diff --git a/.github/test-spec.yml b/.github/test-spec.yml new file mode 100644 index 000000000000..5337249f7dab --- /dev/null +++ b/.github/test-spec.yml @@ -0,0 +1,367 @@ +# This is the Jenkins ci variant of the .github/labler.yaml + +"CI-run-zephyr-twister": + - any: + - "!.github/**/*" + - "!doc/**/*" + - "!CODEOWNERS" + - "!LICENSE" + - "!**/*.rst" + - "!VERSION" + - "!submanifests/**/*" + - "!MAINTAINERS.yml" + - "!version.h.in" + - "!Jenkinsfile" + - "!**/*.md" + +"CI-iot-zephyr-lwm2m-test": + - "drivers/console/**/*" + - "drivers/flash/**/*" + - "subsys/dfu/boot/**/*" + - "subsys/net/ip/**/*" + - "subsys/net/lib/http/**/*" + - "subsys/net/lib/lwm2m//**/*" + - "subsys/net/**/*" + +"CI-iot-samples-test": + - "boards/nordic/nrf9160dk/**/*" + - "dts/arm/nordic/nrf9160*" + - "include/net/**/*" + - "subsys/net/lib/**/*" + +"CI-iot-libraries-test": + - "boards/nordic/nrf9160dk/**/*" + - "dts/arm/nordic/nrf9160*" + - "include/net/socket_ncs.h" + - "subsys/testsuite/ztest/**/*" + +"CI-lwm2m-test": null +# Not necessary to run tests on changes to this repo. + +"CI-boot-test": + - "boards/nordic/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "subsys/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "include/dfu/**/*" + - "samples/subsys/mgmt/mcumgr/smp_svr/**/*" + - "tests/boot/**/*" + - "tests/subsys/dfu/**/*" + - "tests/subsys/mgmt/mcumgr/**/*" + +"CI-tfm-test": + - "boards/nordic/nrf5340dk/**/*" + - "boards/nordic/nrf9160dk/**/*" + - "drivers/entropy/*" + - "dts/arm/nordic/nrf5340*" + - "dts/arm/nordic/nrf9160*" + - "modules/trusted-firmware-m/**/*" + - "samples/tfm_integration/**/*" + +"CI-ble-test": + - any: + - "drivers/bluetooth/**/*" + - any: + - "dts/arm/nordic/nrf5*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/hci_ipc/**/*" + +"CI-ble-samples-test": + - any: + - "drivers/bluetooth/**/*" + - any: + - "dts/arm/nordic/nrf5*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/**/*" + +"CI-mesh-test": + - "subsys/bluetooth/mesh/**/*" + - "include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/mesh/**/*" + - "samples/bluetooth/mesh_demo/**/*" + - "samples/bluetooth/mesh_provisioner/**/*" + - "tests/bluetooth/mesh/**/*" + - "tests/bluetooth/mesh_shell/**/*" + +"CI-thingy91-test": + - "boards/nordic/nrf9160dk/**/*" + - "arch/x86/core/**/*" + - "arch/x86/include/**/*" + - "drivers/console/**/*" + - "drivers/ethernet/**/*" + - "drivers/flash/**/*" + - "drivers/hwinfo/**/*" + - "drivers/interrupt_controller/**/*" + - "drivers/net/**/*" + - "drivers/serial/**/*" + - "drivers/timer/**/*" + - "include/**/*" + - "kernel/**/*" + - "lib/libc/common/source/stdlib/**/*" + - "lib/libc/newlib/**/*" + - "lib/libc/picolibc/**/*" + - "lib/os/**/*" + - "lib/posix/**/*" + - "misc/**/*" + - "modules/mbedtls/**/*" + - "soc/x86/ia32/**/*" + - "subsys/fs/fcb/**/*" + - "subsys/logging/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/include/**/*" + - "subsys/settings/src/**/*" + - "subsys/stats/**/*" + - "subsys/storage/flash_map/**/*" + - "subsys/storage/stream/**/*" + - "subsys/tracing/**/*" + +"CI-desktop-test": + - "drivers/bluetooth/*" + - "subsys/bluetooth/*" + - "include/zephyr/bluetooth/*" + +"CI-crypto-test": + - "boards/nordic/nrf52840dk/**/*" + - "boards/nordic/nrf5340dk/**/*" + - "boards/nordic/nrf9160dk/**/*" + - "drivers/entropy/*" + - "drivers/serial/**/*" + - "dts/arm/nordic/nrf52840*" + - "dts/arm/nordic/nrf5340*" + - "dts/arm/nordic/nrf9160*" + - "include/drivers/serial/**/*" + - "modules/mbedtls/**/*" + +"CI-fem-test": + - "boards/nordic/**/*" + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "dts/bindings/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/arch/**/*" + - "lib/libc/**/*" + - "lib/open-amp/**/*" + - "modules/hal_nordic/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "modules/trusted-firmware-m/**/*" + - "samples/net/sockets/echo_*/**/*" + - "share/**/*" + - "soc/nordic/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + - "subsys/bluetooth/shell/**/*" + - "subsys/ipc/**/*" + - "Kconfig" + - "CMakeLists.txt" + +"CI-rs-test": + - "boards/nordic/**/*" + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "dts/bindings/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/arch/**/*" + - "lib/libc/**/*" + - "lib/open-amp/**/*" + - "modules/hal_nordic/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "modules/trusted-firmware-m/**/*" + - "samples/net/sockets/echo_*/**/*" + - "share/**/*" + - "soc/nordic/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + - "subsys/bluetooth/shell/**/*" + - "subsys/ipc/**/*" + - "Kconfig" + - "CMakeLists.txt" + +"CI-thread-test": + - "include/zephyr/net/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "samples/net/openthread/**/*" + - "soc/nordic/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-nfc-test": + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "drivers/flash/**/*" + - "drivers/mbox/**/*" + - "drivers/spi/**/*" + - "lib/crc/**/*" + - "modules/hal_nordic/**/*" + - "soc/nordic/**/*" + - "subsys/ipc/ipc_service/**/*" + - "subsys/fs/**/*" + - "subsys/mem_mgmt/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/**/*" + - "subsys/shell/**/*" + - "subsys/storage/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + +"CI-matter-test": + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "soc/nordic/**/*" + - "subsys/dfu/**/*" + - "subsys/settings/**/*" + - "subsys/net/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "drivers/net/**/*" + - "samples/bluetooth/hci_ipc/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + +"CI-find-my-test": + - "boards/nordic/**/*" + - "drivers/bluetooth/**/*" + - "drivers/entropy/**/*" + - "drivers/flash/**/*" + - "drivers/usb/**/*" + - "drivers/regulator/**/*" + - "soc/nordic/**/*" + - "subsys/dfu/**/*" + - "subsys/fs/**/*" + - "subsys/ipc/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/**/*" + - "subsys/storage/**/*" + - "subsys/tracing/**/*" + - "subsys/usb/device/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + +"CI-rpc-test": + - "subsys/ipc/ipc_service/**/*" + - "subsys/random/**/*" + - "soc/nordic/nrf53/**/*" + +"CI-modemshell-test": + - "include/net/**/*" + - "include/posix/**/*" + - "include/shell/**/*" + - "drivers/net/**/*" + - "drivers/serial/**/*" + - "drivers/wifi/**/*" + - "subsys/shell/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-positioning-test": + - "include/net/**/*" + - "include/posix/**/*" + - "drivers/net/**/*" + - "drivers/wifi/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-cloud-test": + - "include/zephyr/dfu/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/posix/**/*" + - "include/zephyr/settings/**/*" + - "drivers/led/**/*" + - "drivers/net/**/*" + - "drivers/sensor/**/*" + - "drivers/serial/**/*" + - "drivers/wifi/**/*" + - "lib/posix/**/*" + - "soc/nordic/**/*" + - "subsys/dfu/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-wifi": + - "subsys/net/l2/wifi/**/*" + - "subsys/net/l2/ethernet/**/*" + +"CI-audio-test": + - "boards/nordic/nrf5340_audio_dk/**/*" + - "drivers/flash/**/*" + - "drivers/spi/**/*" + - "drivers/gpio/**/*" + - "drivers/i2c/**/*" + - "drivers/watchdog/**/*" + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "samples/bluetooth/hci_ipc/**/*" + - "soc/nordic/**/*" + - "subsys/bluetooth/audio/**/*" + - "subsys/bluetooth/host/**/*" + - "subsys/dfu/**/*" + - "subsys/fs/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "subsys/sd/**/*" + - "subsys/storage/**/*" + - "subsys/task_wdt/**/*" + - "subsys/usb/**/*" + - "subsys/zbus/**/*" + +"CI-pmic-samples-test": + - "samples/shields/npm1300_ek/**/*" + - "boards/shields/npm1300_ek/**/*" + - "**/**npm1300**/**" + - "drivers/regulator/regulator_common.c" + - "drivers/regulator/regulator_shell.c" + - "drivers/gpio/gpio_shell.c" + - "drivers/sensor/sensor_shell.c" + +"CI-test-low-level": + - "arch/**/*" + - "boards/nordic/nrf54*/**/*" + - "drivers/**/*" + - "dts/**/*" + - "include/zephyr/**/*" + - "kernel/**/*" + - "modules/hal_nordic/**/*" + - "samples/basic/blinky_pwm/**/*" + - "samples/basic/fade_led/**/*" + - "samples/boards/nrf/**/*" + - "samples/boards/nordic/**/*" + - "samples/drivers/adc/**/*" + - "samples/drivers/jesd216/**/*" + - "samples/drivers/mbox/**/*" + - "samples/drivers/soc_flash_nrf/**/*" + - "samples/drivers/spi_flash/**/*" + - "samples/drivers/watchdog/**/*" + - "samples/hello_world/**/*" + - "samples/sensor/**/*" + - "samples/subsys/ipc/**/*" + - "samples/subsys/logging/**/*" + - "samples/subsys/settings/**/*" + - "samples/subsys/usb/cdc_acm/**/*" + - "samples/subsys/usb/mass/**/*" + - "samples/synchronization/**/*" + - "subsys/logging/**/*" + - "subsys/settings/**/*" + - "tests/arch/**/*" + - "tests/boards/nrf/**/*" + - "tests/boards/nordic/**/*" + - "tests/drivers/**/*" + - "tests/kernel/**/*" diff --git a/.github/workflows/commit-tags.yml b/.github/workflows/commit-tags.yml new file mode 100644 index 000000000000..828f02971678 --- /dev/null +++ b/.github/workflows/commit-tags.yml @@ -0,0 +1,28 @@ +name: Commit tags + +on: + pull_request: + types: [synchronize, opened, reopened, edited, labeled, unlabeled, + milestoned, demilestoned, assigned, unassigned, ready_for_review, + review_requested] + +jobs: + commit_tags: + runs-on: ubuntu-22.04 + name: Run commit tags checks on patch series (PR) + steps: + - name: Update PATH for west + run: | + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Checkout the code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Run the commit tags + uses: nrfconnect/action-commit-tags@main + with: + target: . + upstream: zephyrproject-rtos/zephyr/main diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 9d1621cc4d3a..22744e8a6ac1 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -34,8 +34,8 @@ jobs: git config --global user.name "Your Name" git remote -v # Ensure there's no merge commits in the PR - [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ - (echo "::error ::Merge commits not allowed, rebase instead";false) + #[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ + #(echo "::error ::Merge commits not allowed, rebase instead";false) rm -fr ".git/rebase-apply" rm -fr ".git/rebase-merge" git rebase origin/${BASE_REF} @@ -72,12 +72,9 @@ jobs: git log --pretty=oneline | head -n 10 # Increase rename limit to allow for large PRs git config diff.renameLimit 10000 - excludes="-e KconfigBasic -e SysbuildKconfigBasic -e ClangFormat" - # The signed-off-by check for dependabot should be skipped - if [ "${{ github.actor }}" == "dependabot[bot]" ]; then - excludes="$excludes -e Identity" - fi - ./scripts/ci/check_compliance.py --annotate $excludes -c origin/${BASE_REF}.. + ./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e SysbuildKconfigBasic \ + -e Kconfig -e SysbuildKconfig -e KconfigBasicNoModules -e SysbuildKconfigBasicNoModules \ + -e ModulesMaintainers -c origin/${BASE_REF}.. - name: upload-results uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 diff --git a/.github/workflows/manifest-PR.yml b/.github/workflows/manifest-PR.yml new file mode 100644 index 000000000000..a871aa381ded --- /dev/null +++ b/.github/workflows/manifest-PR.yml @@ -0,0 +1,17 @@ +name: handle manifest PR +on: + pull_request_target: + types: [opened, synchronize, closed] + branches: + - main + + +jobs: + call-manifest-pr-action: + runs-on: ubuntu-latest + steps: + - name: handle manifest PR + uses: nrfconnect/action-manifest-pr@main + with: + token: ${{ secrets.NCS_GITHUB_TOKEN }} + manifest-pr-title-details: ${{ github.event.pull_request.title }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0effc0c381cd..3157813d65c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,13 +159,19 @@ zephyr_compile_options($<$:$:$>) # Extra warnings options for twister run -if (CONFIG_COMPILER_WARNINGS_AS_ERRORS) +if(CONFIG_COMPILER_WARNINGS_AS_ERRORS) zephyr_compile_options($<$:$>) zephyr_compile_options($<$:$>) zephyr_compile_options($<$:$>) zephyr_link_libraries($) endif() +if(CONFIG_DEPRECATION_TEST) + zephyr_compile_options($<$:$>) + zephyr_compile_options($<$:$>) + zephyr_compile_options($<$:$>) +endif() + # @Intent: Set compiler flags to enable buffer overflow checks in libc functions # @details: # Kconfig.zephyr "Detect buffer overflows in libc calls" is a kconfig choice, diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000000..3b9cf0022399 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,5 @@ +@Library("CI_LIB") _ + +def pipeline = new ncs.sdk_zephyr.Main() + +pipeline.run(JOB_NAME) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 070b4231eee8..9baae3922090 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -542,7 +542,6 @@ config LTO config COMPILER_WARNINGS_AS_ERRORS bool "Treat warnings as errors" - depends on !DEPRECATION_TEST help Turn on "warning as error" toolchain flags diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 3e7c3048b538..77296a734a6d 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -1041,7 +1041,6 @@ Documentation: - doc/images/Zephyr-Kite-in-tree.png - doc/index-tex.rst - doc/index.rst - - doc/kconfig.rst - doc/templates/sample.tmpl - doc/templates/board.tmpl - boards/index.rst diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 0bf7a219c27d..383fd573513c 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,6 +8,9 @@ #include #include +#if USE_PARTITION_MANAGER +#include +#endif static const struct arm_mpu_region mpu_regions[] = { #ifdef CONFIG_XIP @@ -24,6 +27,14 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", +#if USE_PARTITION_MANAGER + PM_SRAM_ADDRESS, +#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) + REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), +#else + REGION_RAM_ATTR(REGION_SRAM_SIZE)), +#endif +#else CONFIG_SRAM_BASE_ADDRESS, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) REGION_RAM_ATTR(CONFIG_SRAM_BASE_ADDRESS, \ @@ -31,6 +42,8 @@ static const struct arm_mpu_region mpu_regions[] = { #else REGION_RAM_ATTR(REGION_SRAM_SIZE)), #endif + +#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/boards/index.rst b/boards/index.rst index 3cc92770cfeb..2ffe426fc24b 100644 --- a/boards/index.rst +++ b/boards/index.rst @@ -12,33 +12,8 @@ template available under :zephyr_file:`doc/templates/board.tmpl`. Shields are hardware add-ons that can be stacked on top of a board to add extra functionality. Refer to the :ref:`shield_porting_guide` for more information on how to port a shield. -.. admonition:: Search Tips - :class: dropdown - - * Use the form below to filter the list of supported boards and shields. If a field is left - empty, it will not be used in the filtering process. - - * Filtering by name and vendor is available for both boards and shields. The rest of the fields - apply only to boards. - - * A board/shield must meet **all** criteria selected across different fields. For example, if you - select both a vendor and an architecture, only boards that match both will be displayed. Within - a single field, selecting multiple options (such as two architectures) will show boards - matching **either** option. - - * The list of supported hardware features for each board is automatically generated using - information from the Devicetree. It may not be reflecting the full list of supported features - since some of them may not be enabled by default. - - * Can't find your exact board? Don't worry! If a similar board with the same or a closely related - MCU exists, you can use it as a :ref:`starting point ` for adding - support for your own board. - .. toctree:: :maxdepth: 2 :glob: - :hidden: */index - -.. zephyr:board-catalog:: diff --git a/boards/nordic/nrf54h20dk/Kconfig.defconfig b/boards/nordic/nrf54h20dk/Kconfig.defconfig index 60c9345eb045..d2ac190fd178 100644 --- a/boards/nordic/nrf54h20dk/Kconfig.defconfig +++ b/boards/nordic/nrf54h20dk/Kconfig.defconfig @@ -9,6 +9,25 @@ config BT_HCI_IPC config MAX_THREAD_BYTES default 3 if USERSPACE +config ROM_START_OFFSET + default 0x800 if BOOTLOADER_MCUBOOT + +if !USE_DT_CODE_PARTITION + +# Application core firmware must start at this offset when not using MCUboot. +# However, the default 'zephyr,code-partition' in DT is set for MCUboot. +config FLASH_LOAD_OFFSET + default $(dt_nodelabel_reg_addr_hex,cpuapp_boot_partition) + +# This is meant to span 'cpuapp_boot_partition' and 'cpuapp_slot0_partition' +# in the default memory map. +config FLASH_LOAD_SIZE + default $(add_hex, $(dt_nodelabel_reg_addr_hex,cpuapp_slot0_partition), \ + $(dt_nodelabel_reg_size_hex,cpuapp_slot0_partition), \ + -$(dt_nodelabel_reg_addr_hex,cpuapp_boot_partition)) + +endif # !USE_DT_CODE_PARTITION + endif # BOARD_NRF54H20DK_NRF54H20_CPUAPP if BOARD_NRF54H20DK_NRF54H20_CPURAD @@ -16,14 +35,7 @@ if BOARD_NRF54H20DK_NRF54H20_CPURAD config MAX_THREAD_BYTES default 3 if USERSPACE -endif # BOARD_NRF54H20DK_NRF54H20_CPURAD - -if BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON - config ROM_START_OFFSET default 0x800 if BOOTLOADER_MCUBOOT -config FLASH_LOAD_OFFSET - default 0x2c000 if !USE_DT_CODE_PARTITION - -endif # BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON +endif # BOARD_NRF54H20DK_NRF54H20_CPURAD diff --git a/boards/nordic/nrf54h20dk/Kconfig.nrf54h20dk b/boards/nordic/nrf54h20dk/Kconfig.nrf54h20dk index c509f968db6d..62ad7a0d21c1 100644 --- a/boards/nordic/nrf54h20dk/Kconfig.nrf54h20dk +++ b/boards/nordic/nrf54h20dk/Kconfig.nrf54h20dk @@ -2,13 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_NRF54H20DK - select SOC_NRF54H20_CPUAPP if (BOARD_NRF54H20DK_NRF54H20_CPUAPP || \ - BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON) - select SOC_NRF54H20_CPURAD if (BOARD_NRF54H20DK_NRF54H20_CPURAD || \ - BOARD_NRF54H20DK_NRF54H20_CPURAD_IRON) + select SOC_NRF54H20_CPUAPP if BOARD_NRF54H20DK_NRF54H20_CPUAPP + select SOC_NRF54H20_CPURAD if BOARD_NRF54H20DK_NRF54H20_CPURAD select SOC_NRF54H20_CPUPPR if (BOARD_NRF54H20DK_NRF54H20_CPUPPR || \ BOARD_NRF54H20DK_NRF54H20_CPUPPR_XIP) select SOC_NRF54H20_CPUFLPR if (BOARD_NRF54H20DK_NRF54H20_CPUFLPR || \ BOARD_NRF54H20DK_NRF54H20_CPUFLPR_XIP) - select SOC_NRF54H20_IRON if (BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON || \ - BOARD_NRF54H20DK_NRF54H20_CPURAD_IRON) diff --git a/boards/nordic/nrf54h20dk/Kconfig.sysbuild b/boards/nordic/nrf54h20dk/Kconfig.sysbuild new file mode 100644 index 000000000000..29bd62b49927 --- /dev/null +++ b/boards/nordic/nrf54h20dk/Kconfig.sysbuild @@ -0,0 +1,9 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NRF54H20DK_NRF54H20_CPURAD + +config NRF_DEFAULT_EMPTY + default y + +endif # BOARD_NRF54H20DK_NRF54H20_CPURAD diff --git a/boards/nordic/nrf54h20dk/board.cmake b/boards/nordic/nrf54h20dk/board.cmake index 093155e93222..b9383042b0c7 100644 --- a/boards/nordic/nrf54h20dk/board.cmake +++ b/boards/nordic/nrf54h20dk/board.cmake @@ -2,10 +2,7 @@ include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) -if(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP OR - CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD OR - CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON OR - CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD_IRON) +if(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP OR CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD) if(CONFIG_SOC_NRF54H20_CPUAPP) set(JLINKSCRIPTFILE ${CMAKE_CURRENT_LIST_DIR}/support/nrf54h20_cpuapp.JLinkScript) else() @@ -17,7 +14,7 @@ if(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP OR endif() if(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUPPR OR CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUFLPR) - if(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUPPR) + if(CONFIG_SOC_NRF54H20_CPUPPR) set(JLINKSCRIPTFILE ${CMAKE_CURRENT_LIST_DIR}/support/nrf54h20_cpuppr.JLinkScript) else() set(JLINKSCRIPTFILE ${CMAKE_CURRENT_LIST_DIR}/support/nrf54h20_cpuflpr.JLinkScript) diff --git a/boards/nordic/nrf54h20dk/board.yml b/boards/nordic/nrf54h20dk/board.yml index a54cf1ae549f..2d3d40c20e0b 100644 --- a/boards/nordic/nrf54h20dk/board.yml +++ b/boards/nordic/nrf54h20dk/board.yml @@ -9,10 +9,6 @@ board: cpucluster: cpuppr - name: xip cpucluster: cpuflpr - - name: iron - cpucluster: cpuapp - - name: iron - cpucluster: cpurad revision: format: major.minor.patch default: "0.9.0" diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi index 94cda5e8ee2e..f31d909b6f94 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi @@ -7,17 +7,17 @@ / { ipc { cpusec_cpuapp_ipc: ipc-1-2 { - compatible = "zephyr,ipc-icmsg"; + compatible = "nordic,ironside-call"; status = "disabled"; - dcache-alignment = <32>; + memory-region = <&cpusec_cpuapp_ipc_shm>; mboxes = <&cpusec_bellboard 12>, <&cpuapp_bellboard 0>; }; cpusec_cpurad_ipc: ipc-1-3 { - compatible = "zephyr,ipc-icmsg"; + compatible = "nordic,ironside-call"; status = "disabled"; - dcache-alignment = <32>; + memory-region = <&cpusec_cpurad_ipc_shm>; mboxes = <&cpusec_bellboard 18>, <&cpurad_bellboard 0>; }; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi index f29374025540..b6a53955c60e 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi @@ -7,170 +7,109 @@ / { reserved-memory { - cpuapp_ram0x_region: memory@2f010000 { - compatible = "nordic,owned-memory"; - reg = <0x2f010000 DT_SIZE_K(260)>; - status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2f010000 0x41000>; - - cpusec_cpuapp_ipc_shm: memory@0 { - reg = <0x0 DT_SIZE_K(2)>; - }; - - cpuapp_cpusec_ipc_shm: memory@800 { - reg = <0x800 DT_SIZE_K(2)>; - }; - - cpuapp_data: memory@1000 { - reg = <0x1000 DT_SIZE_K(256)>; - }; + cpuapp_data: memory@2f000000 { + reg = <0x2f000000 DT_SIZE_K(760)>; }; - cpurad_ram0x_region: memory@2f051000 { - compatible = "nordic,owned-memory"; - reg = <0x2f051000 DT_SIZE_K(4)>; - status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2f051000 0x1000>; - - cpusec_cpurad_ipc_shm: memory@0 { - reg = <0x0 DT_SIZE_K(2)>; - }; + etr_buffer: memory@2f0be000 { + reg = <0x2f0be000 DT_SIZE_K(4)>; + }; - cpurad_cpusec_ipc_shm: memory@800 { - reg = <0x800 DT_SIZE_K(2)>; - }; + cpuapp_cpurad_ipc_shm: memory@2f0bf000 { + reg = <0x2f0bf000 DT_SIZE_K(2)>; }; - etr_buf_ram0x_region: memory@2f0be000 { - compatible = "nordic,owned-memory"; - reg = <0x2f0be000 DT_SIZE_K(4)>; - status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2f0be000 0x1000>; + cpurad_cpuapp_ipc_shm: memory@2f0bf800 { + reg = <0x2f0bf800 DT_SIZE_K(2)>; + }; - /* TODO In future move this region to cpuapp_ram0x_region. */ - etr_buffer: memory@0 { - reg = <0x0 DT_SIZE_K(4)>; - }; + cpuapp_cpusys_ipc_shm: memory@2f88f600 { + reg = <0x2f88f600 0x80>; }; - cpuapp_cpurad_ram0x_region: memory@2f0bf000 { - compatible = "nordic,owned-memory"; - reg = <0x2f0bf000 DT_SIZE_K(4)>; - status = "disabled"; - nordic,access = , - ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2f0bf000 0x1000>; + cpusys_cpuapp_ipc_shm: memory@2f88f680 { + reg = <0x2f88f680 0x80>; + }; - cpuapp_cpurad_ipc_shm: memory@0 { - reg = <0x0 DT_SIZE_K(2)>; - }; + cpurad_cpusys_ipc_shm: memory@2f88f700 { + reg = <0x2f88f700 0x80>; + }; - cpurad_cpuapp_ipc_shm: memory@800 { - reg = <0x800 DT_SIZE_K(2)>; - }; + cpusys_cpurad_ipc_shm: memory@2f88f780 { + reg = <0x2f88f780 0x80>; }; - cpuapp_cpusys_ipc_shm: memory@2f88fce0 { - reg = <0x2f88fce0 0x80>; + cpusec_cpurad_ipc_shm: memory@2f88f800 { + reg = <0x2f88f800 0x80>; }; - cpusys_cpuapp_ipc_shm: memory@2f88fd60 { - reg = <0x2f88fd60 0x80>; + cpurad_ironside_se_event_report: memory@2f88f880 { + reg = <0x2f88f880 0x100>; }; - cpurad_cpusys_ipc_shm: memory@2f88fe00 { - reg = <0x2f88fe00 0x80>; + cpurad_ironside_se_boot_report: memory@2f88f980 { + reg = <0x2f88f980 0x200>; }; - cpusys_cpurad_ipc_shm: memory@2f88fe80 { - reg = <0x2f88fe80 0x80>; + cpusec_cpuapp_ipc_shm: memory@2f88fb80 { + reg = <0x2f88fb80 0x80>; }; - /* - * NOTE: FLPR has a direct bridge with RAM21 that bypasses MPC. - * This means that when this region is marked as non-executable, - * only FLPR can execute code from it. - */ - ram21_region: memory@2f890000 { - compatible = "nordic,owned-memory"; - status = "disabled"; - reg = <0x2f890000 DT_SIZE_K(64)>; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2f890000 0x10000>; + cpuapp_ironside_se_event_report: memory@2f88fc00 { + reg = <0x2f88fc00 0x100>; + }; - cpuflpr_code_data: memory@0 { - reg = <0x0 DT_SIZE_K(46)>; - }; + cpuapp_ironside_se_boot_report: memory@2f88fd00 { + reg = <0x2f88fd00 0x200>; + }; - cpuapp_cpuflpr_ipc_shm: memory@b800 { - reg = <0xb800 DT_SIZE_K(1)>; - }; + cpuflpr_code_data: memory@2f890000 { + reg = <0x2f890000 DT_SIZE_K(46)>; + }; - cpuflpr_cpuapp_ipc_shm: memory@bc00 { - reg = <0xbc00 DT_SIZE_K(1)>; - }; + cpuapp_cpuflpr_ipc_shm: memory@2f89b800 { + reg = <0x2f89b800 DT_SIZE_K(1)>; + }; - dma_fast_region: memory@c000 { - compatible = "zephyr,memory-region"; - reg = <0xc000 DT_SIZE_K(16)>; - status = "disabled"; - #memory-region-cells = <0>; - zephyr,memory-region = "DMA_RAM21"; - zephyr,memory-attr = <( DT_MEM_DMA | DT_MEM_CACHEABLE )>; - }; + cpuflpr_cpuapp_ipc_shm: memory@2f89bc00 { + reg = <0x2f89bc00 DT_SIZE_K(1)>; }; - cpuppr_ram3x_region: memory@2fc00000 { - compatible = "nordic,owned-memory"; - reg = <0x2fc00000 DT_SIZE_K(64)>; + dma_fast_region: memory@2f89c000 { + compatible = "zephyr,memory-region"; + reg = <0x2f89c000 DT_SIZE_K(16)>; status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2fc00000 0x10000>; + #memory-region-cells = <0>; + zephyr,memory-region = "DMA_RAM21"; + zephyr,memory-attr = <( DT_MEM_DMA | DT_MEM_CACHEABLE )>; + }; - cpuppr_code_data: memory@0 { - reg = <0x0 DT_SIZE_K(62)>; - }; + cpuppr_code_data: memory@2fc00000 { + reg = <0x2fc00000 DT_SIZE_K(62)>; + }; - cpuapp_cpuppr_ipc_shm: memory@f800 { - reg = <0xf800 DT_SIZE_K(1)>; - }; + cpuapp_cpuppr_ipc_shm: memory@2fc0f800 { + reg = <0x2fc0f800 DT_SIZE_K(1)>; + }; - cpuppr_cpuapp_ipc_shm: memory@fc00 { - reg = <0xfc00 DT_SIZE_K(1)>; - }; + cpuppr_cpuapp_ipc_shm: memory@2fc0fc00 { + reg = <0x2fc0fc00 DT_SIZE_K(1)>; }; cpuapp_dma_region: memory@2fc12000 { - compatible = "nordic,owned-memory", "zephyr,memory-region"; + compatible = "zephyr,memory-region"; reg = <0x2fc12000 DT_SIZE_K(4)>; status = "disabled"; #memory-region-cells = <0>; - nordic,access = ; zephyr,memory-region = "DMA_RAM3x_APP"; zephyr,memory-attr = <( DT_MEM_DMA )>; }; cpurad_dma_region: memory@2fc13000 { - compatible = "nordic,owned-memory", "zephyr,memory-region"; + compatible = "zephyr,memory-region"; reg = <0x2fc13000 DT_SIZE_K(1)>; status = "disabled"; #memory-region-cells = <0>; - nordic,access = ; zephyr,memory-region = "DMA_RAM3x_RAD"; zephyr,memory-attr = <( DT_MEM_DMA )>; }; @@ -187,27 +126,21 @@ }; &mram1x { - cpurad_rx_partitions: cpurad-rx-partitions { - compatible = "nordic,owned-partitions", "fixed-partitions"; - status = "disabled"; - nordic,access = ; + partitions { + compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - cpurad_slot0_partition: partition@54000 { - reg = <0x54000 DT_SIZE_K(256)>; + cpuapp_boot_partition: partition@30000 { + reg = <0x30000 DT_SIZE_K(64)>; }; - }; - cpuapp_rx_partitions: cpuapp-rx-partitions { - compatible = "nordic,owned-partitions", "fixed-partitions"; - status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; + cpuapp_slot0_partition: partition@40000 { + reg = <0x40000 DT_SIZE_K(328)>; + }; - cpuapp_slot0_partition: partition@94000 { - reg = <0x94000 DT_SIZE_K(320)>; + cpurad_slot0_partition: partition@92000 { + reg = <0x92000 DT_SIZE_K(328)>; }; cpuppr_code_partition: partition@e4000 { @@ -217,21 +150,21 @@ cpuflpr_code_partition: partition@f4000 { reg = <0xf4000 DT_SIZE_K(48)>; }; - }; - cpuapp_rw_partitions: cpuapp-rw-partitions { - compatible = "nordic,owned-partitions", "fixed-partitions"; - status = "disabled"; - nordic,access = ; - #address-cells = <1>; - #size-cells = <1>; + cpuapp_slot1_partition: partition@100000 { + reg = <0x100000 DT_SIZE_K(328)>; + }; + + cpurad_slot1_partition: partition@152000 { + reg = <0x152000 DT_SIZE_K(328)>; + }; - dfu_partition: partition@100000 { - reg = < 0x100000 DT_SIZE_K(908) >; + storage_partition: partition@1a4000 { + reg = <0x1a4000 DT_SIZE_K(40)>; }; - storage_partition: partition@1e3000 { - reg = < 0x1e3000 DT_SIZE_K(40) >; + periphconf_partition: partition@1ae000 { + reg = <0x1ae000 DT_SIZE_K(8)>; }; }; }; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map_iron.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map_iron.dtsi deleted file mode 100644 index 2977e83758b4..000000000000 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map_iron.dtsi +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2025 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* This file is to be merged with the original memory_map.dtsi in the future. - * The following nodes will be replaced: - */ -/delete-node/ &cpuapp_cpusec_ipc_shm; -/delete-node/ &cpuapp_cpusys_ipc_shm; -/delete-node/ &cpurad_cpusec_ipc_shm; -/delete-node/ &cpurad_cpusys_ipc_shm; -/delete-node/ &cpusec_cpuapp_ipc_shm; -/delete-node/ &cpusec_cpurad_ipc_shm; -/delete-node/ &cpusys_cpuapp_ipc_shm; -/delete-node/ &cpusys_cpurad_ipc_shm; -/delete-node/ &cpuapp_rw_partitions; -/delete-node/ &cpuapp_rx_partitions; -/delete-node/ &cpurad_rx_partitions; - -/ { - reserved-memory { - cpuapp_cpusys_ipc_shm: memory@2f88f600 { - reg = <0x2f88f600 0x80>; - }; - - cpusys_cpuapp_ipc_shm: memory@2f88f680 { - reg = <0x2f88f680 0x80>; - }; - - cpurad_cpusys_ipc_shm: memory@2f88f700 { - reg = <0x2f88f700 0x80>; - }; - - cpusys_cpurad_ipc_shm: memory@2f88f780 { - reg = <0x2f88f780 0x80>; - }; - - cpusec_cpurad_ipc_shm: memory@2f88f800 { - reg = <0x2f88f800 0x80>; - }; - - cpurad_ironside_se_event_report: memory@2f88f880 { - reg = <0x2f88f880 0x100>; - }; - - cpurad_ironside_se_boot_report: memory@2f88f980 { - reg = <0x2f88f980 0x200>; - }; - - cpusec_cpuapp_ipc_shm: memory@2f88fb80 { - reg = <0x2f88fb80 0x80>; - }; - - cpuapp_ironside_se_event_report: memory@2f88fc00 { - reg = <0x2f88fc00 0x100>; - }; - - cpuapp_ironside_se_boot_report: memory@2f88fd00 { - reg = <0x2f88fd00 0x200>; - }; - }; -}; - -&mram1x { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - cpuapp_boot_partition: partition@2c000 { - reg = <0x2c000 DT_SIZE_K(64)>; - }; - - cpuapp_slot0_partition: partition@3c000 { - reg = <0x3c000 DT_SIZE_K(336)>; - }; - - cpurad_slot0_partition: partition@90000 { - reg = <0x90000 DT_SIZE_K(336)>; - }; - - cpuppr_code_partition: partition@e4000 { - reg = <0xe4000 DT_SIZE_K(64)>; - }; - - cpuflpr_code_partition: partition@f4000 { - reg = <0xf4000 DT_SIZE_K(48)>; - }; - - cpuapp_slot1_partition: partition@100000 { - reg = <0x100000 DT_SIZE_K(336)>; - }; - - cpurad_slot1_partition: partition@154000 { - reg = <0x154000 DT_SIZE_K(336)>; - }; - - storage_partition: partition@1a8000 { - reg = <0x1a8000 DT_SIZE_K(40)>; - }; - }; -}; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts index 9cbc9035d4f8..85a2539c3ffe 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts @@ -18,14 +18,16 @@ chosen { zephyr,console = &uart136; - zephyr,code-partition = &cpuapp_slot0_partition; + zephyr,code-partition = &slot0_partition; zephyr,flash = &mram1x; zephyr,sram = &cpuapp_data; zephyr,shell-uart = &uart136; + zephyr,uart-mcumgr = &uart136; zephyr,ieee802154 = &cpuapp_ieee802154; zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; zephyr,canbus = &can120; + zephyr,entropy = &prng; }; aliases { @@ -106,18 +108,11 @@ pwms = <&pwm130 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; }; }; -}; - -&cpuapp_ram0x_region { - status = "okay"; -}; - -&etr_buf_ram0x_region { - status = "okay"; -}; -&ram21_region { - status = "okay"; + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; + }; }; &cpuapp_bellboard { @@ -145,8 +140,6 @@ &cpusec_cpuapp_ipc { status = "okay"; mbox-names = "tx", "rx"; - tx-region = <&cpuapp_cpusec_ipc_shm>; - rx-region = <&cpusec_cpuapp_ipc_shm>; }; &cpusec_bellboard { @@ -190,12 +183,26 @@ ipc0: &cpuapp_cpurad_ipc { status = "okay"; }; -&cpuapp_rx_partitions { - status = "okay"; +ironside_se_boot_report: &cpuapp_ironside_se_boot_report {}; + +boot_partition: &cpuapp_boot_partition { + label = "mcuboot"; }; -&cpuapp_rw_partitions { - status = "okay"; +slot0_partition: &cpuapp_slot0_partition { + label = "image-0"; +}; + +slot1_partition: &cpuapp_slot1_partition { + label = "image-1"; +}; + +slot2_partition: &cpurad_slot0_partition { + label = "image-2"; +}; + +slot3_partition: &cpurad_slot1_partition { + label = "image-3"; }; &cpuppr_vpr { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_9_0.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_9_0.yaml index 1884ce0a4d0d..4e82987d28e5 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_9_0.yaml +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_9_0.yaml @@ -9,8 +9,8 @@ toolchain: - gnuarmemb - zephyr sysbuild: true -ram: 256 -flash: 296 +ram: 760 +flash: 392 supported: - adc - can diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_defconfig b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_defconfig index e1ba596d1358..70bb6a24c9c0 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_defconfig +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_defconfig @@ -8,8 +8,6 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_USE_DT_CODE_PARTITION=y - # Enable MPU CONFIG_ARM_MPU=y diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts index ebeb2aeeafff..7e1a1c8e9e04 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts @@ -24,9 +24,15 @@ zephyr,flash = &mram1x; zephyr,sram = &cpurad_ram0; zephyr,shell-uart = &uart135; + zephyr,uart-mcumgr = &uart135; zephyr,ieee802154 = &cpurad_ieee802154; zephyr,bt-hci-ipc = &ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &prng; + }; + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; }; aliases { @@ -35,14 +41,6 @@ }; }; -&cpuapp_cpurad_ram0x_region { - status = "okay"; -}; - -&cpurad_ram0x_region { - status = "okay"; -}; - &cpurad_bellboard { status = "okay"; interrupts = <96 NRF_DEFAULT_IRQ_PRIORITY>; @@ -62,8 +60,6 @@ &cpusec_cpurad_ipc { status = "okay"; mbox-names = "tx", "rx"; - tx-region = <&cpurad_cpusec_ipc_shm>; - rx-region = <&cpusec_cpurad_ipc_shm>; }; &cpusec_bellboard { @@ -90,8 +86,12 @@ ipc0: &cpuapp_cpurad_ipc { status = "okay"; }; -&cpurad_rx_partitions { - status = "okay"; +slot0_partition: &cpurad_slot0_partition { + label = "image-0"; +}; + +slot1_partition: &cpurad_slot1_partition { + label = "image-1"; }; &grtc { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_9_0.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_9_0.yaml index de557fcc2cdb..8567494d1e3a 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_9_0.yaml +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_9_0.yaml @@ -10,7 +10,7 @@ toolchain: - zephyr sysbuild: true ram: 192 -flash: 256 +flash: 328 supported: - counter - gpio diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron.dts deleted file mode 100644 index 669143a79dac..000000000000 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron.dts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "nrf54h20dk_nrf54h20_cpurad.dts" -#include "nrf54h20dk_nrf54h20-ipc_conf_iron.dtsi" -#include "nrf54h20dk_nrf54h20-memory_map_iron.dtsi" - -/ { - chosen { - zephyr,code-partition = &cpurad_slot0_partition; - zephyr,uart-mcumgr = &uart135; - }; -}; - -&cpusec_cpurad_ipc { - mbox-names = "tx", "rx"; - status = "okay"; -}; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_0_9_0.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_0_9_0.yaml deleted file mode 100644 index ef71cfa924c0..000000000000 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_0_9_0.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2025 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -identifier: nrf54h20dk/nrf54h20/cpurad/iron -name: nRF54H20-DK-nRF54H20-Radio (IRONside SE compatible) (revision 0.9.0) -type: mcu -arch: arm -toolchain: - - gnuarmemb - - xtools - - zephyr -sysbuild: true -ram: 192 -flash: 336 -supported: - - counter - - gpio - - pwm - - retained_mem - - spi diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_defconfig b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_defconfig deleted file mode 100644 index 0ee0a96f99d7..000000000000 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_iron_defconfig +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2025 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -# Enable UART driver -CONFIG_SERIAL=y - -# Enable console -CONFIG_CONSOLE=y -CONFIG_UART_CONSOLE=y - -CONFIG_USE_DT_CODE_PARTITION=y - -# Enable MPU -CONFIG_ARM_MPU=y - -# Enable hardware stack protection -CONFIG_HW_STACK_PROTECTION=y - -# MPU-based null-pointer dereferencing detection cannot be applied -# as the (0x0 - 0x400) region is unmapped for this target. -CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y - -# Enable cache -CONFIG_CACHE_MANAGEMENT=y -CONFIG_EXTERNAL_CACHE=y - -# UICR generation is not supported, and when reintroduced will not use nrf-regtool. -CONFIG_NRF_REGTOOL_GENERATE_UICR=n diff --git a/boards/nordic/nrf54h20dk/support/nrf54h20_cpuapp.JLinkScript b/boards/nordic/nrf54h20dk/support/nrf54h20_cpuapp.JLinkScript index b1b968573991..9738ec77f437 100644 --- a/boards/nordic/nrf54h20dk/support/nrf54h20_cpuapp.JLinkScript +++ b/boards/nordic/nrf54h20dk/support/nrf54h20_cpuapp.JLinkScript @@ -1,6 +1,175 @@ __constant U32 _CPUCONF_ADDR = 0x52011000; __constant U32 _CPUCONF_CPUWAIT_OFFSET = 0x50C; +// ATBFUNNEL +__constant U32 _ATBFUNNEL211_ADDR = 0xBF04D000; +__constant U32 _ATBFUNNEL212_ADDR = 0xBF04E000; +__constant U32 _ATBFUNNEL_CTRLREG_OFFSET = 0x0; +__constant U32 _HOLDTIME_4 = 0x300; +__constant U32 _ENS0 = 0x1; +__constant U32 _ENS1 = 0x2; +__constant U32 _ENS2 = 0x4; + +// ATBREPLICATOR +__constant U32 _ATBREPLICATOR212_ADDR = 0xBF04A000; +__constant U32 _ATBREPLICATOR213_ADDR = 0xBF04B000; +__constant U32 _ATBREPLICATOR_IDFILTER0_OFFSET = 0x0; +__constant U32 _ATBREPLICATOR_IDFILTER1_OFFSET = 0x4; +__constant U32 _ID_NONE = 0xFFFFFFFF; +__constant U32 _ID1x = 0xFFFFFFFD; + +// TSGEN +__constant U32 _TSGEN_ADDR = 0xBF041000; +__constant U32 _TSGEN_CNTCR_OFFSET = 0x0; +__constant U32 _TSGEN_CNTFID0_OFFSET = 0x20; +// Clock rate = TDD Freq. / 8 +__constant U32 _TS_CLOCKRATE = 40000000; + +// CTI +__constant U32 _CTI210_ADDR = 0xBF046000; +__constant U32 _CTICONTROL_OFFSET = 0x0; +__constant U32 _CTIOUTEN_OFFSET = 0xA0; +__constant U32 _CTIGATE_OFFSET = 0x140; +__constant U32 _TPIU_FLUSH_TRIG = 0x2; + +// TPIU +__constant U32 _TPIU_ADDR = 0xBF043000; +__constant U32 _CURRENTPORTSIZE_OFFSET = 0x4; +__constant U32 _FFCR_OFFSET = 0x304; +__constant U32 _FSCR_OFFSET = 0x308; +__constant U32 _ENFCONT = 0x02; +__constant U32 _FONFLIN = 0x10; +__constant U32 _ENFTC = 0x1; +__constant U32 _TPIU_SYNC_FRAME_COUNT = 0x8; +__constant U32 _CURRENTPORTSIZE_4 = 0x8; + +// TDDCONF +__constant U32 _TDDCONF_ADDR = 0xBF001000; +__constant U32 _TRACEPORTSPEED_OFFSET = 0x408; +__constant U32 _SPEED80MHZ = 0x0; + +// CoreSight general +__constant U32 _CORESIGHT_CLAIMSET_OFFSET = 0xFA0; +__constant U32 _CORESIGHT_CLAIMCLR_OFFSET = 0xFA4; +__constant U32 _CORESIGHT_LAR_OFFSET = 0xFB0; +__constant U32 _CORESIGHT_UNLOCK_KEY = 0xC5ACCE55; + +// GPIO P7 +__constant U32 _P7_ADDR = 0x5F938E00; +__constant U32 _PIN_CNF3_OFFSET = 0x8C; +__constant U32 _PIN_CNF4_OFFSET = 0x90; +__constant U32 _PIN_CNF5_OFFSET = 0x94; +__constant U32 _PIN_CNF6_OFFSET = 0x98; +__constant U32 _PIN_CNF7_OFFSET = 0x9C; +__constant U32 _PIN_CNF_TPIU_CLOCK_VALUE = 0x80000503; +__constant U32 _PIN_CNF_TPIU_DATA_VALUE = 0x00000503; + +// Settings +__constant U32 _DEBUGGER_CLAIM_MASK = 0x2; + +// Used to check if we have already set up tracing +int _needCoresightSetup = 1; + +// Unlock a CoreSight peripheral +void _CSUnlock(U32 addr) +{ + JLINK_MEM_WriteU32(addr + _CORESIGHT_LAR_OFFSET, _CORESIGHT_UNLOCK_KEY); +} + +// Lock a CoreSight peripheral +void _CSLock(U32 addr) +{ + JLINK_MEM_WriteU32(addr + _CORESIGHT_LAR_OFFSET, 0); +} + +// Set claim bits in the CoreSight peripheral to indicate to the firmware that it +// has been configured by the host debugger +void _CSClaim(U32 addr) +{ + JLINK_MEM_WriteU32(addr + _CORESIGHT_CLAIMSET_OFFSET, _DEBUGGER_CLAIM_MASK); +} + +// Set up CoreSight and other necessary configuration so to enable ETM -> TPIU tracing. +int _SetupETMTPIUTrace(void) +{ + // Set up ATB funnels/replicators to route ApplicationDomain ETM to TPIU + _CSUnlock(_ATBFUNNEL212_ADDR); + JLINK_MEM_WriteU32(_ATBFUNNEL212_ADDR + _ATBFUNNEL_CTRLREG_OFFSET, _HOLDTIME_4 | _ENS0); + _CSClaim(_ATBFUNNEL212_ADDR); + _CSLock(_ATBFUNNEL212_ADDR); + + _CSUnlock(_ATBREPLICATOR212_ADDR); + JLINK_MEM_WriteU32(_ATBREPLICATOR212_ADDR + _ATBREPLICATOR_IDFILTER0_OFFSET, _ID_NONE); + JLINK_MEM_WriteU32(_ATBREPLICATOR212_ADDR + _ATBREPLICATOR_IDFILTER1_OFFSET, _ID1x); + _CSLock(_ATBREPLICATOR212_ADDR); + _CSClaim(_ATBREPLICATOR212_ADDR); + _CSLock(_ATBREPLICATOR212_ADDR); + + _CSUnlock(_ATBFUNNEL211_ADDR); + JLINK_MEM_WriteU32(_ATBFUNNEL211_ADDR + _ATBFUNNEL_CTRLREG_OFFSET, _HOLDTIME_4 | _ENS0); + _CSClaim(_ATBFUNNEL211_ADDR); + _CSLock(_ATBFUNNEL211_ADDR); + + _CSUnlock(_ATBREPLICATOR213_ADDR); + JLINK_MEM_WriteU32(_ATBREPLICATOR213_ADDR + _ATBREPLICATOR_IDFILTER0_OFFSET, _ID1x); + JLINK_MEM_WriteU32(_ATBREPLICATOR213_ADDR + _ATBREPLICATOR_IDFILTER1_OFFSET, _ID_NONE); + _CSClaim(_ATBREPLICATOR213_ADDR); + _CSLock(_ATBREPLICATOR213_ADDR); + + // Configure timestamp generator for the correct clock rate + JLINK_MEM_WriteU32(_TSGEN_ADDR + _TSGEN_CNTFID0_OFFSET, _TS_CLOCKRATE); + JLINK_MEM_WriteU32(_TSGEN_ADDR + _TSGEN_CNTCR_OFFSET, 1); + _CSClaim(_TSGEN_ADDR); + + // Configure CTI1 for TPIU formatter flushing + _CSUnlock(_CTI210_ADDR); + JLINK_MEM_WriteU32(_CTI210_ADDR + _CTIOUTEN_OFFSET, _TPIU_FLUSH_TRIG); + JLINK_MEM_WriteU32(_CTI210_ADDR + _CTIGATE_OFFSET, _TPIU_FLUSH_TRIG); + JLINK_MEM_WriteU32(_CTI210_ADDR + _CTICONTROL_OFFSET, 1); + _CSClaim(_CTI210_ADDR); + _CSLock(_CTI210_ADDR); + + // Configure TPIU for port size 4, continuous formatting + _CSUnlock(_TPIU_ADDR); + JLINK_MEM_WriteU32(_TPIU_ADDR + _CURRENTPORTSIZE_OFFSET, _CURRENTPORTSIZE_4); + JLINK_MEM_WriteU32(_TPIU_ADDR + _FFCR_OFFSET, _ENFCONT | _FONFLIN | _ENFTC); + JLINK_MEM_WriteU32(_TPIU_ADDR + _FSCR_OFFSET, _TPIU_SYNC_FRAME_COUNT); + _CSClaim(_TPIU_ADDR); + _CSLock(_TPIU_ADDR); + + // Configure the trace pins + JLINK_MEM_WriteU32(_P7_ADDR + _PIN_CNF3_OFFSET, _PIN_CNF_TPIU_CLOCK_VALUE); + JLINK_MEM_WriteU32(_P7_ADDR + _PIN_CNF4_OFFSET, _PIN_CNF_TPIU_DATA_VALUE); + JLINK_MEM_WriteU32(_P7_ADDR + _PIN_CNF5_OFFSET, _PIN_CNF_TPIU_DATA_VALUE); + JLINK_MEM_WriteU32(_P7_ADDR + _PIN_CNF6_OFFSET, _PIN_CNF_TPIU_DATA_VALUE); + JLINK_MEM_WriteU32(_P7_ADDR + _PIN_CNF7_OFFSET, _PIN_CNF_TPIU_DATA_VALUE); + + return 0; +} + +int ConfigTargetSettings(void) +{ + JLINK_ExecCommand("CORESIGHT_AddAP = Index=0 Type=AHB-AP"); + CORESIGHT_IndexAHBAPToUse = 0; + + // Adjust trace sample delay to compensate for timing when using 320MHz + JLINK_ExecCommand("TraceSampleAdjust TD = 1000"); + + return 0; +} + +int OnTraceStart(void) +{ + // Set up CoreSight if not already configured + if (_needCoresightSetup) { + _SetupETMTPIUTrace(); + _needCoresightSetup = 0; + } + + return 0; +} + + int SetupTarget(void) { JLINK_TARGET_Halt(); diff --git a/boards/nordic/nrf54l09pdk/nrf54l09_cpuapp_common.dtsi b/boards/nordic/nrf54l09pdk/nrf54l09_cpuapp_common.dtsi index 7d0c880c2de3..e1347c35948c 100644 --- a/boards/nordic/nrf54l09pdk/nrf54l09_cpuapp_common.dtsi +++ b/boards/nordic/nrf54l09pdk/nrf54l09_cpuapp_common.dtsi @@ -18,7 +18,7 @@ zephyr,bt-c2h-uart = &uart20; zephyr,flash-controller = &rram_controller; zephyr,flash = &cpuapp_rram; - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,ieee802154 = &ieee802154; }; }; @@ -119,7 +119,7 @@ status = "okay"; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; diff --git a/boards/nordic/nrf54l15dk/Kconfig.defconfig b/boards/nordic/nrf54l15dk/Kconfig.defconfig index 9628b1fdf963..b7b15587c58b 100644 --- a/boards/nordic/nrf54l15dk/Kconfig.defconfig +++ b/boards/nordic/nrf54l15dk/Kconfig.defconfig @@ -9,6 +9,7 @@ if BOARD_NRF54L15DK_NRF54L05_CPUAPP || BOARD_NRF54L15DK_NRF54L10_CPUAPP || \ BOARD_NRF54L15DK_NRF54L15_CPUAPP config ROM_START_OFFSET + default 0 if PARTITION_MANAGER_ENABLED default 0x800 if BOOTLOADER_MCUBOOT endif # BOARD_NRF54L15DK_NRF54L05_CPUAPP || BOARD_NRF54L15DK_NRF54L10_CPUAPP || \ diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi b/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi index c030c2c55189..6740544b524a 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_common.dtsi @@ -108,5 +108,9 @@ pinctrl-names = "default", "sleep"; }; +&hfxo { + startup-time-us = <854>; +}; + /* Get a node label for wi-fi spi to use in shield files */ wifi_spi: &spi22 {}; diff --git a/boards/nordic/nrf54l20pdk/nrf54l20_cpuapp_common.dtsi b/boards/nordic/nrf54l20pdk/nrf54l20_cpuapp_common.dtsi index 614ffbca4de3..f719b2d93920 100644 --- a/boards/nordic/nrf54l20pdk/nrf54l20_cpuapp_common.dtsi +++ b/boards/nordic/nrf54l20pdk/nrf54l20_cpuapp_common.dtsi @@ -18,7 +18,7 @@ zephyr,bt-c2h-uart = &uart20; zephyr,flash-controller = &rram_controller; zephyr,flash = &cpuapp_rram; - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,ieee802154 = &ieee802154; }; }; @@ -122,7 +122,7 @@ status = "okay"; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; diff --git a/boards/nordic/nrf7002dk/CMakeLists.txt b/boards/nordic/nrf7002dk/CMakeLists.txt new file mode 100644 index 000000000000..db20255712bc --- /dev/null +++ b/boards/nordic/nrf7002dk/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if((CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) AND + CONFIG_BOARD_ENABLE_CPUNET) + zephyr_library() + zephyr_library_sources(nrf5340_cpunet_reset.c) +endif() diff --git a/boards/nordic/nrf7002dk/Kconfig b/boards/nordic/nrf7002dk/Kconfig index fa6c8097ae32..d4b7030a65ab 100644 --- a/boards/nordic/nrf7002dk/Kconfig +++ b/boards/nordic/nrf7002dk/Kconfig @@ -10,7 +10,9 @@ config MBOX_NRFX_IPC default MBOX if BOARD_NRF7002DK_NRF5340_CPUAPP || \ - BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS config BT_HCI_IPC default y if BT diff --git a/boards/nordic/nrf7002dk/Kconfig.defconfig b/boards/nordic/nrf7002dk/Kconfig.defconfig new file mode 100644 index 000000000000..a6357ae50b2a --- /dev/null +++ b/boards/nordic/nrf7002dk/Kconfig.defconfig @@ -0,0 +1,76 @@ +# nRF5340 DK nRF5340 board configuration + +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +# By default, if we build for a Non-Secure version of the board, +# force building with TF-M as the Secure Execution Environment. +config BUILD_WITH_TFM + default y if BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_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 + +# Code Partition: +# +# 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. + +# SRAM Partition: +# +# If the secure firmware is to be combined with a non-secure image +# (TRUSTED_EXECUTION_SECURE=y), the secure FW image SRAM shall always +# be restricted to the secure image SRAM partition (sram-secure-partition). +# Otherwise (if TRUSTED_EXECUTION_SECURE is not set) the whole zephyr,sram +# may be used by the image. +# +# For the non-secure version of the board, the firmware image SRAM is +# always restricted to the allocated non-secure SRAM partition. +# +# Workaround for not being able to have commas in macro arguments +DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition +DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition + +if (BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001) && \ + TRUSTED_EXECUTION_SECURE + +config FLASH_LOAD_SIZE + default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +config SRAM_SIZE + default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) + +endif + +if BOARD_NRF7002DK_NRF5340_CPUAPP_NS || BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_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 + +endif diff --git a/boards/nordic/nrf7002dk/Kconfig.nrf7002dk b/boards/nordic/nrf7002dk/Kconfig.nrf7002dk index 61b9e818f367..91f52ee6f08c 100644 --- a/boards/nordic/nrf7002dk/Kconfig.nrf7002dk +++ b/boards/nordic/nrf7002dk/Kconfig.nrf7002dk @@ -4,4 +4,6 @@ config BOARD_NRF7002DK select SOC_NRF5340_CPUNET_QKAA if BOARD_NRF7002DK_NRF5340_CPUNET select SOC_NRF5340_CPUAPP_QKAA if BOARD_NRF7002DK_NRF5340_CPUAPP || \ - BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS diff --git a/boards/nordic/nrf7002dk/board.cmake b/boards/nordic/nrf7002dk/board.cmake index f85bbc86f485..11a27910eebc 100644 --- a/boards/nordic/nrf7002dk/board.cmake +++ b/boards/nordic/nrf7002dk/board.cmake @@ -1,10 +1,24 @@ # Copyright (c) 2024 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001) +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) + set(TFM_PUBLIC_KEY_FORMAT "full") +endif() + +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) board_runner_args(nrfutil "--ext-mem-config-file=${BOARD_DIR}/support/nrf7002dk_spi_nrfutil_config.json") board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000") -elseif(CONFIG_BOARD_NRF7002DK_NRF5340_CPUNET) +endif() + +if(CONFIG_TFM_FLASH_MERGED_BINARY) + set_property(TARGET runners_yaml_props_target PROPERTY hex_file "${CMAKE_BINARY_DIR}/zephyr/tfm_merged.hex") +endif() + +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUNET) board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000") endif() diff --git a/boards/nordic/nrf7002dk/board.yml b/boards/nordic/nrf7002dk/board.yml index 4f41341e4423..39db5dcfa3a7 100644 --- a/boards/nordic/nrf7002dk/board.yml +++ b/boards/nordic/nrf7002dk/board.yml @@ -5,5 +5,9 @@ board: socs: - name: nrf5340 variants: + - name: ns + cpucluster: cpuapp - name: nrf7001 cpucluster: cpuapp + variants: + - name: ns diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts new file mode 100644 index 000000000000..5ff28accf3fc --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf5340_cpuapp_common.dtsi" + +/ { + model = "Nordic NRF5340 DK NRF5340 Application"; + compatible = "nordic,nrf5340-dk-nrf5340-cpuapp"; + + chosen { + zephyr,sram = &sram0_ns; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_ns_partition; + zephyr,entropy = &psa_rng; + zephyr,wifi = &wlan0; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; +}; + +&qspi { + nrf70: nrf7001@1 { + compatible = "nordic,nrf7001-qspi"; + status = "okay"; + reg = <1>; + qspi-frequency = <24000000>; + qspi-quad-mode; + + #include "nrf70_common.dtsi" + }; +}; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml new file mode 100644 index 000000000000..165759691260 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml @@ -0,0 +1,19 @@ +identifier: nrf7002dk/nrf5340/cpuapp/nrf7001/ns +name: NRF7002-DK-NRF7001-NRF5340-application-MCU-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 192 +flash: 192 +supported: + - gpio + - i2c + - pwm + - watchdog + - usbd + - usb_device + - netif:openthread +vendor: nordic diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig new file mode 100644 index 000000000000..2c435653140a --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig @@ -0,0 +1,24 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts new file mode 100644 index 000000000000..0deb8ccc1bf5 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf5340_cpuapp_common.dtsi" + +/ { + model = "Nordic NRF5340 DK NRF5340 Application"; + compatible = "nordic,nrf5340-dk-nrf5340-cpuapp"; + + chosen { + zephyr,sram = &sram0_ns_app; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_ns_partition; + zephyr,entropy = &psa_rng; + zephyr,wifi = &wlan0; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; +}; + +&qspi { + nrf70: nrf7002@1 { + compatible = "nordic,nrf7002-qspi"; + status = "okay"; + reg = <1>; + qspi-frequency = <24000000>; + qspi-quad-mode; + + #include "nrf70_common.dtsi" + #include "nrf70_common_5g.dtsi" + }; +}; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml new file mode 100644 index 000000000000..ea43785b4559 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml @@ -0,0 +1,19 @@ +identifier: nrf7002dk/nrf5340/cpuapp/ns +name: NRF7002-DK-NRF5340-application-MCU-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 192 +flash: 192 +supported: + - gpio + - i2c + - pwm + - watchdog + - usbd + - usb_device + - netif:openthread +vendor: nordic diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig new file mode 100644 index 000000000000..1886b926bfd5 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y diff --git a/boards/nordic/nrf9131ek/Kconfig.defconfig b/boards/nordic/nrf9131ek/Kconfig.defconfig index b63e7ef8d34c..8e0e1d02d1d1 100644 --- a/boards/nordic/nrf9131ek/Kconfig.defconfig +++ b/boards/nordic/nrf9131ek/Kconfig.defconfig @@ -5,6 +5,21 @@ if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS +# 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- diff --git a/boards/nordic/nrf9131ek/nrf9131ek_nrf9131_ns_defconfig b/boards/nordic/nrf9131ek/nrf9131ek_nrf9131_ns_defconfig index 5690c239b7ba..d15d371416bc 100644 --- a/boards/nordic/nrf9131ek/nrf9131ek_nrf9131_ns_defconfig +++ b/boards/nordic/nrf9131ek/nrf9131ek_nrf9131_ns_defconfig @@ -26,4 +26,3 @@ CONFIG_UART_CONSOLE=y CONFIG_I2C=y CONFIG_REGULATOR=y CONFIG_SENSOR=y -CONFIG_NPM1300_CHARGER=y diff --git a/boards/nordic/nrf9280pdk/Kconfig.defconfig b/boards/nordic/nrf9280pdk/Kconfig.defconfig index d1252a0a3a2e..ae7cb48cbc3b 100644 --- a/boards/nordic/nrf9280pdk/Kconfig.defconfig +++ b/boards/nordic/nrf9280pdk/Kconfig.defconfig @@ -19,3 +19,13 @@ config ASSERT default n if ZTEST endif # BOARD_NRF9280PDK_NRF9280_CPUPPR + +if BOARD_NRF9280PDK_NRF9280_CPUAPP_IRON + +config ROM_START_OFFSET + default 0x800 if BOOTLOADER_MCUBOOT + +config FLASH_LOAD_OFFSET + default $(dt_nodelabel_reg_addr_hex,cpuapp_boot_partition) if !USE_DT_CODE_PARTITION + +endif # BOARD_NRF9280PDK_NRF9280_CPUAPP_IRON diff --git a/boards/nordic/nrf9280pdk/Kconfig.nrf9280pdk b/boards/nordic/nrf9280pdk/Kconfig.nrf9280pdk index 54865a1b235e..d66fe31da884 100644 --- a/boards/nordic/nrf9280pdk/Kconfig.nrf9280pdk +++ b/boards/nordic/nrf9280pdk/Kconfig.nrf9280pdk @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_NRF9280PDK - select SOC_NRF9280_CPUAPP if BOARD_NRF9280PDK_NRF9280_CPUAPP + select SOC_NRF9280_CPUAPP if (BOARD_NRF9280PDK_NRF9280_CPUAPP || \ + BOARD_NRF9280PDK_NRF9280_CPUAPP_IRON) select SOC_NRF9280_CPURAD if BOARD_NRF9280PDK_NRF9280_CPURAD - select SOC_NRF9280_CPUPPR if BOARD_NRF9280PDK_NRF9280_CPUPPR || \ - BOARD_NRF9280PDK_NRF9280_CPUPPR_XIP + select SOC_NRF9280_CPUPPR if (BOARD_NRF9280PDK_NRF9280_CPUPPR || \ + BOARD_NRF9280PDK_NRF9280_CPUPPR_XIP) + select SOC_NRF9280_IRON if BOARD_NRF9280PDK_NRF9280_CPUAPP_IRON diff --git a/boards/nordic/nrf9280pdk/board.yml b/boards/nordic/nrf9280pdk/board.yml index 963eae59ba0f..2cce133d95c3 100644 --- a/boards/nordic/nrf9280pdk/board.yml +++ b/boards/nordic/nrf9280pdk/board.yml @@ -7,3 +7,5 @@ board: variants: - name: xip cpucluster: cpuppr + - name: iron + cpucluster: cpuapp diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf_iron.dtsi b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-ipc_conf_iron.dtsi similarity index 100% rename from boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf_iron.dtsi rename to boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-ipc_conf_iron.dtsi diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map_iron.dtsi b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map_iron.dtsi new file mode 100644 index 000000000000..aa95021d887c --- /dev/null +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map_iron.dtsi @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* This file is to be merged with the original memory_map.dtsi in the future. + * The following nodes will be replaced: + */ +/delete-node/ &cpuapp_cpusys_ipc_shm; +/delete-node/ &cpusec_cpuapp_ipc_shm; +/delete-node/ &cpusys_cpuapp_ipc_shm; +/delete-node/ &cpuapp_rw_partitions; +/delete-node/ &cpuapp_rx_partitions; +/delete-node/ &cpurad_rx_partitions; + +/ { + reserved-memory { + cpuapp_cpusys_ipc_shm: memory@2f88f600 { + reg = <0x2f88f600 0x80>; + }; + + cpusys_cpuapp_ipc_shm: memory@2f88f680 { + reg = <0x2f88f680 0x80>; + }; + + cpusec_cpuapp_ipc_shm: memory@2f88fb80 { + reg = <0x2f88fb80 0x80>; + }; + + cpuapp_ironside_se_event_report: memory@2f88fc00 { + reg = <0x2f88fc00 0x100>; + }; + + cpuapp_ironside_se_boot_report: memory@2f88fd00 { + reg = <0x2f88fd00 0x200>; + }; + }; +}; + +&mram1x { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cpuapp_boot_partition: partition@312000 { + reg = <0x312000 DT_SIZE_K(64)>; + }; + + cpuapp_slot0_partition: partition@322000 { + reg = <0x322000 DT_SIZE_K(336)>; + }; + + cpuapp_slot1_partition: partition@376000 { + reg = <0x376000 DT_SIZE_K(440)>; + }; + + cpuppr_code_partition: partition@3E4000 { + reg = <0x3E4000 DT_SIZE_K(64)>; + }; + + cpuflpr_code_partition: partition@3F4000 { + reg = <0x3F4000 DT_SIZE_K(48)>; + }; + + cpurad_slot0_partition: partition@400000 { + reg = <0x400000 DT_SIZE_K(336)>; + }; + + cpurad_slot1_partition: partition@454000 { + reg = <0x454000 DT_SIZE_K(336)>; + }; + + storage_partition: partition@600000 { + reg = <0x600000 DT_SIZE_K(40)>; + }; + }; +}; diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts index f4cce12f4b1a..4a99911fa21a 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts @@ -27,6 +27,7 @@ zephyr,ieee802154 = &cpuapp_ieee802154; zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &prng; }; aliases { @@ -108,6 +109,11 @@ pwms = <&pwm130 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; }; }; + + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; + }; }; &cpuapp_ram0x_region { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron.dts b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.dts similarity index 75% rename from boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron.dts rename to boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.dts index d455e200b0b9..a3ca908f59de 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron.dts +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.dts @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "nrf54h20dk_nrf54h20_cpuapp.dts" -#include "nrf54h20dk_nrf54h20-ipc_conf_iron.dtsi" -#include "nrf54h20dk_nrf54h20-memory_map_iron.dtsi" +#include "nrf9280pdk_nrf9280_cpuapp.dts" +#include "nrf9280pdk_nrf9280-ipc_conf_iron.dtsi" +#include "nrf9280pdk_nrf9280-memory_map_iron.dtsi" /delete-node/ &cpusec_cpurad_ipc; @@ -17,6 +17,10 @@ }; }; +&cpusec_bellboard { + status = "okay"; +}; + &cpusec_cpuapp_ipc { mbox-names = "tx", "rx"; status = "okay"; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron_0_9_0.yaml b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.yaml similarity index 60% rename from boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron_0_9_0.yaml rename to boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.yaml index eefca56fe0c3..029f133993bf 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron_0_9_0.yaml +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron.yaml @@ -1,8 +1,8 @@ # Copyright (c) 2025 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -identifier: nrf54h20dk/nrf54h20/cpuapp/iron -name: nRF54H20-DK-nRF54H20-Application (IRONside compatible) (revision 0.9.0) +identifier: nrf9280pdk/nrf9280/cpuapp/iron +name: nRF9280-DK-nRF9280-Application type: mcu arch: arm toolchain: @@ -10,16 +10,14 @@ toolchain: - xtools - zephyr sysbuild: true -ram: 256 -flash: 480 +ram: 512 +flash: 1024 supported: - adc - - can - counter - gpio - i2c - pwm - - retained_mem - spi - watchdog - usbd diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron_defconfig b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron_defconfig similarity index 100% rename from boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_iron_defconfig rename to boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp_iron_defconfig diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts index 5efa7dbd471c..d6c03bc4a514 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts @@ -28,6 +28,11 @@ zephyr,ieee802154 = &cpurad_ieee802154; zephyr,bt-hci-ipc = &ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &prng; + }; + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; }; aliases { diff --git a/boards/nordic/thingy53/Kconfig.defconfig b/boards/nordic/thingy53/Kconfig.defconfig index d149d360f859..f024144451ab 100644 --- a/boards/nordic/thingy53/Kconfig.defconfig +++ b/boards/nordic/thingy53/Kconfig.defconfig @@ -5,6 +5,12 @@ if BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS +config BOOTLOADER_MCUBOOT + default y if !MCUBOOT + +config BOARD_ENABLE_CPUNET + default y if !MCUBOOT + # Code Partition: # # For the secure version of the board the firmware is linked at the beginning @@ -81,6 +87,16 @@ endif # !TRUSTED_EXECUTION_SECURE source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig" +# By default, a USB CDC ACM instance is already enabled in the board's DTS. +# It is not necessary for nRF Connect SDK to add another instance if MCUBoot +# bootloader is built as a child image. +config MCUBOOT_USB_SUPPORT + bool + default n + +config NORDIC_QSPI_NOR + default y + endif # BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS if BOARD_THINGY53_NRF5340_CPUNET diff --git a/boards/nordic/thingy53/Kconfig.sysbuild b/boards/nordic/thingy53/Kconfig.sysbuild new file mode 100644 index 000000000000..df489c1dd546 --- /dev/null +++ b/boards/nordic/thingy53/Kconfig.sysbuild @@ -0,0 +1,29 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y if SECURE_BOOT_NETCORE + +config NRF_DEFAULT_EMPTY + default y if SECURE_BOOT_NETCORE + +config MCUBOOT_USE_ALL_AVAILABLE_RAM + default y if BOARD_THINGY53_NRF5340_CPUAPP_NS && BOOTLOADER_MCUBOOT + +endif # BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y if BOOTLOADER_MCUBOOT diff --git a/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml new file mode 100644 index 000000000000..7a48d51ec334 --- /dev/null +++ b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml @@ -0,0 +1,55 @@ +app: + address: 0x10200 + region: flash_primary + size: 0xdfe00 +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml new file mode 100644 index 000000000000..70ffe6d9c124 --- /dev/null +++ b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml @@ -0,0 +1,73 @@ +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +tfm_secure: + address: 0x10000 + size: 0xc000 + span: [mcuboot_pad, tfm] +tfm_nonsecure: + address: 0x1c000 + size: 0xd4000 + span: [app] +tfm: + address: 0x10200 + region: flash_primary + size: 0xbe00 +app: + address: 0x1c000 + region: flash_primary + size: 0xd4000 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - tfm + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - tfm + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +nonsecure_storage: + address: 0xf0000 + size: 0x10000 + span: [settings_storage] +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi b/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi index 3f2f2d5f0606..900b9d06e658 100644 --- a/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi +++ b/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi @@ -13,6 +13,7 @@ zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; zephyr,ieee802154 = &ieee802154; + nordic,pm-ext-flash = &mx25r64; }; buttons { diff --git a/boards/shields/npm1300_ek/npm1300_ek.overlay b/boards/shields/npm1300_ek/npm1300_ek.overlay index 592aa55f1243..d0a9b0eda228 100644 --- a/boards/shields/npm1300_ek/npm1300_ek.overlay +++ b/boards/shields/npm1300_ek/npm1300_ek.overlay @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include &arduino_i2c { diff --git a/cmake/compiler/compiler_flags_template.cmake b/cmake/compiler/compiler_flags_template.cmake index 34acddfa3624..6050c46d3854 100644 --- a/cmake/compiler/compiler_flags_template.cmake +++ b/cmake/compiler/compiler_flags_template.cmake @@ -76,6 +76,9 @@ set_compiler_property(PROPERTY no_strict_aliasing) set_property(TARGET compiler PROPERTY warnings_as_errors) set_property(TARGET asm PROPERTY warnings_as_errors) +set_property(TARGET compiler PROPERTY no_deprecation_warning) +set_property(TARGET asm PROPERTY no_deprecation_warning) + # Flag for disabling exceptions in C++ set_property(TARGET compiler-cpp PROPERTY no_exceptions) diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 9d4989fea47e..c3b8c113d42d 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -153,6 +153,10 @@ set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing) set_property(TARGET compiler PROPERTY warnings_as_errors -Werror) set_property(TARGET asm PROPERTY warnings_as_errors -Werror -Wa,--fatal-warnings) +# Deprecation warning +set_property(TARGET compiler PROPERTY no_deprecation_warning -Wno-deprecated-declarations) +set_property(TARGET asm PROPERTY no_deprecation_warning -Wno-deprecated-declarations) + # Disable exceptions flag in C++ set_property(TARGET compiler-cpp PROPERTY no_exceptions "-fno-exceptions") diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 733accda7820..cee3dd011bc5 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,6 +80,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index b6b96525e706..bdea4f1ec922 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,6 +52,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index c6319611c8c3..5c8fa184b208 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -256,3 +256,7 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() + +if(ZEPHYR_NRF_MODULE_DIR) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) +endif() diff --git a/doc/build/kconfig/preprocessor-functions.rst b/doc/build/kconfig/preprocessor-functions.rst index 9de5110bfdbc..e3ed5f406366 100644 --- a/doc/build/kconfig/preprocessor-functions.rst +++ b/doc/build/kconfig/preprocessor-functions.rst @@ -81,18 +81,29 @@ Integer functions The functions listed below can be used to do arithmetic operations on integer variables, such as addition, subtraction and more. +Functions with and without the ``_hex`` suffix in their names +return hexadecimal and decimal values respectively. .. code-block:: none $(add,[,value]...) + $(add_hex,[,value]...) $(dec,[,value]...) + $(dec_hex,[,value]...) $(div,[,value]...) + $(div_hex,[,value]...) $(inc,[,value]...) + $(inc_hex,[,value]...) $(max,[,value]...) + $(max_hex,[,value]...) $(min,[,value]...) + $(min_hex,[,value]...) $(mod,[,value]...) + $(mod_hex,[,value]...) $(mul,[,value]...) + $(mul_hex,[,value]...) $(sub,[,value]...) + $(sub_hex,[,value]...) String functions diff --git a/doc/build/kconfig/setting.rst b/doc/build/kconfig/setting.rst index ad62d86eb3d4..6fe1feaed7d3 100644 --- a/doc/build/kconfig/setting.rst +++ b/doc/build/kconfig/setting.rst @@ -7,8 +7,7 @@ The :ref:`menuconfig and guiconfig interfaces ` can be used to test out configurations during application development. This page explains how to make settings permanent. -All Kconfig options can be searched in the :ref:`Kconfig search page -`. +All Kconfig options can be searched in the Kconfig search page. .. note:: @@ -115,8 +114,7 @@ Assignments in configuration files are only respected if the dependencies for the symbol are satisfied. A warning is printed otherwise. To figure out what the dependencies of a symbol are, use one of the :ref:`interactive configuration interfaces ` (you can jump directly to a symbol with -:kbd:`/`), or look up the symbol in the :ref:`Kconfig search page -`. +:kbd:`/`), or look up the symbol in the Kconfig search page. .. _initial-conf: diff --git a/doc/connectivity/networking/api/mqtt.rst b/doc/connectivity/networking/api/mqtt.rst index 9a167ffe665a..3d222d53816a 100644 --- a/doc/connectivity/networking/api/mqtt.rst +++ b/doc/connectivity/networking/api/mqtt.rst @@ -150,6 +150,7 @@ additional configuration information: tls_config->sec_tag_list = m_sec_tags; tls_config->sec_tag_count = ARRAY_SIZE(m_sec_tags); tls_config->hostname = MQTT_BROKER_HOSTNAME; + tls_config->set_native_tls = true; In this sample code, the ``m_sec_tags`` array holds a list of tags, referencing TLS credentials that the MQTT library should use for authentication. We do not specify @@ -162,6 +163,8 @@ Note, that TLS credentials referenced by the ``m_sec_tags`` array must be registered in the system first. For more information on how to do that, refer to :ref:`secure sockets documentation `. +Finally, ``set_native_tls`` can be optionally set to enable native TLS support instead of offloading TLS operations to the modem. + An example of how to use TLS with MQTT is also present in :zephyr:code-sample:`mqtt-publisher` sample application. diff --git a/doc/develop/application/index.rst b/doc/develop/application/index.rst index 7dc4539677ea..42d53040bd29 100644 --- a/doc/develop/application/index.rst +++ b/doc/develop/application/index.rst @@ -648,9 +648,8 @@ started. See :ref:`setting_configuration_values` for detailed documentation on setting Kconfig configuration values. The :ref:`initial-conf` section on the same page -explains how the initial configuration is derived. See :ref:`kconfig-search` -for a complete list of configuration options. -See :ref:`hardening` for security information related with Kconfig options. +explains how the initial configuration is derived. See :ref:`hardening` for +security information related with Kconfig options. The other pages in the :ref:`Kconfig section of the manual ` are also worth going through, especially if you planning to add new configuration diff --git a/doc/kconfig.rst b/doc/kconfig.rst deleted file mode 100644 index 1123de2adbd9..000000000000 --- a/doc/kconfig.rst +++ /dev/null @@ -1,8 +0,0 @@ -:orphan: - -.. _kconfig-search: - -Kconfig Search -============== - -.. kconfig:search:: diff --git a/doc/releases/migration-guide-4.2.rst b/doc/releases/migration-guide-4.2.rst index e643142e0ba0..faad669e379e 100644 --- a/doc/releases/migration-guide-4.2.rst +++ b/doc/releases/migration-guide-4.2.rst @@ -212,6 +212,11 @@ GPIO * ``arduino-nano-header-r3`` is renamed to :dtcompatible:`arduino-nano-header`. Because the R3 comes from the Arduino UNO R3, which has changed the connector from the former version, and is unrelated to the Arduino Nano. +* Moved file ``include/zephyr/dt-bindings/gpio/nordic-npm1300-gpio.h`` to + :zephyr_file:`include/zephyr/dt-bindings/gpio/nordic-npm13xx-gpio.h` and renamed all instances of + ``NPM1300`` to ``NPM13XX`` in the defines +* Renamed ``CONFIG_GPIO_NPM1300`` to :kconfig:option:`CONFIG_GPIO_NPM13XX`, + ``CONFIG_GPIO_NPM1300_INIT_PRIORITY`` to :kconfig:option:`CONFIG_GPIO_NPM13XX_INIT_PRIORITY` I2S === @@ -219,6 +224,30 @@ I2S * configure the MCLK signal as an output. Older driver versions used the macro * ``I2S_OPT_BIT_CLK_SLAVE`` to configure the MCLK signal direction. (:github:`88554`) +LED +=== + +* Renamed ``CONFIG_LED_NPM1300`` to :kconfig:option:`CONFIG_LED_NPM13XX` + +MFD +=== + +* Moved file ``include/zephyr/drivers/mfd/npm1300.h`` to :zephyr_file:`include/zephyr/drivers/mfd/npm13xx.h` + and renamed all instances of ``npm1300``/``NPM1300`` to ``npm13xx``/``NPM13XX`` in the enums and + function names +* Renamed ``CONFIG_MFD_NPM1300`` to :kconfig:option:`CONFIG_MFD_NPM13XX`, + ``CONFIG_MFD_NPM1300_INIT_PRIORITY`` to :kconfig:option:`CONFIG_MFD_NPM13XX_INIT_PRIORITY` + +Regulator +========= + +* Moved file ``include/zephyr/dt-bindings/regulator/npm1300.h`` to + :zephyr_file:`include/zephyr/dt-bindings/regulator/npm13xx.h` and renamed all instances of + ``NPM1300`` to ``NPM13XX`` in the defines +* Renamed ``CONFIG_REGULATOR_NPM1300`` to :kconfig:option:`CONFIG_REGULATOR_NPM13XX`, + ``CONFIG_REGULATOR_NPM1300_COMMON_INIT_PRIORITY`` to :kconfig:option:`REGULATOR_NPM13XX_COMMON_INIT_PRIORITY`, + ``CONFIG_REGULATOR_NPM1300_INIT_PRIORITY`` to :kconfig:option:`CONFIG_REGULATOR_NPM13XX_INIT_PRIORITY` + Sensors ======= @@ -255,6 +284,12 @@ Sensors * The binding file for :dtcompatible:`raspberrypi,pico-temp.yaml` has been renamed to have a name matching the compatible string. +* Moved file ``include/zephyr/drivers/sensor/npm1300_charger.h`` to + :zephyr_file:`include/zephyr/drivers/sensor/npm13xx_charger.h` and renamed all instances of + ``NPM1300`` to ``NPM13XX`` in the enums + +* Renamed ``CONFIG_NPM1300_CHARGER`` to :kconfig:option:`CONFIG_NPM13XX_CHARGER` + Serial ======= @@ -304,6 +339,11 @@ Timer reg-names = "mtime", "mtimecmp"; }; +Watchdog +======== +* Renamed ``CONFIG_WDT_NPM1300`` to :kconfig:option:`CONFIG_WDT_NPM13XX`, + ``CONFIG_WDT_NPM1300_INIT_PRIORITY`` to :kconfig:option:`CONFIG_WDT_NPM13XX_INIT_PRIORITY` + Modem ===== diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index 8d8c6a01ad30..986cca49af8f 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -54,7 +54,7 @@ static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = { [NRF_SAADC_AVDD] = NRF_SAADC_INPUT_AVDD, [NRF_SAADC_DVDD] = NRF_SAADC_INPUT_DVDD, }; -#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#elif defined(NRF54LM20A_ENGA_XXAA) static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = { [NRF_SAADC_AIN0] = NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1), [NRF_SAADC_AIN1] = NRF_PIN_PORT_TO_PIN_NUMBER(31U, 1), @@ -68,6 +68,19 @@ static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = { [NRF_SAADC_AVDD] = NRF_SAADC_INPUT_AVDD, [NRF_SAADC_DVDD] = NRF_SAADC_INPUT_DVDD, }; +#elif defined(NRF54LV10A_ENGA_XXAA) +static const uint32_t saadc_psels[NRF_SAADC_DVDD + 1] = { + [NRF_SAADC_AIN0] = NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1), + [NRF_SAADC_AIN1] = NRF_PIN_PORT_TO_PIN_NUMBER(1U, 1), + [NRF_SAADC_AIN2] = NRF_PIN_PORT_TO_PIN_NUMBER(2U, 1), + [NRF_SAADC_AIN3] = NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1), + [NRF_SAADC_AIN4] = NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1), + [NRF_SAADC_AIN5] = NRF_PIN_PORT_TO_PIN_NUMBER(10U, 1), + [NRF_SAADC_AIN6] = NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1), + [NRF_SAADC_AIN7] = NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1), + [NRF_SAADC_VDD] = NRF_SAADC_INPUT_VDD, + [NRF_SAADC_DVDD] = NRF_SAADC_INPUT_DVDD, +}; #endif #else @@ -220,7 +233,9 @@ static int adc_nrfx_channel_setup(const struct device *dev, .resistor_p = NRF_SAADC_RESISTOR_DISABLED, .resistor_n = NRF_SAADC_RESISTOR_DISABLED, #endif +#if NRF_SAADC_HAS_CH_BURST .burst = NRF_SAADC_BURST_DISABLED, +#endif }; uint8_t channel_id = channel_cfg->channel_id; uint32_t input_negative = channel_cfg->input_negative; @@ -229,6 +244,7 @@ static int adc_nrfx_channel_setup(const struct device *dev, return -EINVAL; } +#if NRF_SAADC_HAS_CH_GAIN switch (channel_cfg->gain) { #if defined(SAADC_CH_CONFIG_GAIN_Gain1_6) case ADC_GAIN_1_6: @@ -282,6 +298,9 @@ static int adc_nrfx_channel_setup(const struct device *dev, break; #endif default: +#else + if (channel_cfg->gain != ADC_GAIN_1) { +#endif /* defined(NRF_SAADC_HAS_CH_GAIN) */ LOG_ERR("Selected ADC gain is not valid"); return -EINVAL; } @@ -530,6 +549,7 @@ static int start_read(const struct device *dev, uint8_t resolution = sequence->resolution; uint8_t active_channels; uint8_t channel_id; + nrf_saadc_burst_t burst; /* Signal an error if channel selection is invalid (no channels or * a non-existing one is selected). @@ -581,10 +601,13 @@ static int start_read(const struct device *dev, * is not used (hence, the multiple channel sampling is * possible), the burst mode have to be deactivated. */ - nrf_saadc_burst_set(NRF_SAADC, channel_id, - (sequence->oversampling != 0U ? - NRF_SAADC_BURST_ENABLED : - NRF_SAADC_BURST_DISABLED)); + burst = (sequence->oversampling != 0U ? + NRF_SAADC_BURST_ENABLED : NRF_SAADC_BURST_DISABLED); +#if NRF_SAADC_HAS_CH_BURST + nrf_saadc_channel_burst_set(NRF_SAADC, channel_id, burst); +#else + nrf_saadc_burst_set(NRF_SAADC, burst); +#endif nrf_saadc_channel_pos_input_set( NRF_SAADC, channel_id, @@ -596,10 +619,12 @@ static int start_read(const struct device *dev, ); ++active_channels; } else { - nrf_saadc_burst_set( - NRF_SAADC, - channel_id, - NRF_SAADC_BURST_DISABLED); + burst = NRF_SAADC_BURST_DISABLED; +#if NRF_SAADC_HAS_CH_BURST + nrf_saadc_channel_burst_set(NRF_SAADC, channel_id, burst); +#else + nrf_saadc_burst_set(NRF_SAADC, burst); +#endif nrf_saadc_channel_pos_input_set( NRF_SAADC, channel_id, @@ -729,7 +754,9 @@ static DEVICE_API(adc, adc_nrfx_driver_api) = { #ifdef CONFIG_ADC_ASYNC .read_async = adc_nrfx_read_async, #endif -#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#if defined(NRF54LV10A_ENGA_XXAA) + .ref_internal = 1300, +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) .ref_internal = 900, #elif defined(CONFIG_NRF_PLATFORM_HALTIUM) .ref_internal = 1024, diff --git a/drivers/audio/dmic_nrfx_pdm.c b/drivers/audio/dmic_nrfx_pdm.c index 2e8d71b0a93c..b2fcb7abb868 100644 --- a/drivers/audio/dmic_nrfx_pdm.c +++ b/drivers/audio/dmic_nrfx_pdm.c @@ -30,7 +30,7 @@ struct dmic_nrfx_pdm_drv_data { const nrfx_pdm_t *pdm; #if CONFIG_CLOCK_CONTROL_NRF struct onoff_manager *clk_mgr; -#elif CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL const struct device *audiopll_dev; #endif struct onoff_client clk_cli; @@ -75,7 +75,7 @@ static int request_clock(struct dmic_nrfx_pdm_drv_data *drv_data) } #if CONFIG_CLOCK_CONTROL_NRF return onoff_request(drv_data->clk_mgr, &drv_data->clk_cli); -#elif CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL return nrf_clock_control_request(drv_data->audiopll_dev, NULL, &drv_data->clk_cli); #else return -ENOTSUP; @@ -90,7 +90,7 @@ static int release_clock(struct dmic_nrfx_pdm_drv_data *drv_data) #if CONFIG_CLOCK_CONTROL_NRF return onoff_release(drv_data->clk_mgr); -#elif CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL return nrf_clock_control_release(drv_data->audiopll_dev, NULL); #else return -ENOTSUP; @@ -673,7 +673,7 @@ static void init_clock_manager(const struct device *dev) drv_data->clk_mgr = z_nrf_clock_control_get_onoff(subsys); __ASSERT_NO_MSG(drv_data->clk_mgr != NULL); -#elif CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL struct dmic_nrfx_pdm_drv_data *drv_data = dev->data; drv_data->audiopll_dev = DEVICE_DT_GET(DT_NODELABEL(audiopll)); diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index a1680af6583d..e64a33f663ce 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -12,7 +12,7 @@ menuconfig BT_DRIVERS bool "Bluetooth drivers" default y - depends on BT + depends on BT && BT_HCI if BT_DRIVERS diff --git a/drivers/cache/cache_nrf.c b/drivers/cache/cache_nrf.c index 3cf798978749..6a9a4b6b49e4 100644 --- a/drivers/cache/cache_nrf.c +++ b/drivers/cache/cache_nrf.c @@ -94,6 +94,7 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op) return 0; } +#if NRF_CACHE_HAS_LINEADDR static inline void _cache_line(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, uintptr_t line_addr) { do { @@ -160,7 +161,7 @@ static inline int _cache_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, v size_t size, bool is_range) { /* Check if the cache is enabled */ - if (!(cache->ENABLE & CACHE_ENABLE_ENABLE_Enabled)) { + if (!nrf_cache_enable_check(cache)) { return -EAGAIN; } @@ -175,6 +176,16 @@ static inline int _cache_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, v return _cache_range(cache, op, addr, size); } +#else +static inline int _cache_all_checks(NRF_CACHE_Type *cache, enum k_nrf_cache_op op) +{ + /* Check if the cache is enabled */ + if (!nrf_cache_enable_check(cache)) { + return -EAGAIN; + } + return _cache_all(cache, op); +} +#endif /* NRF_CACHE_HAS_LINEADDR */ #if defined(NRF_DCACHE) && NRF_CACHE_HAS_TASKS @@ -296,7 +307,11 @@ void cache_instr_disable(void) int cache_instr_flush_all(void) { #if NRF_CACHE_HAS_TASK_CLEAN +#if NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN, NULL, 0, false); +#else + return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN); +#endif #else return -ENOTSUP; #endif @@ -304,13 +319,21 @@ int cache_instr_flush_all(void) int cache_instr_invd_all(void) { +#if NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_INVD, NULL, 0, false); +#else + return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_INVD); +#endif } int cache_instr_flush_and_invd_all(void) { #if NRF_CACHE_HAS_TASK_FLUSH +#if NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH, NULL, 0, false); +#else + return _cache_all_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH); +#endif #else return -ENOTSUP; #endif @@ -318,7 +341,7 @@ int cache_instr_flush_and_invd_all(void) int cache_instr_flush_range(void *addr, size_t size) { -#if NRF_CACHE_HAS_TASK_CLEAN +#if NRF_CACHE_HAS_TASK_CLEAN && NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_CLEAN, addr, size, true); #else return -ENOTSUP; @@ -327,12 +350,16 @@ int cache_instr_flush_range(void *addr, size_t size) int cache_instr_invd_range(void *addr, size_t size) { +#if NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_INVD, addr, size, true); +#else + return -ENOTSUP; +#endif } int cache_instr_flush_and_invd_range(void *addr, size_t size) { -#if NRF_CACHE_HAS_TASK_FLUSH +#if NRF_CACHE_HAS_TASK_FLUSH && NRF_CACHE_HAS_LINEADDR return _cache_checks(NRF_ICACHE, K_NRF_CACHE_FLUSH, addr, size, true); #else return -ENOTSUP; diff --git a/drivers/can/can_nrf.c b/drivers/can/can_nrf.c index c538291ecb40..f8c037835a83 100644 --- a/drivers/can/can_nrf.c +++ b/drivers/can/can_nrf.c @@ -171,7 +171,7 @@ static int can_nrf_init(const struct device *dev) return ret; } - ret = clock_control_on(config->auxpll, NULL); + ret = nrf_clock_control_request_sync(config->auxpll, NULL, K_FOREVER); if (ret < 0) { return ret; } diff --git a/drivers/clock_control/CMakeLists.txt b/drivers/clock_control/CMakeLists.txt index 886c92b63578..59e7e3e30260 100644 --- a/drivers/clock_control/CMakeLists.txt +++ b/drivers/clock_control/CMakeLists.txt @@ -45,18 +45,18 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RENESAS_RZ_CPG clock_cont zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_AMBIQ clock_control_ambiq.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_PWM clock_control_pwm.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RPI_PICO clock_control_rpi_pico.c) -zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL clock_control_nrf2_global_hsfll.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL clock_control_nrf_hsfll_global.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RTS5912_SCCON clock_control_rts5912_sccon.c) -zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL clock_control_nrf2_audiopll.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL clock_control_nrfs_audiopll.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_IT51XXX clock_control_it51xxx.c) - -if(CONFIG_CLOCK_CONTROL_NRF2) - zephyr_library_sources(clock_control_nrf2_common.c) - zephyr_library_sources(clock_control_nrf2_fll16m.c) - zephyr_library_sources(clock_control_nrf2_hfxo.c) - zephyr_library_sources(clock_control_nrf2_hsfll.c) - zephyr_library_sources(clock_control_nrf2_lfclk.c) -endif() +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF2_COMMON clock_control_nrf2_common.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_FLL16M clock_control_nrf_fll16m.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF54H_HFXO clock_control_nrf54h_hfxo.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL clock_control_nrf_hsfll_local.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL clock_control_nrf_iron_hsfll_local.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_LFCLK clock_control_nrf_lfclk.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_AUXPLL clock_control_nrf_auxpll.c) +zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_BOUFFALOLAB_BL60X clock_control_bl60x.c) if(CONFIG_CLOCK_CONTROL_RENESAS_RZA2M_CPG) zephyr_library_sources(clock_control_renesas_rza2m_cpg.c) @@ -118,5 +118,4 @@ endif() zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_AST10X0 clock_control_ast10x0.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_MAX32 clock_control_max32.c) -zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_AUXPLL clock_control_nrf_auxpll.c) zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_WCH_RCC clock_control_wch_rcc.c) diff --git a/drivers/clock_control/Kconfig b/drivers/clock_control/Kconfig index f528aa2dad32..05a2a7fb8fa6 100644 --- a/drivers/clock_control/Kconfig +++ b/drivers/clock_control/Kconfig @@ -32,6 +32,8 @@ source "drivers/clock_control/Kconfig.stm32" source "drivers/clock_control/Kconfig.beetle" +source "drivers/clock_control/Kconfig.bflb" + source "drivers/clock_control/Kconfig.fixed" source "drivers/clock_control/Kconfig.lpc11u6x" @@ -102,8 +104,6 @@ source "drivers/clock_control/Kconfig.pwm" source "drivers/clock_control/Kconfig.rpi_pico" -source "drivers/clock_control/Kconfig.nrf_auxpll" - source "drivers/clock_control/Kconfig.arm_scmi" source "drivers/clock_control/Kconfig.silabs" diff --git a/drivers/clock_control/Kconfig.bflb b/drivers/clock_control/Kconfig.bflb new file mode 100644 index 000000000000..dd89dbdf4f80 --- /dev/null +++ b/drivers/clock_control/Kconfig.bflb @@ -0,0 +1,7 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +config CLOCK_CONTROL_BOUFFALOLAB_BL60X + bool "Bouffalolab BL60x Clock Control" + default y + depends on DT_HAS_BFLB_BL60X_CLOCK_CONTROLLER_ENABLED diff --git a/drivers/clock_control/Kconfig.nrf b/drivers/clock_control/Kconfig.nrf index 07ee365603b6..53f03cf6bcdc 100644 --- a/drivers/clock_control/Kconfig.nrf +++ b/drivers/clock_control/Kconfig.nrf @@ -201,43 +201,25 @@ config CLOCK_CONTROL_NRF_ACCURACY endif # CLOCK_CONTROL_NRF -config CLOCK_CONTROL_NRF2 - bool "nRF clock control support" - default y - depends on SOC_SERIES_NRF54HX && !RISCV_CORE_NORDIC_VPR +config CLOCK_CONTROL_NRF2_COMMON + bool "NRF2 clock control common framework" select ONOFF - select NRFS if HAS_NRFS - help - Support for nRF clock control devices. - -if CLOCK_CONTROL_NRF2 - -config CLOCK_CONTROL_NRF2_HSFLL_REQ_LOW_FREQ - bool "Local domain scale down after init" - default y if NRFS_DVFS_LOCAL_DOMAIN - help - Request the lowest operating point after DVFS initialization. - -config CLOCK_CONTROL_NRF2_NRFS_DVFS_TIMEOUT_MS - int "Timeout waiting for nrfs dvfs service callback in milliseconds" - default 2000 -config CLOCK_CONTROL_NRF2_NRFS_CLOCK_TIMEOUT_MS - int "Timeout waiting for nrfs clock service callback in milliseconds" - default 1000 - -config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL +config CLOCK_CONTROL_NRF_HSFLL_GLOBAL bool "Clock control for global HSFLL" - depends on NRFS_GDFS_SERVICE_ENABLED + depends on DT_HAS_NORDIC_NRF_HSFLL_GLOBAL_ENABLED + select NRFS + select NRFS_GDFS_SERVICE_ENABLED + select CLOCK_CONTROL_NRF2_COMMON default y -if CLOCK_CONTROL_NRF2_GLOBAL_HSFLL +if CLOCK_CONTROL_NRF_HSFLL_GLOBAL -config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_TIMEOUT_MS +config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_TIMEOUT_MS int "Frequency request timeout in milliseconds" default 10000 -config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_REQ_LOW_FREQ +config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_REQ_LOW_FREQ bool "Request LOW frequency on init" default y help @@ -251,18 +233,93 @@ config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_REQ_LOW_FREQ unnecessary HIGH -> LOW -> HIGH cycle given some module will request a HIGH frequency on init anyway. -config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY +config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY int "Init priority of global HSFLL device driver" default 52 help Must be higher than NRFS backend -endif # CLOCK_CONTROL_NRF2_GLOBAL_HSFLL +endif # CLOCK_CONTROL_NRF_HSFLL_GLOBAL -config CLOCK_CONTROL_NRF2_AUDIOPLL +config CLOCK_CONTROL_NRFS_AUDIOPLL bool "NRFS AudioPLL driver support" depends on DT_HAS_NORDIC_NRFS_AUDIOPLL_ENABLED - depends on NRFS_AUDIOPLL_SERVICE_ENABLED + select NRFS + select NRFS_AUDIOPLL_SERVICE_ENABLED + select CLOCK_CONTROL_NRF2_COMMON + default y + +config CLOCK_CONTROL_NRF_FLL16M + bool "NRF FLL16M driver support" + depends on DT_HAS_NORDIC_NRF_FLL16M_ENABLED + select CLOCK_CONTROL_NRF2_COMMON + default y + +config CLOCK_CONTROL_NRF54H_HFXO + bool "NRF54H HFXO driver support" + depends on DT_HAS_NORDIC_NRF54H_HFXO_ENABLED + select CLOCK_CONTROL_NRF2_COMMON + default y + +config CLOCK_CONTROL_NRF_HSFLL_LOCAL + bool "NRF HSFLL LOCAL driver support" + depends on DT_HAS_NORDIC_NRF_HSFLL_LOCAL_ENABLED + select NRFS + select NRFS_DVFS_LOCAL_DOMAIN + select CLOCK_CONTROL_NRF2_COMMON + default y + +if CLOCK_CONTROL_NRF_HSFLL_LOCAL + +config CLOCK_CONTROL_NRF_HSFLL_LOCAL_REQ_LOW_FREQ + bool "Local domain scale down after init" + help + Request the lowest operating point after DVFS initialization. + +config CLOCK_CONTROL_NRF_HSFLL_LOCAL_NRFS_DVFS_TIMEOUT_MS + int "Timeout waiting for nrfs dvfs service callback in milliseconds" + default 2000 + +endif # CLOCK_CONTROL_NRF_HSFLL_LOCAL + +config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL + bool "NRF IronSide HSFLL LOCAL driver support" + depends on DT_HAS_NORDIC_NRF_IRON_HSFLL_LOCAL_ENABLED + select NRF_IRONSIDE_DVFS_SERVICE + select CLOCK_CONTROL_NRF2_COMMON default y -endif # CLOCK_CONTROL_NRF2 +if CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL + +config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_REQ_LOW_FREQ + bool "Local domain scale down after init" + help + Request the lowest operating point after DVFS initialization. + +config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_DVFS_TIMEOUT_MS + int "Timeout waiting for dvfs request to complete" + default 2000 + +endif # CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL + +config CLOCK_CONTROL_NRF_LFCLK + bool "NRF LFCLK driver support" + depends on DT_HAS_NORDIC_NRF_LFCLK_ENABLED + select NRFS + select NRFS_CLOCK_SERVICE_ENABLED + select CLOCK_CONTROL_NRF2_COMMON + default y + +if CLOCK_CONTROL_NRF_LFCLK + +config CLOCK_CONTROL_NRF_LFCLK_CLOCK_TIMEOUT_MS + int "Timeout waiting for nrfs clock service callback in milliseconds" + default 1000 + +endif # CLOCK_CONTROL_NRF_LFCLK + +config CLOCK_CONTROL_NRF_AUXPLL + bool "nRF Auxiliary PLL driver" + default y + depends on DT_HAS_NORDIC_NRF_AUXPLL_ENABLED + select CLOCK_CONTROL_NRF2_COMMON diff --git a/drivers/clock_control/Kconfig.nrf_auxpll b/drivers/clock_control/Kconfig.nrf_auxpll deleted file mode 100644 index 413452c1ac49..000000000000 --- a/drivers/clock_control/Kconfig.nrf_auxpll +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config CLOCK_CONTROL_NRF_AUXPLL - bool "nRF Auxiliary PLL driver" - default y - depends on DT_HAS_NORDIC_NRF_AUXPLL_ENABLED - help - Driver for nRF Auxiliary PLL. diff --git a/drivers/clock_control/clock_control_bl60x.c b/drivers/clock_control/clock_control_bl60x.c new file mode 100644 index 000000000000..eb81b04eec88 --- /dev/null +++ b/drivers/clock_control/clock_control_bl60x.c @@ -0,0 +1,913 @@ +/* + * Copyright (c) 2025 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT bflb_bl60x_clock_controller + +#include +#include +#include +#include +#include +#include +LOG_MODULE_REGISTER(clock_control_bl60x, CONFIG_CLOCK_CONTROL_LOG_LEVEL); + +#include +#include +#include +#include +#include +#include +#include + +#define CLK_SRC_IS(clk, src) \ + DT_SAME_NODE(DT_CLOCKS_CTLR_BY_IDX(DT_INST_CLOCKS_CTLR_BY_NAME(0, clk), 0), \ + DT_INST_CLOCKS_CTLR_BY_NAME(0, src)) + +#define CLOCK_TIMEOUT 1024 +#define EFUSE_RC32M_TRIM_OFFSET 0x0C +#define EFUSE_RC32M_TRIM_EN_POS 19 +#define EFUSE_RC32M_TRIM_PARITY_POS 18 +#define EFUSE_RC32M_TRIM_POS 10 +#define EFUSE_RC32M_TRIM_MSK 0x3FC00 + +#define CRYSTAL_ID_FREQ_32000000 0 +#define CRYSTAL_ID_FREQ_24000000 1 +#define CRYSTAL_ID_FREQ_38400000 2 +#define CRYSTAL_ID_FREQ_40000000 3 +#define CRYSTAL_ID_FREQ_26000000 4 + +#define CRYSTAL_FREQ_TO_ID(freq) CONCAT(CRYSTAL_ID_FREQ_, freq) + +enum bl60x_clkid { + bl60x_clkid_clk_root = BL60X_CLKID_CLK_ROOT, + bl60x_clkid_clk_rc32m = BL60X_CLKID_CLK_RC32M, + bl60x_clkid_clk_crystal = BL60X_CLKID_CLK_CRYSTAL, + bl60x_clkid_clk_pll = BL60X_CLKID_CLK_PLL, + bl60x_clkid_clk_bclk = BL60X_CLKID_CLK_BCLK, +}; + +struct clock_control_bl60x_pll_config { + enum bl60x_clkid source; + bool overclock; +}; + +struct clock_control_bl60x_root_config { + enum bl60x_clkid source; + uint8_t pll_select; + uint8_t divider; +}; + +struct clock_control_bl60x_bclk_config { + uint8_t divider; +}; + +struct clock_control_bl60x_config { + uint32_t crystal_id; +}; + +struct clock_control_bl60x_data { + bool crystal_enabled; + bool pll_enabled; + struct clock_control_bl60x_pll_config pll; + struct clock_control_bl60x_root_config root; + struct clock_control_bl60x_bclk_config bclk; +}; + +const static uint32_t clock_control_bl60x_crystal_SDMIN_table[5] = { + /* 32M */ + 0x3C0000, + /* 24M */ + 0x500000, + /* 38.4M */ + 0x320000, + /* 40M */ + 0x300000, + /* 26M */ + 0x49D39D, +}; + +static inline void clock_control_bl60x_clock_settle(void) +{ + __asm__ volatile(".rept 15 ; nop ; .endr"); +} + +/* 32 Mhz Oscillator: 0 + * crystal: 1 + * PLL and 32M: 2 + * PLL and crystal: 3 + */ +static void clock_control_bl60x_set_root_clock(uint32_t clock) +{ + uint32_t tmp; + + /* invalid value, fallback to internal 32M */ + if (clock > 3) { + clock = 0; + } + tmp = sys_read32(HBN_BASE + HBN_GLB_OFFSET); + tmp = (tmp & HBN_ROOT_CLK_SEL_UMSK) | (clock << HBN_ROOT_CLK_SEL_POS); + sys_write32(tmp, HBN_BASE + HBN_GLB_OFFSET); + + clock_control_bl60x_clock_settle(); +} + +static uint32_t clock_control_bl60x_get_root_clock(void) +{ + uint32_t tmp; + + tmp = sys_read32(HBN_BASE + HBN_GLB_OFFSET); + return (((tmp & HBN_ROOT_CLK_SEL_MSK) >> HBN_ROOT_CLK_SEL_POS) & 0x3); +} + +static int clock_control_bl60x_deinit_crystal(void) +{ + uint32_t tmp; + + /* unpower crystal */ + tmp = sys_read32(AON_BASE + AON_RF_TOP_AON_OFFSET); + tmp = tmp & AON_PU_XTAL_AON_UMSK; + tmp = tmp & AON_PU_XTAL_BUF_AON_UMSK; + sys_write32(tmp, AON_BASE + AON_RF_TOP_AON_OFFSET); + + clock_control_bl60x_clock_settle(); + return 0; +} + +static int clock_control_bl60x_init_crystal(void) +{ + uint32_t tmp; + int count = CLOCK_TIMEOUT; + + /* power crystal */ + tmp = sys_read32(AON_BASE + AON_RF_TOP_AON_OFFSET); + tmp = (tmp & AON_PU_XTAL_AON_UMSK) | (1U << AON_PU_XTAL_AON_POS); + tmp = (tmp & AON_PU_XTAL_BUF_AON_UMSK) | (1U << AON_PU_XTAL_BUF_AON_POS); + sys_write32(tmp, AON_BASE + AON_RF_TOP_AON_OFFSET); + + /* wait for crystal to be powered on */ + do { + clock_control_bl60x_clock_settle(); + tmp = sys_read32(AON_BASE + AON_TSEN_OFFSET); + count--; + } while (!(tmp & AON_XTAL_RDY_MSK) && count > 0); + + clock_control_bl60x_clock_settle(); + if (count < 1) { + return -1; + } + return 0; +} + +/* HCLK is the core clock */ +static int clock_control_bl60x_set_root_clock_dividers(uint32_t hclk_div, uint32_t bclk_div) +{ + uint32_t tmp; + uint32_t old_rootclk; + + old_rootclk = clock_control_bl60x_get_root_clock(); + + /* security RC32M */ + if (old_rootclk > 1) { + clock_control_bl60x_set_root_clock(0); + } + + /* set dividers */ + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_HCLK_DIV_UMSK) | (hclk_div << GLB_REG_HCLK_DIV_POS); + tmp = (tmp & GLB_REG_BCLK_DIV_UMSK) | (bclk_div << GLB_REG_BCLK_DIV_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG0_OFFSET); + + /* do something undocumented, probably acknowledging clock change by disabling then + * reenabling bclk + */ + sys_write32(0x00000001, 0x40000FFC); + sys_write32(0x00000000, 0x40000FFC); + + clock_control_bl60x_clock_settle(); + + /* enable clocks */ + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_BCLK_EN_UMSK) | (1U << GLB_REG_BCLK_EN_POS); + tmp = (tmp & GLB_REG_HCLK_EN_UMSK) | (1U << GLB_REG_HCLK_EN_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG0_OFFSET); + + clock_control_bl60x_set_root_clock(old_rootclk); + clock_control_bl60x_clock_settle(); + + return 0; +} + +static void clock_control_bl60x_set_machine_timer_clock_enable(bool enable) +{ + uint32_t tmp; + + tmp = sys_read32(GLB_BASE + GLB_CPU_CLK_CFG_OFFSET); + if (enable) { + tmp = (tmp & GLB_CPU_RTC_EN_UMSK) | (1U << GLB_CPU_RTC_EN_POS); + } else { + tmp = (tmp & GLB_CPU_RTC_EN_UMSK) | (0U << GLB_CPU_RTC_EN_POS); + } + sys_write32(tmp, GLB_BASE + GLB_CPU_CLK_CFG_OFFSET); +} + +/* clock: + * 0: BCLK + * 1: 32Khz Oscillator (RC32*K*) + */ +static void clock_control_bl60x_set_machine_timer_clock(bool enable, uint32_t clock, + uint32_t divider) +{ + uint32_t tmp; + + if (divider > 0x1FFFF) { + divider = 0x1FFFF; + } + if (clock > 1) { + clock = 1; + } + + /* disable first, then set div */ + clock_control_bl60x_set_machine_timer_clock_enable(false); + + tmp = sys_read32(GLB_BASE + GLB_CPU_CLK_CFG_OFFSET); + tmp = (tmp & GLB_CPU_RTC_SEL_UMSK) | (clock << GLB_CPU_RTC_SEL_POS); + tmp = (tmp & GLB_CPU_RTC_DIV_UMSK) | (divider << GLB_CPU_RTC_DIV_POS); + sys_write32(tmp, GLB_BASE + GLB_CPU_CLK_CFG_OFFSET); + + clock_control_bl60x_set_machine_timer_clock_enable(enable); +} + +static void clock_control_bl60x_deinit_pll(void) +{ + uint32_t tmp; + + /* PLL Off */ + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_PU_CLKPLL_SFREG_UMSK) | (0U << PDS_PU_CLKPLL_SFREG_POS); + tmp = (tmp & PDS_PU_CLKPLL_UMSK) | (0U << PDS_PU_CLKPLL_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + /* needs 2 steps ? */ + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_PU_CP_UMSK) | (0U << PDS_CLKPLL_PU_CP_POS); + tmp = (tmp & PDS_CLKPLL_PU_PFD_UMSK) | (0U << PDS_CLKPLL_PU_PFD_POS); + tmp = (tmp & PDS_CLKPLL_PU_FBDV_UMSK) | (0U << PDS_CLKPLL_PU_FBDV_POS); + tmp = (tmp & PDS_CLKPLL_PU_POSTDIV_UMSK) | (0U << PDS_CLKPLL_PU_POSTDIV_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); +} + +/* RC32M : 0 + * XTAL : 1 + */ +static void clock_control_bl60x_set_pll_source(uint32_t source) +{ + uint32_t tmp; + + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_TOP_CTRL_OFFSET); + if (source > 0) { + tmp = (tmp & PDS_CLKPLL_REFCLK_SEL_UMSK) | (1U << PDS_CLKPLL_REFCLK_SEL_POS); + tmp = (tmp & PDS_CLKPLL_XTAL_RC32M_SEL_UMSK) | + (0U << PDS_CLKPLL_XTAL_RC32M_SEL_POS); + } else { + tmp = (tmp & PDS_CLKPLL_REFCLK_SEL_UMSK) | (0U << PDS_CLKPLL_REFCLK_SEL_POS); + tmp = (tmp & PDS_CLKPLL_XTAL_RC32M_SEL_UMSK) | + (1U << PDS_CLKPLL_XTAL_RC32M_SEL_POS); + } + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_TOP_CTRL_OFFSET); +} + +static void clock_control_bl60x_init_pll(enum bl60x_clkid source, uint32_t crystal_id) +{ + uint32_t tmp; + uint32_t old_rootclk; + + old_rootclk = clock_control_bl60x_get_root_clock(); + + /* security RC32M */ + if (old_rootclk > 1) { + clock_control_bl60x_set_root_clock(0); + } + + clock_control_bl60x_deinit_pll(); + + if (source == BL60X_CLKID_CLK_CRYSTAL) { + clock_control_bl60x_set_pll_source(1); + } else { + clock_control_bl60x_set_pll_source(0); + } + + /* 26M special treatment */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_CP_OFFSET); + if (crystal_id == CRYSTAL_ID_FREQ_26000000) { + tmp = (tmp & PDS_CLKPLL_ICP_1U_UMSK) | (1U << PDS_CLKPLL_ICP_1U_POS); + tmp = (tmp & PDS_CLKPLL_ICP_5U_UMSK) | (0U << PDS_CLKPLL_ICP_5U_POS); + tmp = (tmp & PDS_CLKPLL_INT_FRAC_SW_UMSK) | (1U << PDS_CLKPLL_INT_FRAC_SW_POS); + } else { + tmp = (tmp & PDS_CLKPLL_ICP_1U_UMSK) | (0U << PDS_CLKPLL_ICP_1U_POS); + tmp = (tmp & PDS_CLKPLL_ICP_5U_UMSK) | (2U << PDS_CLKPLL_ICP_5U_POS); + tmp = (tmp & PDS_CLKPLL_INT_FRAC_SW_UMSK) | (0U << PDS_CLKPLL_INT_FRAC_SW_POS); + } + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_CP_OFFSET); + + /* More 26M special treatment */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_RZ_OFFSET); + if (crystal_id == CRYSTAL_ID_FREQ_26000000) { + tmp = (tmp & PDS_CLKPLL_C3_UMSK) | (2U << PDS_CLKPLL_C3_POS); + tmp = (tmp & PDS_CLKPLL_CZ_UMSK) | (2U << PDS_CLKPLL_CZ_POS); + tmp = (tmp & PDS_CLKPLL_RZ_UMSK) | (5U << PDS_CLKPLL_RZ_POS); + tmp = (tmp & PDS_CLKPLL_R4_SHORT_UMSK) | (0U << PDS_CLKPLL_R4_SHORT_POS); + } else { + tmp = (tmp & PDS_CLKPLL_C3_UMSK) | (3U << PDS_CLKPLL_C3_POS); + tmp = (tmp & PDS_CLKPLL_CZ_UMSK) | (1U << PDS_CLKPLL_CZ_POS); + tmp = (tmp & PDS_CLKPLL_RZ_UMSK) | (1U << PDS_CLKPLL_RZ_POS); + tmp = (tmp & PDS_CLKPLL_R4_SHORT_UMSK) | (1U << PDS_CLKPLL_R4_SHORT_POS); + } + tmp = (tmp & PDS_CLKPLL_R4_UMSK) | (2U << PDS_CLKPLL_R4_POS); + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_RZ_OFFSET); + + /* set pll dividers */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_TOP_CTRL_OFFSET); + tmp = (tmp & PDS_CLKPLL_POSTDIV_UMSK) | ((uint32_t)(0x14) << PDS_CLKPLL_POSTDIV_POS); + tmp = (tmp & PDS_CLKPLL_REFDIV_RATIO_UMSK) | (2U << PDS_CLKPLL_REFDIV_RATIO_POS); + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_TOP_CTRL_OFFSET); + + /* set SDMIN */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_SDM_OFFSET); + if (source == BL60X_CLKID_CLK_CRYSTAL) { + tmp = (tmp & PDS_CLKPLL_SDMIN_UMSK) | + (clock_control_bl60x_crystal_SDMIN_table[crystal_id] + << PDS_CLKPLL_SDMIN_POS); + } else { + tmp = (tmp & PDS_CLKPLL_SDMIN_UMSK) | + (clock_control_bl60x_crystal_SDMIN_table[CRYSTAL_ID_FREQ_32000000] + << PDS_CLKPLL_SDMIN_POS); + } + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_SDM_OFFSET); + + /* phase comparator settings? */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_FBDV_OFFSET); + tmp = (tmp & PDS_CLKPLL_SEL_FB_CLK_UMSK) | (1U << PDS_CLKPLL_SEL_FB_CLK_POS); + tmp = (tmp & PDS_CLKPLL_SEL_SAMPLE_CLK_UMSK) | (1U << PDS_CLKPLL_SEL_SAMPLE_CLK_POS); + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_FBDV_OFFSET); + + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_PU_CLKPLL_SFREG_UMSK) | (1U << PDS_PU_CLKPLL_SFREG_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + clock_control_bl60x_clock_settle(); + + /* enable PPL clock actual? */ + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_PU_CLKPLL_UMSK) | (1U << PDS_PU_CLKPLL_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + /* More power up sequencing*/ + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_PU_CP_UMSK) | (1U << PDS_CLKPLL_PU_CP_POS); + tmp = (tmp & PDS_CLKPLL_PU_PFD_UMSK) | (1U << PDS_CLKPLL_PU_PFD_POS); + tmp = (tmp & PDS_CLKPLL_PU_FBDV_UMSK) | (1U << PDS_CLKPLL_PU_FBDV_POS); + tmp = (tmp & PDS_CLKPLL_PU_POSTDIV_UMSK) | (1U << PDS_CLKPLL_PU_POSTDIV_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + clock_control_bl60x_clock_settle(); + + /* reset couple things one by one? */ + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_SDM_RESET_UMSK) | (1U << PDS_CLKPLL_SDM_RESET_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_RESET_FBDV_UMSK) | (1U << PDS_CLKPLL_RESET_FBDV_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_RESET_FBDV_UMSK) | (0U << PDS_CLKPLL_RESET_FBDV_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + tmp = sys_read32(PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + tmp = (tmp & PDS_CLKPLL_SDM_RESET_UMSK) | (0U << PDS_CLKPLL_SDM_RESET_POS); + sys_write32(tmp, PDS_BASE + PDS_PU_RST_CLKPLL_OFFSET); + + clock_control_bl60x_set_root_clock(old_rootclk); + clock_control_bl60x_clock_settle(); +} + +/* + * 0: 48M + * 1: 120M + * 2: 160M + * 3: 192M + */ +static void clock_control_bl60x_select_PLL(uint8_t pll) +{ + uint32_t tmp; + + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_PLL_SEL_UMSK) | (pll << GLB_REG_PLL_SEL_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG0_OFFSET); +} + +static int clock_control_bl60x_clock_trim_32M(void) +{ + uint32_t tmp; + int err; + uint32_t trim, trim_parity; + const struct device *efuse = DEVICE_DT_GET_ONE(bflb_efuse); + + err = syscon_read_reg(efuse, EFUSE_RC32M_TRIM_OFFSET, &trim); + if (err < 0) { + LOG_ERR("Error: Couldn't read efuses: err: %d.\n", err); + return err; + } + if (!((trim >> EFUSE_RC32M_TRIM_EN_POS) & 1)) { + LOG_ERR("RC32M trim disabled!"); + return -EINVAL; + } + + trim_parity = (trim >> EFUSE_RC32M_TRIM_PARITY_POS) & 1; + trim = (trim & EFUSE_RC32M_TRIM_MSK) >> EFUSE_RC32M_TRIM_POS; + + if (trim_parity != (POPCOUNT(trim) & 1)) { + LOG_ERR("Bad trim parity"); + return -EINVAL; + } + + tmp = sys_read32(PDS_BASE + PDS_RC32M_CTRL0_OFFSET); + tmp = (tmp & PDS_RC32M_EXT_CODE_EN_UMSK) | 1 << PDS_RC32M_EXT_CODE_EN_POS; + tmp = (tmp & PDS_RC32M_CODE_FR_EXT_UMSK) | trim << PDS_RC32M_CODE_FR_EXT_POS; + sys_write32(tmp, PDS_BASE + PDS_RC32M_CTRL0_OFFSET); + + clock_control_bl60x_clock_settle(); + + return 0; +} + +/* source for most clocks, either XTAL or RC32M */ +static uint32_t clock_control_bl60x_get_xclk(const struct device *dev) +{ + uint32_t tmp; + + tmp = sys_read32(HBN_BASE + HBN_GLB_OFFSET); + tmp &= HBN_ROOT_CLK_SEL_MSK; + tmp = tmp >> HBN_ROOT_CLK_SEL_POS; + tmp &= 1; + if (tmp == 0) { + return BFLB_RC32M_FREQUENCY; + } else if (tmp == 1) { + return DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, crystal), clock_frequency); + } else { + return 0; + } +} + +static uint32_t clock_control_bl60x_get_clk(const struct device *dev) +{ + uint32_t tmp; + uint32_t hclk_div; + + hclk_div = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + hclk_div = (hclk_div & GLB_REG_HCLK_DIV_MSK) >> GLB_REG_HCLK_DIV_POS; + + tmp = sys_read32(HBN_BASE + HBN_GLB_OFFSET); + tmp &= HBN_ROOT_CLK_SEL_MSK; + tmp = (tmp >> HBN_ROOT_CLK_SEL_POS) >> 1; + tmp &= 1; + + if (tmp == 0) { + return clock_control_bl60x_get_xclk(dev) / (hclk_div + 1); + } + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_PLL_SEL_MSK) >> GLB_REG_PLL_SEL_POS; + if (tmp == 3) { + return MHZ(192) / (hclk_div + 1); + } else if (tmp == 2) { + return MHZ(160) / (hclk_div + 1); + } else if (tmp == 1) { + return MHZ(120) / (hclk_div + 1); + } else if (tmp == 0) { + return MHZ(48) / (hclk_div + 1); + } + return 0; +} + +/* most peripherals clock */ +static uint32_t clock_control_bl60x_get_bclk(const struct device *dev) +{ + uint32_t tmp; + uint32_t clock_id; + + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_BCLK_DIV_MSK) >> GLB_REG_BCLK_DIV_POS; + clock_id = clock_control_bl60x_get_clk(dev); + return clock_id / (tmp + 1); +} + +static uint32_t clock_control_bl60x_mtimer_get_clk_src_div(const struct device *dev) +{ + return clock_control_bl60x_get_bclk(dev) / 1000 / 1000 - 1; +} + +static void clock_control_bl60x_cache_2T(bool yes) +{ + uint32_t tmp; + + tmp = sys_read32(L1C_BASE + L1C_CONFIG_OFFSET); + + if (yes) { + tmp |= L1C_IROM_2T_ACCESS_MSK; + } else { + tmp &= ~L1C_IROM_2T_ACCESS_MSK; + } + + sys_write32(tmp, L1C_BASE + L1C_CONFIG_OFFSET); +} + +/* HCLK: 0 + * PLL120M: 1 + */ +static void clock_control_bl60x_set_PKA_clock(uint32_t pka_clock) +{ + uint32_t tmp; + + tmp = sys_read32(GLB_BASE + GLB_SWRST_CFG2_OFFSET); + tmp = (tmp & GLB_PKA_CLK_SEL_UMSK) | (pka_clock << GLB_PKA_CLK_SEL_POS); + sys_write32(tmp, GLB_BASE + GLB_SWRST_CFG2_OFFSET); +} + +static void clock_control_bl60x_init_root_as_pll(const struct device *dev) +{ + struct clock_control_bl60x_data *data = dev->data; + const struct clock_control_bl60x_config *config = dev->config; + uint32_t tmp; + + clock_control_bl60x_init_pll(data->pll.source, config->crystal_id); + + /* enable all 'PDS' clocks */ + tmp = sys_read32(PDS_BASE + PDS_CLKPLL_OUTPUT_EN_OFFSET); + tmp |= 0x1FF; + sys_write32(tmp, PDS_BASE + PDS_CLKPLL_OUTPUT_EN_OFFSET); + + /* glb enable pll actual? */ + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_PLL_EN_UMSK) | (1U << GLB_REG_PLL_EN_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG0_OFFSET); + + clock_control_bl60x_select_PLL(data->root.pll_select); + + if (data->pll.source == bl60x_clkid_clk_crystal) { + clock_control_bl60x_set_root_clock(3); + } else { + clock_control_bl60x_set_root_clock(2); + } + + if (clock_control_bl60x_get_clk(dev) > MHZ(120)) { + clock_control_bl60x_cache_2T(true); + } + + sys_write32(clock_control_bl60x_get_clk(dev), CORECLOCKREGISTER); + clock_control_bl60x_set_PKA_clock(1); +} + +static void clock_control_bl60x_init_root_as_crystal(const struct device *dev) +{ + clock_control_bl60x_set_root_clock(1); + sys_write32(clock_control_bl60x_get_clk(dev), CORECLOCKREGISTER); +} + +static int clock_control_bl60x_update_root(const struct device *dev) +{ + struct clock_control_bl60x_data *data = dev->data; + uint32_t tmp; + int ret; + + /* make sure all clocks are enabled */ + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG0_OFFSET); + tmp = (tmp & GLB_REG_BCLK_EN_UMSK) | (1U << GLB_REG_BCLK_EN_POS); + tmp = (tmp & GLB_REG_HCLK_EN_UMSK) | (1U << GLB_REG_HCLK_EN_POS); + tmp = (tmp & GLB_REG_FCLK_EN_UMSK) | (1U << GLB_REG_FCLK_EN_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG0_OFFSET); + + /* set root clock to internal 32MHz Oscillator as failsafe */ + clock_control_bl60x_set_root_clock(0); + if (clock_control_bl60x_set_root_clock_dividers(0, 0) != 0) { + return -EIO; + } + sys_write32(BFLB_RC32M_FREQUENCY, CORECLOCKREGISTER); + + clock_control_bl60x_set_PKA_clock(0); + + if (data->crystal_enabled) { + if (clock_control_bl60x_init_crystal() < 0) { + return -EIO; + } + } else { + clock_control_bl60x_deinit_crystal(); + } + + ret = clock_control_bl60x_set_root_clock_dividers(data->root.divider - 1, + data->bclk.divider - 1); + if (ret < 0) { + return ret; + } + + if (data->root.source == bl60x_clkid_clk_pll) { + clock_control_bl60x_init_root_as_pll(dev); + } else if (data->root.source == bl60x_clkid_clk_crystal) { + clock_control_bl60x_init_root_as_crystal(dev); + } else { + /* Root clock already setup as RC32M */ + } + + ret = clock_control_bl60x_clock_trim_32M(); + if (ret < 0) { + return ret; + } + clock_control_bl60x_set_machine_timer_clock( + 1, 0, clock_control_bl60x_mtimer_get_clk_src_div(dev)); + + clock_control_bl60x_clock_settle(); + + return ret; +} + +static void clock_control_bl60x_uart_set_clock_enable(bool enable) +{ + uint32_t tmp; + + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG2_OFFSET); + if (enable) { + tmp = (tmp & GLB_UART_CLK_EN_UMSK) | (1U << GLB_UART_CLK_EN_POS); + } else { + tmp = (tmp & GLB_UART_CLK_EN_UMSK) | (0U << GLB_UART_CLK_EN_POS); + } + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG2_OFFSET); +} + +/* Clock: + * FCLK: 0 + * 160 Mhz PLL: 1 + * When using PLL root clock, we can use either setting, when using the 32Mhz Oscillator with a + * uninitialized PLL, only FCLK will be available. + */ +static void clock_control_bl60x_uart_set_clock(bool enable, uint32_t clock, uint32_t divider) +{ + uint32_t tmp; + + if (divider > 0x7) { + divider = 0x7; + } + if (clock > 1) { + clock = 1; + } + /* disable uart clock */ + clock_control_bl60x_uart_set_clock_enable(false); + + tmp = sys_read32(GLB_BASE + GLB_CLK_CFG2_OFFSET); + tmp = (tmp & GLB_UART_CLK_DIV_UMSK) | (divider << GLB_UART_CLK_DIV_POS); + sys_write32(tmp, GLB_BASE + GLB_CLK_CFG2_OFFSET); + + tmp = sys_read32(HBN_BASE + HBN_GLB_OFFSET); + tmp = (tmp & HBN_UART_CLK_SEL_UMSK) | (clock << HBN_UART_CLK_SEL_POS); + sys_write32(tmp, HBN_BASE + HBN_GLB_OFFSET); + + clock_control_bl60x_uart_set_clock_enable(enable); +} + +/* Simple function to enable all peripherals for now */ +static void clock_control_bl60x_peripheral_clock_init(void) +{ + uint32_t regval = sys_read32(GLB_BASE + GLB_CGEN_CFG1_OFFSET); + + /* enable ADC clock routing */ + regval |= (1 << 2); + /* enable UART0 clock routing */ + regval |= (1 << 16); + /* enable I2C0 clock routing */ + regval |= (1 << 19); + + sys_write32(regval, GLB_BASE + GLB_CGEN_CFG1_OFFSET); + + clock_control_bl60x_uart_set_clock(1, 0, 0); +} + +static int clock_control_bl60x_on(const struct device *dev, clock_control_subsys_t sys) +{ + struct clock_control_bl60x_data *data = dev->data; + int ret = -EINVAL; + uint32_t key; + enum bl60x_clkid oldroot; + + key = irq_lock(); + + if ((enum bl60x_clkid)sys == bl60x_clkid_clk_crystal) { + if (data->crystal_enabled) { + ret = 0; + } else { + data->crystal_enabled = true; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->crystal_enabled = false; + } + } + } else if ((enum bl60x_clkid)sys == bl60x_clkid_clk_pll) { + if (data->pll_enabled) { + ret = 0; + } else { + data->pll_enabled = true; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->pll_enabled = false; + } + } + } else if ((int)sys == BFLB_FORCE_ROOT_RC32M) { + if (data->root.source == bl60x_clkid_clk_rc32m) { + ret = 0; + } else { + /* Cannot fail to set root to rc32m */ + data->root.source = bl60x_clkid_clk_rc32m; + ret = clock_control_bl60x_update_root(dev); + } + } else if ((int)sys == BFLB_FORCE_ROOT_CRYSTAL) { + if (data->root.source == bl60x_clkid_clk_crystal) { + ret = 0; + } else { + oldroot = data->root.source; + data->root.source = bl60x_clkid_clk_crystal; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->root.source = oldroot; + } + } + } else if ((int)sys == BFLB_FORCE_ROOT_PLL) { + if (data->root.source == bl60x_clkid_clk_pll) { + ret = 0; + } else { + oldroot = data->root.source; + data->root.source = bl60x_clkid_clk_pll; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->root.source = oldroot; + } + } + } + + irq_unlock(key); + return ret; +} + +static int clock_control_bl60x_off(const struct device *dev, clock_control_subsys_t sys) +{ + struct clock_control_bl60x_data *data = dev->data; + int ret = -EINVAL; + uint32_t key; + + key = irq_lock(); + + if ((enum bl60x_clkid)sys == bl60x_clkid_clk_crystal) { + if (!data->crystal_enabled) { + ret = 0; + } else { + data->crystal_enabled = false; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->crystal_enabled = true; + } + } + } else if ((enum bl60x_clkid)sys == bl60x_clkid_clk_pll) { + if (!data->pll_enabled) { + ret = 0; + } else { + data->pll_enabled = false; + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + data->pll_enabled = true; + } + } + } + + irq_unlock(key); + return ret; +} + +static enum clock_control_status clock_control_bl60x_get_status(const struct device *dev, + clock_control_subsys_t sys) +{ + struct clock_control_bl60x_data *data = dev->data; + + switch ((enum bl60x_clkid)sys) { + case bl60x_clkid_clk_root: + case bl60x_clkid_clk_bclk: + case bl60x_clkid_clk_rc32m: + return CLOCK_CONTROL_STATUS_ON; + case bl60x_clkid_clk_crystal: + if (data->crystal_enabled) { + return CLOCK_CONTROL_STATUS_ON; + } + return CLOCK_CONTROL_STATUS_OFF; + case bl60x_clkid_clk_pll: + if (data->pll_enabled) { + return CLOCK_CONTROL_STATUS_ON; + } + return CLOCK_CONTROL_STATUS_OFF; + default: + return CLOCK_CONTROL_STATUS_UNKNOWN; + } +} + +static int clock_control_bl60x_get_rate(const struct device *dev, clock_control_subsys_t sys, + uint32_t *rate) +{ + if ((enum bl60x_clkid)sys == bl60x_clkid_clk_root) { + *rate = clock_control_bl60x_get_clk(dev); + } else if ((enum bl60x_clkid)sys == bl60x_clkid_clk_bclk) { + *rate = clock_control_bl60x_get_bclk(dev); + } else if ((enum bl60x_clkid)sys == bl60x_clkid_clk_crystal) { + *rate = DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, crystal), clock_frequency); + } else if ((enum bl60x_clkid)sys == bl60x_clkid_clk_rc32m) { + *rate = BFLB_RC32M_FREQUENCY; + } else { + return -EINVAL; + } + return 0; +} + +static int clock_control_bl60x_init(const struct device *dev) +{ + int ret; + uint32_t key; + + key = irq_lock(); + + ret = clock_control_bl60x_update_root(dev); + if (ret < 0) { + irq_unlock(key); + return ret; + } + + clock_control_bl60x_peripheral_clock_init(); + + irq_unlock(key); + + return 0; +} + +static DEVICE_API(clock_control, clock_control_bl60x_api) = { + .on = clock_control_bl60x_on, + .off = clock_control_bl60x_off, + .get_rate = clock_control_bl60x_get_rate, + .get_status = clock_control_bl60x_get_status, +}; + +static const struct clock_control_bl60x_config clock_control_bl60x_config = { + .crystal_id = CRYSTAL_FREQ_TO_ID(DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, crystal), + clock_frequency)), +}; + +static struct clock_control_bl60x_data clock_control_bl60x_data = { + .crystal_enabled = DT_NODE_HAS_STATUS_OKAY(DT_INST_CLOCKS_CTLR_BY_NAME(0, crystal)), + .pll_enabled = DT_NODE_HAS_STATUS_OKAY(DT_INST_CLOCKS_CTLR_BY_NAME(0, pll_192)), + + .root = { +#if CLK_SRC_IS(root, pll_192) + .source = bl60x_clkid_clk_pll, + .pll_select = DT_CLOCKS_CELL(DT_INST_CLOCKS_CTLR_BY_NAME(0, root), select), +#elif CLK_SRC_IS(root, crystal) + .source = bl60x_clkid_clk_crystal, +#else + .source = bl60x_clkid_clk_rc32m, +#endif + .divider = DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, root), divider), + }, + + .pll = { +#if CLK_SRC_IS(pll_192, crystal) + .source = bl60x_clkid_clk_crystal, +#else + .source = bl60x_clkid_clk_rc32m, +#endif + }, + + .bclk = { + .divider = DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, bclk), divider), + }, +}; + +BUILD_ASSERT(CLK_SRC_IS(pll_192, crystal) || CLK_SRC_IS(root, crystal) + ? DT_NODE_HAS_STATUS_OKAY(DT_INST_CLOCKS_CTLR_BY_NAME(0, crystal)) + : 1, + "Crystal must be enabled to use it"); + +BUILD_ASSERT(CLK_SRC_IS(root, pll_192) ? + DT_NODE_HAS_STATUS_OKAY(DT_INST_CLOCKS_CTLR_BY_NAME(0, pll_192)) : 1, + "PLL must be enabled to use it"); + +BUILD_ASSERT(DT_NODE_HAS_STATUS_OKAY(DT_INST_CLOCKS_CTLR_BY_NAME(0, rc32m)), "RC32M is always on"); + +BUILD_ASSERT(DT_PROP(DT_INST_CLOCKS_CTLR_BY_NAME(0, rc32m), clock_frequency) + == BFLB_RC32M_FREQUENCY, "RC32M must be 32M"); + +DEVICE_DT_INST_DEFINE(0, clock_control_bl60x_init, NULL, &clock_control_bl60x_data, + &clock_control_bl60x_config, PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY, + &clock_control_bl60x_api); diff --git a/drivers/clock_control/clock_control_nrf2_common.c b/drivers/clock_control/clock_control_nrf2_common.c index f070d5d7b698..c2657f454782 100644 --- a/drivers/clock_control/clock_control_nrf2_common.c +++ b/drivers/clock_control/clock_control_nrf2_common.c @@ -5,7 +5,6 @@ #include "clock_control_nrf2_common.h" #include -#include #include LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL); @@ -20,8 +19,6 @@ LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL); (idx * sizeof(array[0])) - \ offsetof(type, array[0])) -#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr)) - /* * Definition of `struct clock_config_generic`. * Used to access `clock_config_*` structures in a common way. @@ -92,40 +89,6 @@ static inline uint8_t get_index_of_highest_bit(uint32_t value) return value ? (uint8_t)(31 - __builtin_clz(value)) : 0; } -int lfosc_get_accuracy(uint16_t *accuracy) -{ - switch (nrf_bicr_lfosc_accuracy_get(BICR)) { - case NRF_BICR_LFOSC_ACCURACY_500PPM: - *accuracy = 500U; - break; - case NRF_BICR_LFOSC_ACCURACY_250PPM: - *accuracy = 250U; - break; - case NRF_BICR_LFOSC_ACCURACY_150PPM: - *accuracy = 150U; - break; - case NRF_BICR_LFOSC_ACCURACY_100PPM: - *accuracy = 100U; - break; - case NRF_BICR_LFOSC_ACCURACY_75PPM: - *accuracy = 75U; - break; - case NRF_BICR_LFOSC_ACCURACY_50PPM: - *accuracy = 50U; - break; - case NRF_BICR_LFOSC_ACCURACY_30PPM: - *accuracy = 30U; - break; - case NRF_BICR_LFOSC_ACCURACY_20PPM: - *accuracy = 20U; - break; - default: - return -EINVAL; - } - - return 0; -} - int clock_config_init(void *clk_cfg, uint8_t onoff_cnt, k_work_handler_t update_work_handler) { struct clock_config_generic *cfg = clk_cfg; diff --git a/drivers/clock_control/clock_control_nrf2_common.h b/drivers/clock_control/clock_control_nrf2_common.h index 7f934fdac5b8..4b1c7fe000e4 100644 --- a/drivers/clock_control/clock_control_nrf2_common.h +++ b/drivers/clock_control/clock_control_nrf2_common.h @@ -36,16 +36,6 @@ struct clock_onoff { struct clock_onoff onoff[_onoff_cnt]; \ } -/** - * @brief Obtain LFOSC accuracy in ppm. - * - * @param[out] accuracy Accuracy in ppm. - * - * @retval 0 On success - * @retval -EINVAL If accuracy is not configured. - */ -int lfosc_get_accuracy(uint16_t *accuracy); - /** * @brief Initializes a clock configuration structure. * diff --git a/drivers/clock_control/clock_control_nrf2_hfxo.c b/drivers/clock_control/clock_control_nrf54h_hfxo.c similarity index 89% rename from drivers/clock_control/clock_control_nrf2_hfxo.c rename to drivers/clock_control/clock_control_nrf54h_hfxo.c index 21d3d33f7e8d..1c8d6f8ed181 100644 --- a/drivers/clock_control/clock_control_nrf2_hfxo.c +++ b/drivers/clock_control/clock_control_nrf54h_hfxo.c @@ -271,6 +271,39 @@ static int init_hfxo(const struct device *dev) return 0; } +static int api_resolve(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ + const struct dev_config_hfxo *dev_config = dev->config; + + if (!is_clock_spec_valid(dev, req_spec)) { + return -EINVAL; + } + + res_spec->frequency = dev_config->fixed_frequency; + res_spec->accuracy = dev_config->fixed_accuracy; + res_spec->precision = NRF_CLOCK_CONTROL_PRECISION_HIGH; + return 0; +} + +static int api_get_startup_time(const struct device *dev, + const struct nrf_clock_spec *spec, + uint32_t *startup_time_us) +{ + if (!is_clock_spec_valid(dev, spec)) { + return -EINVAL; + } + + *startup_time_us = nrf_bicr_hfxo_startup_time_us_get(BICR); + + if (*startup_time_us == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) { + return -EINVAL; + } + + return 0; +} + static DEVICE_API(nrf_clock_control, drv_api_hfxo) = { .std_api = { .on = api_nosys_on_off, @@ -280,6 +313,8 @@ static DEVICE_API(nrf_clock_control, drv_api_hfxo) = { .request = api_request_hfxo, .release = api_release_hfxo, .cancel_or_release = api_cancel_or_release_hfxo, + .resolve = api_resolve, + .get_startup_time = api_get_startup_time, }; static struct dev_data_hfxo data_hfxo; diff --git a/drivers/clock_control/clock_control_nrf_auxpll.c b/drivers/clock_control/clock_control_nrf_auxpll.c index 19dee8c44938..d048f4ed1c7e 100644 --- a/drivers/clock_control/clock_control_nrf_auxpll.c +++ b/drivers/clock_control/clock_control_nrf_auxpll.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA * SPDX-License-Identifier: Apache-2.0 */ @@ -9,55 +9,65 @@ #include #include -#include #include -#include -#include +#include #include #include +#include +#include "clock_control_nrf2_common.h" #include -/* maximum lock time in ms, >10x time observed experimentally */ -#define AUXPLL_LOCK_TIME_MAX_MS 20 -/* lock wait step in ms*/ -#define AUXPLL_LOCK_WAIT_STEP_MS 1 + +/* Check dt-bindings match MDK frequency division definitions*/ +BUILD_ASSERT(NRF_AUXPLL_FREQ_DIV_MIN == NRF_AUXPLL_FREQUENCY_DIV_MIN, + "Different AUXPLL_FREQ_DIV_MIN definition in MDK and devicetree binding"); +BUILD_ASSERT(NRF_AUXPLL_FREQ_DIV_AUDIO_44K1 == NRF_AUXPLL_FREQUENCY_AUDIO_44K1, + "Different AUXPLL_FREQ_DIV_AUDIO_44K1 definition in MDK and devicetree binding"); +BUILD_ASSERT(NRF_AUXPLL_FREQ_DIV_USB24M == NRF_AUXPLL_FREQUENCY_USB_24M, + "Different AUXPLL_FREQ_DIV_USB24M definition in MDK and devicetree binding"); +BUILD_ASSERT(NRF_AUXPLL_FREQ_DIV_AUDIO_48K == NRF_AUXPLL_FREQUENCY_AUDIO_48K, + "Different AUXPLL_FREQ_DIV_AUDIO_48K definition in MDK and devicetree binding"); +BUILD_ASSERT(NRF_AUXPLL_FREQ_DIV_MAX == NRF_AUXPLL_FREQUENCY_DIV_MAX, + "Different AUXPLL_FREQ_DIV_MAX definition in MDK and devicetree binding"); + +/* maximum lock time in us, >10x time observed experimentally */ +#define AUXPLL_LOCK_TIME_MAX_US 20000 +/* lock wait step in us*/ +#define AUXPLL_LOCK_WAIT_STEP_US 1000 + +struct dev_data_auxpll { + struct onoff_manager mgr; + onoff_notify_fn notify; + const struct device *dev; +}; struct clock_control_nrf_auxpll_config { NRF_AUXPLL_Type *auxpll; uint32_t ref_clk_hz; uint32_t ficr_ctune; nrf_auxpll_config_t cfg; - uint16_t frequency; + nrf_auxpll_freq_div_ratio_t frequency; nrf_auxpll_ctrl_outsel_t out_div; }; -static int clock_control_nrf_auxpll_on(const struct device *dev, clock_control_subsys_t sys) +static int clock_control_nrf_auxpll_on(struct dev_data_auxpll *dev_data) { - const struct clock_control_nrf_auxpll_config *config = dev->config; + const struct clock_control_nrf_auxpll_config *config = dev_data->dev->config; bool locked; - unsigned int wait = 0U; - - ARG_UNUSED(sys); nrf_auxpll_task_trigger(config->auxpll, NRF_AUXPLL_TASK_START); - do { - locked = nrf_auxpll_mode_locked_check(config->auxpll); - if (!locked) { - k_msleep(AUXPLL_LOCK_WAIT_STEP_MS); - wait += AUXPLL_LOCK_WAIT_STEP_MS; - } - } while (wait < AUXPLL_LOCK_TIME_MAX_MS && !locked); + NRFX_WAIT_FOR(nrf_auxpll_mode_locked_check(config->auxpll), + AUXPLL_LOCK_TIME_MAX_US / AUXPLL_LOCK_WAIT_STEP_US, + AUXPLL_LOCK_WAIT_STEP_US, locked); return locked ? 0 : -ETIMEDOUT; } -static int clock_control_nrf_auxpll_off(const struct device *dev, clock_control_subsys_t sys) +static int clock_control_nrf_auxpll_off(struct dev_data_auxpll *dev_data) { - const struct clock_control_nrf_auxpll_config *config = dev->config; - - ARG_UNUSED(sys); + const struct clock_control_nrf_auxpll_config *config = dev_data->dev->config; nrf_auxpll_task_trigger(config->auxpll, NRF_AUXPLL_TASK_STOP); @@ -67,6 +77,58 @@ static int clock_control_nrf_auxpll_off(const struct device *dev, clock_control_ return 0; } +static void onoff_start_auxpll(struct onoff_manager *mgr, onoff_notify_fn notify) +{ + struct dev_data_auxpll *dev_data = + CONTAINER_OF(mgr, struct dev_data_auxpll, mgr); + + int ret = clock_control_nrf_auxpll_on(dev_data); + + notify(&dev_data->mgr, ret); + +} + +static void onoff_stop_auxpll(struct onoff_manager *mgr, onoff_notify_fn notify) +{ + struct dev_data_auxpll *dev_data = + CONTAINER_OF(mgr, struct dev_data_auxpll, mgr); + + clock_control_nrf_auxpll_off(dev_data); + notify(mgr, 0); +} + +static int api_request_auxpll(const struct device *dev, + const struct nrf_clock_spec *spec, + struct onoff_client *cli) +{ + struct dev_data_auxpll *dev_data = dev->data; + + ARG_UNUSED(spec); + + return onoff_request(&dev_data->mgr, cli); +} + +static int api_release_auxpll(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + struct dev_data_auxpll *dev_data = dev->data; + + ARG_UNUSED(spec); + + return onoff_release(&dev_data->mgr); +} + +static int api_cancel_or_release_auxpll(const struct device *dev, + const struct nrf_clock_spec *spec, + struct onoff_client *cli) +{ + struct dev_data_auxpll *dev_data = dev->data; + + ARG_UNUSED(spec); + + return onoff_cancel_or_release(&dev_data->mgr, cli); +} + static int clock_control_nrf_auxpll_get_rate(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate) { @@ -99,16 +161,21 @@ static enum clock_control_status clock_control_nrf_auxpll_get_status(const struc return CLOCK_CONTROL_STATUS_OFF; } -static DEVICE_API(clock_control, clock_control_nrf_auxpll_api) = { - .on = clock_control_nrf_auxpll_on, - .off = clock_control_nrf_auxpll_off, - .get_rate = clock_control_nrf_auxpll_get_rate, - .get_status = clock_control_nrf_auxpll_get_status, +static const struct onoff_transitions transitions = { + .start = onoff_start_auxpll, + .stop = onoff_stop_auxpll }; static int clock_control_nrf_auxpll_init(const struct device *dev) { + struct dev_data_auxpll *dev_data = dev->data; const struct clock_control_nrf_auxpll_config *config = dev->config; + int rc; + + rc = onoff_manager_init(&dev_data->mgr, &transitions); + if (rc < 0) { + return rc; + } nrf_auxpll_ctrl_frequency_set(config->auxpll, config->frequency); @@ -123,7 +190,31 @@ static int clock_control_nrf_auxpll_init(const struct device *dev) return 0; } +static DEVICE_API(nrf_clock_control, drv_api_auxpll) = { + .std_api = { + .on = api_nosys_on_off, + .off = api_nosys_on_off, + .get_rate = clock_control_nrf_auxpll_get_rate, + .get_status = clock_control_nrf_auxpll_get_status, + }, + .request = api_request_auxpll, + .release = api_release_auxpll, + .cancel_or_release = api_cancel_or_release_auxpll, +}; + #define CLOCK_CONTROL_NRF_AUXPLL_DEFINE(n) \ + BUILD_ASSERT( \ + DT_INST_PROP(n, nordic_frequency) == NRF_AUXPLL_FREQUENCY_DIV_MIN || \ + DT_INST_PROP(n, nordic_frequency) == NRF_AUXPLL_FREQUENCY_AUDIO_44K1 || \ + DT_INST_PROP(n, nordic_frequency) == NRF_AUXPLL_FREQUENCY_USB_24M || \ + DT_INST_PROP(n, nordic_frequency) == NRF_AUXPLL_FREQUENCY_AUDIO_48K || \ + DT_INST_PROP(n, nordic_frequency) == NRF_AUXPLL_FREQUENCY_DIV_MAX, \ + "Invalid nordic,frequency value in DeviceTree for AUXPLL instance " #n); \ + BUILD_ASSERT(DT_INST_PROP(n, nordic_out_div) > 0, \ + "nordic,out_div must be greater than 0 for AUXPLL instance " #n); \ + static struct dev_data_auxpll data_auxpll##n = { \ + .dev = DEVICE_DT_INST_GET(n), \ + }; \ static const struct clock_control_nrf_auxpll_config config##n = { \ .auxpll = (NRF_AUXPLL_Type *)DT_INST_REG_ADDR(n), \ .ref_clk_hz = DT_PROP(DT_INST_CLOCKS_CTLR(n), clock_frequency), \ @@ -140,9 +231,9 @@ static int clock_control_nrf_auxpll_init(const struct device *dev) .frequency = DT_INST_PROP(n, nordic_frequency), \ .out_div = DT_INST_PROP(n, nordic_out_div), \ }; \ - \ - DEVICE_DT_INST_DEFINE(n, clock_control_nrf_auxpll_init, NULL, NULL, &config##n, \ + \ + DEVICE_DT_INST_DEFINE(n, clock_control_nrf_auxpll_init, NULL, &data_auxpll##n, &config##n, \ PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY, \ - &clock_control_nrf_auxpll_api); + &drv_api_auxpll); DT_INST_FOREACH_STATUS_OKAY(CLOCK_CONTROL_NRF_AUXPLL_DEFINE) diff --git a/drivers/clock_control/clock_control_nrf2_fll16m.c b/drivers/clock_control/clock_control_nrf_fll16m.c similarity index 66% rename from drivers/clock_control/clock_control_nrf2_fll16m.c rename to drivers/clock_control/clock_control_nrf_fll16m.c index 7bb10263d5b6..92b09804b8a7 100644 --- a/drivers/clock_control/clock_control_nrf2_fll16m.c +++ b/drivers/clock_control/clock_control_nrf_fll16m.c @@ -34,6 +34,7 @@ BUILD_ASSERT(FLL16M_MODE_CLOSED_LOOP == NRF_LRCCONF_CLK_SRC_CLOSED_LOOP); #define FLL16M_HFXO_ACCURACY DT_PROP(FLL16M_HFXO_NODE, accuracy_ppm) #define FLL16M_OPEN_LOOP_ACCURACY DT_INST_PROP(0, open_loop_accuracy_ppm) #define FLL16M_MAX_ACCURACY FLL16M_HFXO_ACCURACY +#define FLL16M_OPEN_LOOP_STARTUP_TIME_US DT_INST_PROP(0, open_loop_startup_time_us) #define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr)) @@ -57,6 +58,7 @@ struct fll16m_dev_data { STRUCT_CLOCK_CONFIG(fll16m, ARRAY_SIZE(clock_options)) clk_cfg; struct onoff_client hfxo_cli; sys_snode_t fll16m_node; + uint32_t bypass_startup_time_us; }; struct fll16m_dev_config { @@ -133,49 +135,98 @@ static void fll16m_work_handler(struct k_work *work) } } -static struct onoff_manager *fll16m_find_mgr(const struct device *dev, - const struct nrf_clock_spec *spec) +static int fll16m_resolve_spec_to_idx(const struct device *dev, + const struct nrf_clock_spec *req_spec) { - struct fll16m_dev_data *dev_data = dev->data; const struct fll16m_dev_config *dev_config = dev->config; - uint16_t accuracy; - - if (!spec) { - return &dev_data->clk_cfg.onoff[0].mgr; - } + uint16_t req_accuracy; - if (spec->frequency > dev_config->fixed_frequency) { + if (req_spec->frequency > dev_config->fixed_frequency) { LOG_ERR("invalid frequency"); - return NULL; + return -EINVAL; } - if (spec->precision) { + if (req_spec->precision) { LOG_ERR("invalid precision"); - return NULL; + return -EINVAL; } - accuracy = spec->accuracy == NRF_CLOCK_CONTROL_ACCURACY_MAX - ? FLL16M_MAX_ACCURACY - : spec->accuracy; + req_accuracy = req_spec->accuracy == NRF_CLOCK_CONTROL_ACCURACY_MAX + ? FLL16M_MAX_ACCURACY + : req_spec->accuracy; for (int i = 0; i < ARRAY_SIZE(clock_options); ++i) { - if (accuracy && - accuracy < clock_options[i].accuracy) { + if (req_accuracy && + req_accuracy < clock_options[i].accuracy) { continue; } - return &dev_data->clk_cfg.onoff[i].mgr; + return i; } LOG_ERR("invalid accuracy"); - return NULL; + return -EINVAL; +} + +static void fll16m_get_spec_by_idx(const struct device *dev, + uint8_t idx, + struct nrf_clock_spec *spec) +{ + const struct fll16m_dev_config *dev_config = dev->config; + + spec->frequency = dev_config->fixed_frequency; + spec->accuracy = clock_options[idx].accuracy; + spec->precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT; +} + +static int fll16m_get_startup_time_by_idx(const struct device *dev, + uint8_t idx, + uint32_t *startup_time_us) +{ + const struct fll16m_dev_data *dev_data = dev->data; + uint8_t mode = clock_options[idx].mode; + + switch (mode) { + case FLL16M_MODE_OPEN_LOOP: + *startup_time_us = FLL16M_OPEN_LOOP_STARTUP_TIME_US; + return 0; + + case FLL16M_MODE_BYPASS: + *startup_time_us = dev_data->bypass_startup_time_us; + return 0; + + default: + break; + } + + return -EINVAL; +} + +static struct onoff_manager *fll16m_get_mgr_by_idx(const struct device *dev, uint8_t idx) +{ + struct fll16m_dev_data *dev_data = dev->data; + + return &dev_data->clk_cfg.onoff[idx].mgr; +} + +static struct onoff_manager *fll16m_find_mgr_by_spec(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + int idx; + + if (!spec) { + return fll16m_get_mgr_by_idx(dev, 0); + } + + idx = fll16m_resolve_spec_to_idx(dev, spec); + return idx < 0 ? NULL : fll16m_get_mgr_by_idx(dev, idx); } static int api_request_fll16m(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = fll16m_find_mgr(dev, spec); + struct onoff_manager *mgr = fll16m_find_mgr_by_spec(dev, spec); if (mgr) { return clock_config_request(mgr, cli); @@ -187,7 +238,7 @@ static int api_request_fll16m(const struct device *dev, static int api_release_fll16m(const struct device *dev, const struct nrf_clock_spec *spec) { - struct onoff_manager *mgr = fll16m_find_mgr(dev, spec); + struct onoff_manager *mgr = fll16m_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_release(mgr); @@ -200,7 +251,7 @@ static int api_cancel_or_release_fll16m(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = fll16m_find_mgr(dev, spec); + struct onoff_manager *mgr = fll16m_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_cancel_or_release(mgr, cli); @@ -222,10 +273,45 @@ static int api_get_rate_fll16m(const struct device *dev, return 0; } +static int api_resolve(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ + int idx; + + idx = fll16m_resolve_spec_to_idx(dev, req_spec); + if (idx < 0) { + return -EINVAL; + } + + fll16m_get_spec_by_idx(dev, idx, res_spec); + return 0; +} + +static int api_get_startup_time(const struct device *dev, + const struct nrf_clock_spec *spec, + uint32_t *startup_time_us) +{ + int idx; + + idx = fll16m_resolve_spec_to_idx(dev, spec); + if (idx < 0) { + return -EINVAL; + } + + return fll16m_get_startup_time_by_idx(dev, idx, startup_time_us); +} + static int fll16m_init(const struct device *dev) { struct fll16m_dev_data *dev_data = dev->data; + dev_data->bypass_startup_time_us = nrf_bicr_hfxo_startup_time_us_get(BICR); + if (dev_data->bypass_startup_time_us == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) { + LOG_ERR("BICR HFXO startup time invalid"); + return -ENODEV; + } + return clock_config_init(&dev_data->clk_cfg, ARRAY_SIZE(dev_data->clk_cfg.onoff), fll16m_work_handler); @@ -240,6 +326,8 @@ static DEVICE_API(nrf_clock_control, fll16m_drv_api) = { .request = api_request_fll16m, .release = api_release_fll16m, .cancel_or_release = api_cancel_or_release_fll16m, + .resolve = api_resolve, + .get_startup_time = api_get_startup_time, }; static struct fll16m_dev_data fll16m_data; diff --git a/drivers/clock_control/clock_control_nrf2_global_hsfll.c b/drivers/clock_control/clock_control_nrf_hsfll_global.c similarity index 78% rename from drivers/clock_control/clock_control_nrf2_global_hsfll.c rename to drivers/clock_control/clock_control_nrf_hsfll_global.c index 50f3396429c1..605b788b5399 100644 --- a/drivers/clock_control/clock_control_nrf2_global_hsfll.c +++ b/drivers/clock_control/clock_control_nrf_hsfll_global.c @@ -23,10 +23,10 @@ LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL); DT_INST_PROP_LEN(0, supported_clock_frequencies) #define GLOBAL_HSFLL_FREQ_REQ_TIMEOUT \ - K_MSEC(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_TIMEOUT_MS) + K_MSEC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_TIMEOUT_MS) #define GLOBAL_HSFLL_INIT_LOW_REQ \ - CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_REQ_LOW_FREQ + CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_REQ_LOW_FREQ BUILD_ASSERT(GLOBAL_HSFLL_CLOCK_FREQUENCIES_SIZE == 4); BUILD_ASSERT(GLOBAL_HSFLL_CLOCK_FREQUENCIES_IDX(0) == 64000000); @@ -62,43 +62,69 @@ static uint32_t global_hsfll_get_max_clock_frequency(const struct device *dev) return dev_config->clock_frequencies[ARRAY_SIZE(dev_config->clock_frequencies) - 1]; } -static struct onoff_manager *global_hsfll_find_mgr(const struct device *dev, - const struct nrf_clock_spec *spec) +static int global_hsfll_resolve_spec_to_idx(const struct device *dev, + const struct nrf_clock_spec *req_spec) { - struct global_hsfll_dev_data *dev_data = dev->data; const struct global_hsfll_dev_config *dev_config = dev->config; - uint32_t frequency; - - if (!spec) { - return &dev_data->clk_cfg.onoff[0].mgr; - } + uint32_t req_frequency; - if (spec->accuracy || spec->precision) { + if (req_spec->accuracy || req_spec->precision) { LOG_ERR("invalid specification of accuracy or precision"); - return NULL; + return -EINVAL; } - frequency = spec->frequency == NRF_CLOCK_CONTROL_FREQUENCY_MAX - ? global_hsfll_get_max_clock_frequency(dev) - : spec->frequency; + req_frequency = req_spec->frequency == NRF_CLOCK_CONTROL_FREQUENCY_MAX + ? global_hsfll_get_max_clock_frequency(dev) + : req_spec->frequency; for (uint8_t i = 0; i < ARRAY_SIZE(dev_config->clock_frequencies); i++) { - if (dev_config->clock_frequencies[i] < frequency) { + if (dev_config->clock_frequencies[i] < req_frequency) { continue; } - return &dev_data->clk_cfg.onoff[i].mgr; + return i; } LOG_ERR("invalid frequency"); - return NULL; + return -EINVAL; +} + +static void global_hsfll_get_spec_by_idx(const struct device *dev, + uint8_t idx, + struct nrf_clock_spec *spec) +{ + const struct global_hsfll_dev_config *dev_config = dev->config; + + spec->frequency = dev_config->clock_frequencies[idx]; + spec->accuracy = 0; + spec->precision = 0; +} + +static struct onoff_manager *global_hsfll_get_mgr_by_idx(const struct device *dev, uint8_t idx) +{ + struct global_hsfll_dev_data *dev_data = dev->data; + + return &dev_data->clk_cfg.onoff[idx].mgr; +} + +static struct onoff_manager *global_hsfll_find_mgr_by_spec(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + int idx; + + if (!spec) { + return global_hsfll_get_mgr_by_idx(dev, 0); + } + + idx = global_hsfll_resolve_spec_to_idx(dev, spec); + return idx < 0 ? NULL : global_hsfll_get_mgr_by_idx(dev, idx); } static int api_request_global_hsfll(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = global_hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = global_hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return clock_config_request(mgr, cli); @@ -110,7 +136,7 @@ static int api_request_global_hsfll(const struct device *dev, static int api_release_global_hsfll(const struct device *dev, const struct nrf_clock_spec *spec) { - struct onoff_manager *mgr = global_hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = global_hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_release(mgr); @@ -123,7 +149,7 @@ static int api_cancel_or_release_global_hsfll(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = global_hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = global_hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_cancel_or_release(mgr, cli); @@ -132,6 +158,21 @@ static int api_cancel_or_release_global_hsfll(const struct device *dev, return -EINVAL; } +static int api_resolve_global_hsfll(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ + int idx; + + idx = global_hsfll_resolve_spec_to_idx(dev, req_spec); + if (idx < 0) { + return -EINVAL; + } + + global_hsfll_get_spec_by_idx(dev, idx, res_spec); + return 0; +} + static DEVICE_API(nrf_clock_control, driver_api) = { .std_api = { .on = api_nosys_on_off, @@ -140,6 +181,7 @@ static DEVICE_API(nrf_clock_control, driver_api) = { .request = api_request_global_hsfll, .release = api_release_global_hsfll, .cancel_or_release = api_cancel_or_release_global_hsfll, + .resolve = api_resolve_global_hsfll, }; static enum gdfs_frequency_setting global_hsfll_freq_idx_to_nrfs_freq(const struct device *dev, @@ -297,6 +339,6 @@ DEVICE_DT_INST_DEFINE( &driver_data, &driver_config, POST_KERNEL, - CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY, + CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY, &driver_api ); diff --git a/drivers/clock_control/clock_control_nrf2_hsfll.c b/drivers/clock_control/clock_control_nrf_hsfll_local.c similarity index 74% rename from drivers/clock_control/clock_control_nrf2_hsfll.c rename to drivers/clock_control/clock_control_nrf_hsfll_local.c index eb2dfde989c7..942f16ed4447 100644 --- a/drivers/clock_control/clock_control_nrf2_hsfll.c +++ b/drivers/clock_control/clock_control_nrf_hsfll_local.c @@ -25,7 +25,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, #define HSFLL_FREQ_MEDLOW MHZ(128) #define HSFLL_FREQ_HIGH MHZ(320) -#define NRFS_DVFS_TIMEOUT K_MSEC(CONFIG_CLOCK_CONTROL_NRF2_NRFS_DVFS_TIMEOUT_MS) +#define NRFS_DVFS_TIMEOUT K_MSEC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL_NRFS_DVFS_TIMEOUT_MS) /* Clock options sorted from lowest to highest frequency */ static const struct clock_options { @@ -100,35 +100,56 @@ static void hsfll_work_handler(struct k_work *work) k_timer_start(&dev_data->timer, NRFS_DVFS_TIMEOUT, K_NO_WAIT); } -static struct onoff_manager *hsfll_find_mgr(const struct device *dev, - const struct nrf_clock_spec *spec) +static int hsfll_resolve_spec_to_idx(const struct nrf_clock_spec *req_spec) { - struct hsfll_dev_data *dev_data = dev->data; - uint32_t frequency; - - if (!spec) { - return &dev_data->clk_cfg.onoff[0].mgr; - } + uint32_t req_frequency; - if (spec->accuracy || spec->precision) { + if (req_spec->accuracy || req_spec->precision) { LOG_ERR("invalid specification of accuracy or precision"); - return NULL; + return -EINVAL; } - frequency = spec->frequency == NRF_CLOCK_CONTROL_FREQUENCY_MAX - ? HSFLL_FREQ_HIGH - : spec->frequency; + req_frequency = req_spec->frequency == NRF_CLOCK_CONTROL_FREQUENCY_MAX + ? HSFLL_FREQ_HIGH + : req_spec->frequency; for (int i = 0; i < ARRAY_SIZE(clock_options); ++i) { - if (frequency > clock_options[i].frequency) { + if (req_frequency > clock_options[i].frequency) { continue; } - return &dev_data->clk_cfg.onoff[i].mgr; + return i; } LOG_ERR("invalid frequency"); - return NULL; + return -EINVAL; +} + +static void hsfll_get_spec_by_idx(uint8_t idx, struct nrf_clock_spec *spec) +{ + spec->frequency = clock_options[idx].frequency; + spec->accuracy = 0; + spec->precision = 0; +} + +static struct onoff_manager *hsfll_get_mgr_by_idx(const struct device *dev, uint8_t idx) +{ + struct hsfll_dev_data *dev_data = dev->data; + + return &dev_data->clk_cfg.onoff[idx].mgr; +} + +static struct onoff_manager *hsfll_find_mgr_by_spec(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + int idx; + + if (!spec) { + return hsfll_get_mgr_by_idx(dev, 0); + } + + idx = hsfll_resolve_spec_to_idx(spec); + return idx < 0 ? NULL : hsfll_get_mgr_by_idx(dev, idx); } #endif /* CONFIG_NRFS_DVFS_LOCAL_DOMAIN */ @@ -137,7 +158,7 @@ static int api_request_hsfll(const struct device *dev, struct onoff_client *cli) { #ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN - struct onoff_manager *mgr = hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return clock_config_request(mgr, cli); @@ -153,7 +174,7 @@ static int api_release_hsfll(const struct device *dev, const struct nrf_clock_spec *spec) { #ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN - struct onoff_manager *mgr = hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_release(mgr); @@ -170,7 +191,7 @@ static int api_cancel_or_release_hsfll(const struct device *dev, struct onoff_client *cli) { #ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN - struct onoff_manager *mgr = hsfll_find_mgr(dev, spec); + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_cancel_or_release(mgr, cli); @@ -182,6 +203,25 @@ static int api_cancel_or_release_hsfll(const struct device *dev, #endif } +static int api_resolve_hsfll(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ +#ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN + int idx; + + idx = hsfll_resolve_spec_to_idx(req_spec); + if (idx < 0) { + return -EINVAL; + } + + hsfll_get_spec_by_idx(idx, res_spec); + return 0; +#else + return -ENOTSUP; +#endif +} + static int hsfll_init(const struct device *dev) { #ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN @@ -212,16 +252,17 @@ static DEVICE_API(nrf_clock_control, hsfll_drv_api) = { .request = api_request_hsfll, .release = api_release_hsfll, .cancel_or_release = api_cancel_or_release_hsfll, + .resolve = api_resolve_hsfll, }; #ifdef CONFIG_NRFS_DVFS_LOCAL_DOMAIN static struct hsfll_dev_data hsfll_data; #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF2_HSFLL_REQ_LOW_FREQ +#ifdef CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL_REQ_LOW_FREQ static int dvfs_low_init(void) { - static const k_timeout_t timeout = K_MSEC(CONFIG_CLOCK_CONTROL_NRF2_NRFS_DVFS_TIMEOUT_MS); + static const k_timeout_t timeout = NRFS_DVFS_TIMEOUT; static const struct device *hsfll_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_NODELABEL(cpu))); static const struct nrf_clock_spec clk_spec = { .frequency = HSFLL_FREQ_LOW diff --git a/drivers/clock_control/clock_control_nrf_iron_hsfll_local.c b/drivers/clock_control/clock_control_nrf_iron_hsfll_local.c new file mode 100644 index 000000000000..78bec1d839e0 --- /dev/null +++ b/drivers/clock_control/clock_control_nrf_iron_hsfll_local.c @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT nordic_nrf_iron_hsfll_local + +#include "clock_control_nrf2_common.h" +#include +#include + +#include +LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL); + +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, "multiple instances not supported"); + +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE +#include + +#define HSFLL_FREQ_LOW MHZ(64) +#define HSFLL_FREQ_MEDLOW MHZ(128) +#define HSFLL_FREQ_HIGH MHZ(320) + +#define IRONSIDE_DVFS_TIMEOUT K_MSEC(CONFIG_CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_DVFS_TIMEOUT_MS) + +/* Clock options sorted from lowest to highest frequency */ +static const struct clock_options { + uint32_t frequency; + enum ironside_dvfs_oppoint setting; +} clock_options[] = { + { + .frequency = HSFLL_FREQ_LOW, + .setting = IRONSIDE_DVFS_OPP_LOW, + }, + { + .frequency = HSFLL_FREQ_MEDLOW, + .setting = IRONSIDE_DVFS_OPP_MEDLOW, + }, + { + .frequency = HSFLL_FREQ_HIGH, + .setting = IRONSIDE_DVFS_OPP_HIGH, + }, +}; + +struct hsfll_dev_data { + STRUCT_CLOCK_CONFIG(hsfll, ARRAY_SIZE(clock_options)) clk_cfg; + struct k_timer timer; +}; + +static void hsfll_update_timeout_handler(struct k_timer *timer) +{ + struct hsfll_dev_data *dev_data = CONTAINER_OF(timer, struct hsfll_dev_data, timer); + + clock_config_update_end(&dev_data->clk_cfg, -ETIMEDOUT); +} + +static void hsfll_work_handler(struct k_work *work) +{ + struct hsfll_dev_data *dev_data = CONTAINER_OF(work, struct hsfll_dev_data, clk_cfg.work); + enum ironside_dvfs_oppoint required_setting; + uint8_t to_activate_idx; + int rc; + + to_activate_idx = clock_config_update_begin(work); + required_setting = clock_options[to_activate_idx].setting; + + k_timer_start(&dev_data->timer, IRONSIDE_DVFS_TIMEOUT, K_NO_WAIT); + + /* Request the DVFS service to change the OPP point. */ + rc = ironside_dvfs_change_oppoint(required_setting); + k_timer_stop(&dev_data->timer); + clock_config_update_end(&dev_data->clk_cfg, rc); +} + +static int hsfll_resolve_spec_to_idx(const struct nrf_clock_spec *req_spec) +{ + uint32_t req_frequency; + + if (req_spec->accuracy || req_spec->precision) { + LOG_ERR("invalid specification of accuracy or precision"); + return -EINVAL; + } + + req_frequency = req_spec->frequency == NRF_CLOCK_CONTROL_FREQUENCY_MAX + ? HSFLL_FREQ_HIGH + : req_spec->frequency; + + for (int i = 0; i < ARRAY_SIZE(clock_options); ++i) { + if (req_frequency > clock_options[i].frequency) { + continue; + } + + return i; + } + + LOG_ERR("invalid frequency"); + return -EINVAL; +} + +static void hsfll_get_spec_by_idx(uint8_t idx, struct nrf_clock_spec *spec) +{ + spec->frequency = clock_options[idx].frequency; + spec->accuracy = 0; + spec->precision = 0; +} + +static struct onoff_manager *hsfll_get_mgr_by_idx(const struct device *dev, uint8_t idx) +{ + struct hsfll_dev_data *dev_data = dev->data; + + return &dev_data->clk_cfg.onoff[idx].mgr; +} + +static struct onoff_manager *hsfll_find_mgr_by_spec(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + int idx; + + if (!spec) { + return hsfll_get_mgr_by_idx(dev, 0); + } + + idx = hsfll_resolve_spec_to_idx(spec); + return idx < 0 ? NULL : hsfll_get_mgr_by_idx(dev, idx); +} +#endif /* CONFIG_NRF_IRONSIDE_DVFS_SERVICE */ + +static int api_request_hsfll(const struct device *dev, const struct nrf_clock_spec *spec, + struct onoff_client *cli) +{ +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); + + if (mgr) { + return clock_config_request(mgr, cli); + } + + return -EINVAL; +#else + return -ENOTSUP; +#endif +} + +static int api_release_hsfll(const struct device *dev, const struct nrf_clock_spec *spec) +{ +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); + + if (mgr) { + return onoff_release(mgr); + } + + return -EINVAL; +#else + return -ENOTSUP; +#endif +} + +static int api_cancel_or_release_hsfll(const struct device *dev, const struct nrf_clock_spec *spec, + struct onoff_client *cli) +{ +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE + struct onoff_manager *mgr = hsfll_find_mgr_by_spec(dev, spec); + + if (mgr) { + return onoff_cancel_or_release(mgr, cli); + } + + return -EINVAL; +#else + return -ENOTSUP; +#endif +} + +static int api_resolve_hsfll(const struct device *dev, const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE + int idx; + + idx = hsfll_resolve_spec_to_idx(req_spec); + if (idx < 0) { + return -EINVAL; + } + + hsfll_get_spec_by_idx(idx, res_spec); + return 0; +#else + return -ENOTSUP; +#endif +} + +static int hsfll_init(const struct device *dev) +{ +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE + struct hsfll_dev_data *dev_data = dev->data; + int rc; + + rc = clock_config_init(&dev_data->clk_cfg, ARRAY_SIZE(dev_data->clk_cfg.onoff), + hsfll_work_handler); + if (rc < 0) { + return rc; + } + + k_timer_init(&dev_data->timer, hsfll_update_timeout_handler, NULL); + +#endif + + return 0; +} + +static DEVICE_API(nrf_clock_control, hsfll_drv_api) = { + .std_api = { + .on = api_nosys_on_off, + .off = api_nosys_on_off, + }, + .request = api_request_hsfll, + .release = api_release_hsfll, + .cancel_or_release = api_cancel_or_release_hsfll, + .resolve = api_resolve_hsfll, +}; + +#ifdef CONFIG_NRF_IRONSIDE_DVFS_SERVICE +static struct hsfll_dev_data hsfll_data; +#endif + +#ifdef CONFIG_CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_REQ_LOW_FREQ +static int dvfs_low_init(void) +{ + static const k_timeout_t timeout = IRONSIDE_DVFS_TIMEOUT; + static const struct device *hsfll_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_NODELABEL(cpu))); + static const struct nrf_clock_spec clk_spec = {.frequency = HSFLL_FREQ_LOW}; + + return nrf_clock_control_request_sync(hsfll_dev, &clk_spec, timeout); +} + +SYS_INIT(dvfs_low_init, APPLICATION, 0); +#endif + +DEVICE_DT_INST_DEFINE(0, hsfll_init, NULL, + COND_CODE_1(CONFIG_NRF_IRONSIDE_DVFS_SERVICE, + (&hsfll_data), + (NULL)), NULL, PRE_KERNEL_1, + CONFIG_CLOCK_CONTROL_INIT_PRIORITY, &hsfll_drv_api); diff --git a/drivers/clock_control/clock_control_nrf2_lfclk.c b/drivers/clock_control/clock_control_nrf_lfclk.c similarity index 60% rename from drivers/clock_control/clock_control_nrf2_lfclk.c rename to drivers/clock_control/clock_control_nrf_lfclk.c index c5f70c1497ba..829416f662cb 100644 --- a/drivers/clock_control/clock_control_nrf2_lfclk.c +++ b/drivers/clock_control/clock_control_nrf_lfclk.c @@ -22,11 +22,13 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, #define LFCLK_LFLPRC_ACCURACY DT_INST_PROP(0, lflprc_accuracy_ppm) #define LFCLK_LFRC_ACCURACY DT_INST_PROP(0, lfrc_accuracy_ppm) #define LFCLK_HFXO_ACCURACY DT_PROP(LFCLK_HFXO_NODE, accuracy_ppm) +#define LFCLK_LFLPRC_STARTUP_TIME_US DT_INST_PROP(0, lflprc_startup_time_us) +#define LFCLK_LFRC_STARTUP_TIME_US DT_INST_PROP(0, lfrc_startup_time_us) #define LFCLK_MAX_OPTS 5 #define LFCLK_DEF_OPTS 3 -#define NRFS_CLOCK_TIMEOUT K_MSEC(CONFIG_CLOCK_CONTROL_NRF2_NRFS_CLOCK_TIMEOUT_MS) +#define NRFS_CLOCK_TIMEOUT K_MSEC(CONFIG_CLOCK_CONTROL_NRF_LFCLK_CLOCK_TIMEOUT_MS) #define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr)) @@ -59,12 +61,48 @@ struct lfclk_dev_data { struct k_timer timer; uint16_t max_accuracy; uint8_t clock_options_cnt; + uint32_t hfxo_startup_time_us; + uint32_t lfxo_startup_time_us; }; struct lfclk_dev_config { uint32_t fixed_frequency; }; +static int lfosc_get_accuracy(uint16_t *accuracy) +{ + switch (nrf_bicr_lfosc_accuracy_get(BICR)) { + case NRF_BICR_LFOSC_ACCURACY_500PPM: + *accuracy = 500U; + break; + case NRF_BICR_LFOSC_ACCURACY_250PPM: + *accuracy = 250U; + break; + case NRF_BICR_LFOSC_ACCURACY_150PPM: + *accuracy = 150U; + break; + case NRF_BICR_LFOSC_ACCURACY_100PPM: + *accuracy = 100U; + break; + case NRF_BICR_LFOSC_ACCURACY_75PPM: + *accuracy = 75U; + break; + case NRF_BICR_LFOSC_ACCURACY_50PPM: + *accuracy = 50U; + break; + case NRF_BICR_LFOSC_ACCURACY_30PPM: + *accuracy = 30U; + break; + case NRF_BICR_LFOSC_ACCURACY_20PPM: + *accuracy = 20U; + break; + default: + return -EINVAL; + } + + return 0; +} + static void clock_evt_handler(nrfs_clock_evt_t const *p_evt, void *context) { struct lfclk_dev_data *dev_data = context; @@ -105,45 +143,108 @@ static void lfclk_work_handler(struct k_work *work) } } -static struct onoff_manager *lfclk_find_mgr(const struct device *dev, - const struct nrf_clock_spec *spec) +static int lfclk_resolve_spec_to_idx(const struct device *dev, + const struct nrf_clock_spec *req_spec) { struct lfclk_dev_data *dev_data = dev->data; const struct lfclk_dev_config *dev_config = dev->config; - uint16_t accuracy; + uint16_t req_accuracy; - if (!spec) { - return &dev_data->clk_cfg.onoff[0].mgr; - } - - if (spec->frequency > dev_config->fixed_frequency) { + if (req_spec->frequency > dev_config->fixed_frequency) { LOG_ERR("invalid frequency"); - return NULL; + return -EINVAL; } - accuracy = spec->accuracy == NRF_CLOCK_CONTROL_ACCURACY_MAX - ? dev_data->max_accuracy - : spec->accuracy; + req_accuracy = req_spec->accuracy == NRF_CLOCK_CONTROL_ACCURACY_MAX + ? dev_data->max_accuracy + : req_spec->accuracy; for (int i = 0; i < dev_data->clock_options_cnt; ++i) { - if ((accuracy && - accuracy < clock_options[i].accuracy) || - spec->precision > clock_options[i].precision) { + if ((req_accuracy && + req_accuracy < clock_options[i].accuracy) || + req_spec->precision > clock_options[i].precision) { continue; } - return &dev_data->clk_cfg.onoff[i].mgr; + return i; } LOG_ERR("invalid accuracy or precision"); - return NULL; + return -EINVAL; +} + +static void lfclk_get_spec_by_idx(const struct device *dev, + uint8_t idx, + struct nrf_clock_spec *spec) +{ + const struct lfclk_dev_config *dev_config = dev->config; + + spec->frequency = dev_config->fixed_frequency; + spec->accuracy = clock_options[idx].accuracy; + spec->precision = clock_options[idx].precision; +} + +static struct onoff_manager *lfclk_get_mgr_by_idx(const struct device *dev, uint8_t idx) +{ + struct lfclk_dev_data *dev_data = dev->data; + + return &dev_data->clk_cfg.onoff[idx].mgr; +} + +static int lfclk_get_startup_time_by_idx(const struct device *dev, + uint8_t idx, + uint32_t *startup_time_us) +{ + struct lfclk_dev_data *dev_data = dev->data; + nrfs_clock_src_t src = clock_options[idx].src; + + switch (src) { + case NRFS_CLOCK_SRC_LFCLK_LFLPRC: + *startup_time_us = LFCLK_LFLPRC_STARTUP_TIME_US; + return 0; + + case NRFS_CLOCK_SRC_LFCLK_LFRC: + *startup_time_us = LFCLK_LFRC_STARTUP_TIME_US; + return 0; + + case NRFS_CLOCK_SRC_LFCLK_XO_PIXO: + case NRFS_CLOCK_SRC_LFCLK_XO_PIERCE: + case NRFS_CLOCK_SRC_LFCLK_XO_EXT_SINE: + case NRFS_CLOCK_SRC_LFCLK_XO_EXT_SQUARE: + case NRFS_CLOCK_SRC_LFCLK_XO_PIERCE_HP: + case NRFS_CLOCK_SRC_LFCLK_XO_EXT_SINE_HP: + *startup_time_us = dev_data->lfxo_startup_time_us; + return 0; + + case NRFS_CLOCK_SRC_LFCLK_SYNTH: + *startup_time_us = dev_data->hfxo_startup_time_us; + return 0; + + default: + break; + } + + return -EINVAL; +} + +static struct onoff_manager *lfclk_find_mgr_by_spec(const struct device *dev, + const struct nrf_clock_spec *spec) +{ + int idx; + + if (!spec) { + return lfclk_get_mgr_by_idx(dev, 0); + } + + idx = lfclk_resolve_spec_to_idx(dev, spec); + return idx < 0 ? NULL : lfclk_get_mgr_by_idx(dev, idx); } static int api_request_lfclk(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = lfclk_find_mgr(dev, spec); + struct onoff_manager *mgr = lfclk_find_mgr_by_spec(dev, spec); if (mgr) { return clock_config_request(mgr, cli); @@ -155,7 +256,7 @@ static int api_request_lfclk(const struct device *dev, static int api_release_lfclk(const struct device *dev, const struct nrf_clock_spec *spec) { - struct onoff_manager *mgr = lfclk_find_mgr(dev, spec); + struct onoff_manager *mgr = lfclk_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_release(mgr); @@ -168,7 +269,7 @@ static int api_cancel_or_release_lfclk(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli) { - struct onoff_manager *mgr = lfclk_find_mgr(dev, spec); + struct onoff_manager *mgr = lfclk_find_mgr_by_spec(dev, spec); if (mgr) { return onoff_cancel_or_release(mgr, cli); @@ -177,6 +278,36 @@ static int api_cancel_or_release_lfclk(const struct device *dev, return -EINVAL; } + +static int api_resolve(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ + int idx; + + idx = lfclk_resolve_spec_to_idx(dev, req_spec); + if (idx < 0) { + return -EINVAL; + } + + lfclk_get_spec_by_idx(dev, idx, res_spec); + return 0; +} + +static int api_get_startup_time(const struct device *dev, + const struct nrf_clock_spec *spec, + uint32_t *startup_time_us) +{ + int idx; + + idx = lfclk_resolve_spec_to_idx(dev, spec); + if (idx < 0) { + return -EINVAL; + } + + return lfclk_get_startup_time_by_idx(dev, idx, startup_time_us); +} + static int api_get_rate_lfclk(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate) @@ -251,6 +382,19 @@ static int lfclk_init(const struct device *dev) LOG_ERR("Unexpected LFOSC mode"); return -EINVAL; } + + dev_data->lfxo_startup_time_us = nrf_bicr_lfosc_startup_time_ms_get(BICR) + * USEC_PER_MSEC; + if (dev_data->lfxo_startup_time_us == NRF_BICR_LFOSC_STARTUP_TIME_UNCONFIGURED) { + LOG_ERR("BICR LFXO startup time invalid"); + return -ENODEV; + } + } + + dev_data->hfxo_startup_time_us = nrf_bicr_hfxo_startup_time_us_get(BICR); + if (dev_data->hfxo_startup_time_us == NRF_BICR_HFXO_STARTUP_TIME_UNCONFIGURED) { + LOG_ERR("BICR HFXO startup time invalid"); + return -ENODEV; } k_timer_init(&dev_data->timer, lfclk_update_timeout_handler, NULL); @@ -269,6 +413,8 @@ static DEVICE_API(nrf_clock_control, lfclk_drv_api) = { .request = api_request_lfclk, .release = api_release_lfclk, .cancel_or_release = api_cancel_or_release_lfclk, + .resolve = api_resolve, + .get_startup_time = api_get_startup_time, }; static struct lfclk_dev_data lfclk_data; diff --git a/drivers/clock_control/clock_control_nrf2_audiopll.c b/drivers/clock_control/clock_control_nrfs_audiopll.c similarity index 100% rename from drivers/clock_control/clock_control_nrf2_audiopll.c rename to drivers/clock_control/clock_control_nrfs_audiopll.c diff --git a/drivers/comparator/comparator_nrf_common.h b/drivers/comparator/comparator_nrf_common.h index c45e6676e2d8..e86fc9f63692 100644 --- a/drivers/comparator/comparator_nrf_common.h +++ b/drivers/comparator/comparator_nrf_common.h @@ -28,7 +28,7 @@ static const uint32_t shim_nrf_comp_ain_map[] = { NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1), -#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#elif defined(NRF54LM20A_ENGA_XXAA) NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(31U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(30U, 1), @@ -37,6 +37,15 @@ static const uint32_t shim_nrf_comp_ain_map[] = { NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1), NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1), +#elif defined(NRF54LV10A_ENGA_XXAA) + NRF_PIN_PORT_TO_PIN_NUMBER(0U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(1U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(2U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(3U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(10U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1), + NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1), #endif }; #endif diff --git a/drivers/counter/Kconfig.nrfx b/drivers/counter/Kconfig.nrfx index 775406a5198c..ed02411de261 100644 --- a/drivers/counter/Kconfig.nrfx +++ b/drivers/counter/Kconfig.nrfx @@ -12,7 +12,8 @@ config COUNTER_NRF_RTC config COUNTER_NRFX_TIMER_USE_CLOCK_CONTROL def_bool y depends on $(dt_nodelabel_enabled,timer120) || \ - $(dt_nodelabel_enabled,timer121) + $(dt_nodelabel_enabled,timer121) + depends on !SOC_NRF54H20_CPUFLPR && !SOC_NRF54H20_CPUPPR select CLOCK_CONTROL # Internal flag which detects if PPI wrap feature is enabled for any instance diff --git a/drivers/counter/counter_nrfx_timer.c b/drivers/counter/counter_nrfx_timer.c index 52e525717a9b..71f7f7edd331 100644 --- a/drivers/counter/counter_nrfx_timer.c +++ b/drivers/counter/counter_nrfx_timer.c @@ -481,7 +481,7 @@ static DEVICE_API(counter, counter_nrfx_driver_api) = { */ #define TIMER_INIT_PRIO(idx) \ COND_CODE_1(INSTANCE_IS_FAST(idx), \ - (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY)), \ + (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \ (CONFIG_COUNTER_INIT_PRIORITY)) /* diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 1ac3d15ba62f..4d8e3f1eee01 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -469,6 +469,8 @@ static const struct disk_operations flash_disk_ops = { .ioctl = disk_flash_access_ioctl, }; +#ifndef USE_PARTITION_MANAGER +/* The non-Partition manager, DTS based generators below */ #define DT_DRV_COMPAT zephyr_flash_disk #define PARTITION_PHANDLE(n) DT_PHANDLE_BY_IDX(DT_DRV_INST(n), partition, 0) @@ -510,6 +512,82 @@ DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) "Devicetree node " DT_NODE_PATH(DT_DRV_INST(n)) \ " has cache size which is not a multiple of its sector size"); DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#else /* ifndef USE_PARTITION_MANAGER */ +/* Partition Manager based generators below */ + +/* Gets the PM_..._EXTRA_PARAM_##param value */ +#define PM_FLASH_DISK_ENTRY_EXTRA_PARAM(name, param) PM_##name##_EXTRA_PARAM_disk_##param + +/* Gets the PM_..._NAME value which is originally cased, as in yaml, partition name */ +#define PM_FLASH_DISK_ENTRY_PARTITION_NAME(name) PM_##name##_NAME + +/* Generates flashdiskN_cache variable name, where N is partition ID */ +#define PM_FLASH_DISK_CACHE_VARIABLE(n) UTIL_CAT(flashdisk, UTIL_CAT(FIXED_PARTITION_ID(n), _cache)) + +/* Generate cache buffers */ +#define CACHE_SIZE(n) (COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), (0), (1)) * \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size)) +#define DEFINE_FLASHDISKS_CACHE(n) \ + static uint8_t __aligned(4) PM_FLASH_DISK_CACHE_VARIABLE(n)[CACHE_SIZE(n)]; + +PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE) + +/* Generated single Flash Disk device data from Partition Manager partition. + * Partition is required to have type set to disk in partition definitions: + * type: disk + * and following extra params can be provided: + * extra_params: { + * name = "", + * cache_size = , + * sector_size = , + * read_only = + * } + * where: + * is mandatory device name that will be used by Disk Access and FAT FS to mount device; + * is cache r/w cache size, which is mandatory if read_only = 0 or not present, + * and should be multiple of ; + * is mandatory device sector size information, usually should be erase page size, + * for flash devices, for example 4096 bytes; + * read_only is optional, if not present then assumed false; can be 0(false) or 1(true). + */ +#define DEFINE_FLASHDISKS_DEVICE(n) \ +{ \ + .info = { \ + .ops = &flash_disk_ops, \ + .name = STRINGIFY(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, name)), \ + }, \ + .area_id = FIXED_PARTITION_ID(n), \ + .offset = FIXED_PARTITION_OFFSET(n), \ + .cache = PM_FLASH_DISK_CACHE_VARIABLE(n), \ + .cache_size = sizeof(PM_FLASH_DISK_CACHE_VARIABLE(n)), \ + .size = FIXED_PARTITION_SIZE(n), \ + .sector_size = PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size), \ +}, + +/* The bellow used PM_FOREACH_TYPE_disk is generated by Partition Manager foreach + * loop macro. The lower case _disk is type name for which the macro has been generated; + * partition entry can have multiple types set and foreach macro will be generated + * for every type found across partition definitions. + */ +static struct flashdisk_data flash_disks[] = { + PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE) +}; + +#define VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY(n) \ + COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), \ + (/* cache-size is not used for read-only disks */), \ + (BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) != 0, \ + "Flash disk partition " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n))\ + " must have non-zero cache-size");)) +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) + +#define VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE(n) \ + BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) % \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size) == 0, \ + "Devicetree node " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n)) \ + " has cache size which is not a multiple of its sector size"); +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#endif /* USE_PARTITION_MANAGER */ static int disk_flash_init(void) { diff --git a/drivers/entropy/CMakeLists.txt b/drivers/entropy/CMakeLists.txt index eaf858add89b..e038bbfe1b65 100644 --- a/drivers/entropy/CMakeLists.txt +++ b/drivers/entropy/CMakeLists.txt @@ -45,4 +45,11 @@ zephyr_library_sources_ifdef(CONFIG_ENTROPY_SY1XX_TRNG entropy_sy1xx_tr zephyr_library_sources_ifdef(CONFIG_ENTROPY_TELINK_B91_TRNG entropy_b91_trng.c) # zephyr-keep-sorted-stop +if (CONFIG_FAKE_ENTROPY_NRF_PRNG) + zephyr_library_sources(fake_entropy_nrf_prng.c) + + message(WARNING "\nA nRF PRNG is used, which does not produce real random bits." + "This is not secure and should therefore never be used in a product.") +endif() + zephyr_library_link_libraries_ifdef(CONFIG_BUILD_WITH_TFM tfm_api) diff --git a/drivers/entropy/Kconfig b/drivers/entropy/Kconfig index e0a2080b343b..c52ac96e6bfc 100644 --- a/drivers/entropy/Kconfig +++ b/drivers/entropy/Kconfig @@ -36,6 +36,7 @@ source "drivers/entropy/Kconfig.neorv32" source "drivers/entropy/Kconfig.npcx" source "drivers/entropy/Kconfig.nrf5" source "drivers/entropy/Kconfig.nrf_cracen" +source "drivers/entropy/Kconfig.nrf_prng" source "drivers/entropy/Kconfig.nxp" source "drivers/entropy/Kconfig.psa_crypto" source "drivers/entropy/Kconfig.renesas_ra" diff --git a/drivers/entropy/Kconfig.nrf_prng b/drivers/entropy/Kconfig.nrf_prng new file mode 100644 index 000000000000..e81db4de4b15 --- /dev/null +++ b/drivers/entropy/Kconfig.nrf_prng @@ -0,0 +1,19 @@ +# nRF fake entropy prng generator driver configuration + +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if ENTROPY_GENERATOR + +config FAKE_ENTROPY_NRF_PRNG + bool "A fake nRF entropy driver" + default y + depends on DT_HAS_NORDIC_ENTROPY_PRNG_ENABLED + depends on (SOC_SERIES_NRF54HX || SOC_SERIES_NRF92X || SOC_SERIES_NRF54LX) + select ENTROPY_HAS_DRIVER + help + This is a super simple PRNG driver that can be used on nRF platforms that + do not have an entropy source. + This is NOT SAFE to use for cryptographic operations! + +endif diff --git a/drivers/entropy/Kconfig.psa_crypto b/drivers/entropy/Kconfig.psa_crypto index d06001225b05..18514a071d1c 100644 --- a/drivers/entropy/Kconfig.psa_crypto +++ b/drivers/entropy/Kconfig.psa_crypto @@ -7,6 +7,7 @@ config ENTROPY_PSA_CRYPTO_RNG bool "PSA Crypto Random source Entropy driver" depends on DT_HAS_ZEPHYR_PSA_CRYPTO_RNG_ENABLED select ENTROPY_HAS_DRIVER + select PSA_WANT_GENERATE_RANDOM default y help Enable the PSA Crypto source Entropy driver. diff --git a/drivers/entropy/fake_entropy_nrf_prng.c b/drivers/entropy/fake_entropy_nrf_prng.c new file mode 100644 index 000000000000..8624c8444057 --- /dev/null +++ b/drivers/entropy/fake_entropy_nrf_prng.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#define DT_DRV_COMPAT nordic_entropy_prng + +/* This file implements a pseudo-RNG + * https://vigna.di.unimi.it/xorshift/xoshiro128plus.c + */ + +static uint32_t s[4]; + +static inline uint32_t rotl(const uint32_t x, int k) +{ + return (x << k) | (x >> (32 - k)); +} + +static uint32_t rng_next(void) +{ + const uint32_t result = rotl(s[0] + s[3], 7) + s[0]; + + const uint32_t t = s[1] << 9; + + s[2] ^= s[0]; + s[3] ^= s[1]; + s[1] ^= s[2]; + s[0] ^= s[3]; + + s[2] ^= t; + + s[3] = rotl(s[3], 11); + + return result; +} + +static int entropy_prng_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length) +{ + ARG_UNUSED(dev); + + while (length) { + /* + * Note that only 1 thread (Zephyr thread or HW models), runs at + * a time, therefore there is no need to use random_r() + */ + uint32_t value = rng_next(); + + size_t to_copy = MIN(length, sizeof(long)); + + memcpy(buffer, &value, to_copy); + buffer += to_copy; + length -= to_copy; + } + + return 0; +} + +static int entropy_prng_get_entropy_isr(const struct device *dev, uint8_t *buf, uint16_t len, + uint32_t flags) +{ + ARG_UNUSED(flags); + + int err; + + /* + * entropy_prng_get_entropy() is also safe for ISRs + * and always produces data. + */ + err = entropy_prng_get_entropy(dev, buf, len); + if (err < 0) { + return err; + } else { + return len; + } +} + +static int entropy_prng_init(const struct device *dev) +{ + ARG_UNUSED(dev); + + /* Picked some arbitrary initial seed. */ + s[0] = 0xAF568BC0; + s[1] = 0xAC34307E; + s[2] = 0x9B7F6DD1; + s[3] = 0xD84319FC; + return 0; +} + +static const struct entropy_driver_api entropy_prng_api_funcs = { + .get_entropy = entropy_prng_get_entropy, .get_entropy_isr = entropy_prng_get_entropy_isr}; + +DEVICE_DT_INST_DEFINE(0, entropy_prng_init, NULL, NULL, NULL, PRE_KERNEL_1, + CONFIG_ENTROPY_INIT_PRIORITY, &entropy_prng_api_funcs); diff --git a/drivers/firmware/nrf_ironside/CMakeLists.txt b/drivers/firmware/nrf_ironside/CMakeLists.txt index bc2adf842edc..093cd531f071 100644 --- a/drivers/firmware/nrf_ironside/CMakeLists.txt +++ b/drivers/firmware/nrf_ironside/CMakeLists.txt @@ -7,4 +7,6 @@ zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_CALL call.c) zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_BOOT_REPORT boot_report.c) zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_CPUCONF_SERVICE cpuconf.c) +zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_TDD_SERVICE tdd.c) zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_UPDATE_SERVICE update.c) +zephyr_library_sources_ifdef(CONFIG_NRF_IRONSIDE_DVFS_SERVICE dvfs.c) diff --git a/drivers/firmware/nrf_ironside/Kconfig b/drivers/firmware/nrf_ironside/Kconfig index e009df4df058..8de3380e21c4 100644 --- a/drivers/firmware/nrf_ironside/Kconfig +++ b/drivers/firmware/nrf_ironside/Kconfig @@ -3,9 +3,9 @@ config NRF_IRONSIDE bool - depends on SOC_NRF54H20_IRON + depends on SOC_NRF54H20 || SOC_NRF9280_IRON help - This is selected by drivers interacting with Nordic IRONside firmware. + This is selected by drivers interacting with Nordic IronSide firmware. config NRF_IRONSIDE_CALL bool @@ -14,40 +14,63 @@ config NRF_IRONSIDE_CALL select EVENTS select MBOX help - This is selected by features that require support for IRONside calls. + This is selected by features that require support for IronSide calls. if NRF_IRONSIDE_CALL config NRF_IRONSIDE_CALL_INIT_PRIORITY - int "IRONside calls' initialization priority" + int "IronSide calls' initialization priority" default 41 help - Initialization priority of IRONside calls. It must be below MBOX_INIT_PRIORITY, + Initialization priority of IronSide calls. It must be below MBOX_INIT_PRIORITY, but higher than the priority of any feature that selects NRF_IRONSIDE_CALL. endif # NRF_IRONSIDE_CALL -menu "Nordic IRONside services" - depends on SOC_NRF54H20_IRON +menu "Nordic IronSide services" + depends on SOC_NRF54H20 || SOC_NRF9280_IRON config NRF_IRONSIDE_CPUCONF_SERVICE - bool "IRONside CPUCONF service" - depends on SOC_NRF54H20_CPUAPP + bool "IronSide CPUCONF service" + depends on SOC_NRF54H20_CPUAPP || SOC_NRF9280_CPUAPP select NRF_IRONSIDE_CALL help Service used to boot local domain cores. +config NRF_IRONSIDE_TDD_SERVICE + bool "IRONside tdd service" + select NRF_IRONSIDE_CALL + help + Service used to control the trace and debug domain. + config NRF_IRONSIDE_UPDATE_SERVICE - bool "IRONside update service" + bool "IronSide update service" select NRF_IRONSIDE_CALL help - Service used to update the IRONside SE firmware. + Service used to update the IronSide SE firmware. config NRF_IRONSIDE_BOOT_REPORT - bool "IRONside boot report" + bool "IronSide boot report" depends on $(dt_nodelabel_exists,ironside_se_boot_report) select NRF_IRONSIDE help - Support for parsing the Boot Report populated by Nordic IRONside firmware. + Support for parsing the Boot Report populated by Nordic IronSide firmware. + +config NRF_IRONSIDE_DVFS_SERVICE + bool "IronSide DVFS service" + depends on SOC_NRF54H20_CPUAPP + select NRF_IRONSIDE_CALL + help + Service used to handle DVFS operating point requests. + +if NRF_IRONSIDE_DVFS_SERVICE + +config NRF_IRONSIDE_DVFS_OPPOINT_CHANGE_MUTEX_TIMEOUT_MS + int "IRONSside DVFS change oppoint mutex timeout" + default 100 + help + Maximum tiemout when waiting for DVFS oppoint change mutex lock. + +endif # NRF_IRONSIDE_DVFS_SERVICE endmenu diff --git a/drivers/firmware/nrf_ironside/dvfs.c b/drivers/firmware/nrf_ironside/dvfs.c new file mode 100644 index 000000000000..973a7360b6d8 --- /dev/null +++ b/drivers/firmware/nrf_ironside/dvfs.c @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +#include +#include + +static enum ironside_dvfs_oppoint current_dvfs_oppoint = IRONSIDE_DVFS_OPP_HIGH; + +#if defined(CONFIG_SOC_SERIES_NRF54HX) +#define ABB_STATUSANA_LOCKED_L_Pos (0UL) +#define ABB_STATUSANA_LOCKED_L_Msk (0x1UL << ABB_STATUSANA_LOCKED_L_Pos) +#define ABB_STATUSANA_REG_OFFSET (0x102UL) +#else +#error "Unsupported SoC series for IRONside DVFS" +#endif + +struct dvfs_hsfll_data_t { + uint32_t new_f_mult; + uint32_t new_f_trim_entry; + uint32_t max_hsfll_freq; +}; + +static const struct dvfs_hsfll_data_t dvfs_hsfll_data[] = { + /* ABB oppoint 0.8V */ + { + .new_f_mult = 20, + .new_f_trim_entry = 0, + .max_hsfll_freq = 320000000, + }, + /* ABB oppoint 0.6V */ + { + .new_f_mult = 8, + .new_f_trim_entry = 2, + .max_hsfll_freq = 128000000, + }, + /* ABB oppoint 0.5V */ + { + .new_f_mult = 4, + .new_f_trim_entry = 3, + .max_hsfll_freq = 64000000, + }, +}; + +BUILD_ASSERT(ARRAY_SIZE(dvfs_hsfll_data) == (IRONSIDE_DVFS_OPPOINT_COUNT), + "dvfs_hsfll_data size must match number of DVFS oppoints"); + +/** + * @brief Check if the requested oppoint change operation is downscaling. + * + * @param target_freq_setting The target oppoint to check. + * @return true if the current oppoint is higher than the target, false otherwise. + */ +static bool ironside_dvfs_is_downscaling(enum ironside_dvfs_oppoint target_freq_setting) +{ + return current_dvfs_oppoint < target_freq_setting; +} + +/** + * @brief Configure hsfll depending on selected oppoint + * + * @param enum oppoint target operation point + */ +static void ironside_dvfs_configure_hsfll(enum ironside_dvfs_oppoint oppoint) +{ + nrf_hsfll_trim_t hsfll_trim = {}; + uint8_t freq_trim_idx = dvfs_hsfll_data[oppoint].new_f_trim_entry; + +#if defined(NRF_APPLICATION) + hsfll_trim.vsup = NRF_FICR->TRIM.APPLICATION.HSFLL.TRIM.VSUP; + hsfll_trim.coarse = NRF_FICR->TRIM.APPLICATION.HSFLL.TRIM.COARSE[freq_trim_idx]; + hsfll_trim.fine = NRF_FICR->TRIM.APPLICATION.HSFLL.TRIM.FINE[freq_trim_idx]; +#if NRF_HSFLL_HAS_TCOEF_TRIM + hsfll_trim.tcoef = NRF_FICR->TRIM.APPLICATION.HSFLL.TRIM.TCOEF; +#endif +#else +#error "Only application core is supported for DVFS" +#endif + + nrf_hsfll_clkctrl_mult_set(NRF_HSFLL, dvfs_hsfll_data[oppoint].new_f_mult); + nrf_hsfll_trim_set(NRF_HSFLL, &hsfll_trim); + nrf_barrier_w(); + + nrf_hsfll_task_trigger(NRF_HSFLL, NRF_HSFLL_TASK_FREQ_CHANGE); + /* Trigger hsfll task one more time, SEE PAC-4078 */ + nrf_hsfll_task_trigger(NRF_HSFLL, NRF_HSFLL_TASK_FREQ_CHANGE); +} + +/* Function handling steps for DVFS oppoint change. */ +static void ironside_dvfs_prepare_to_scale(enum ironside_dvfs_oppoint dvfs_oppoint) +{ + if (ironside_dvfs_is_downscaling(dvfs_oppoint)) { + ironside_dvfs_configure_hsfll(dvfs_oppoint); + } +} + +/* Update MDK variable which is used by nrfx_coredep_delay_us (k_busy_wait). */ +static void ironside_dvfs_update_core_clock(enum ironside_dvfs_oppoint dvfs_oppoint) +{ + extern uint32_t SystemCoreClock; + + SystemCoreClock = dvfs_hsfll_data[dvfs_oppoint].max_hsfll_freq; +} + +/* Perform scaling finnish procedure. */ +static void ironside_dvfs_change_oppoint_complete(enum ironside_dvfs_oppoint dvfs_oppoint) +{ + if (!ironside_dvfs_is_downscaling(dvfs_oppoint)) { + ironside_dvfs_configure_hsfll(dvfs_oppoint); + } + + current_dvfs_oppoint = dvfs_oppoint; + ironside_dvfs_update_core_clock(dvfs_oppoint); +} + +/** + * @brief Check if ABB analog part is locked. + * + * @param abb Pointer to ABB peripheral. + * + * @return true if ABB is locked, false otherwise. + */ +static inline bool ironside_dvfs_is_abb_locked(NRF_ABB_Type *abb) +{ + /* Check if ABB analog part is locked. */ + /* Temporary workaround until STATUSANA register is visible. */ + volatile const uint32_t *statusana = (uint32_t *)abb + ABB_STATUSANA_REG_OFFSET; + + return ((*statusana & ABB_STATUSANA_LOCKED_L_Msk) != 0); +} + +/** + * @brief Request DVFS oppoint change from IronSide secure domain. + * This function will send a request over IPC to the IronSide secure domain + * This function is synchronous and will return when the request is completed. + * + * @param oppoint @ref enum ironside_dvfs_oppoint + * @return int + */ +static int ironside_dvfs_req_oppoint(enum ironside_dvfs_oppoint oppoint) +{ + int err; + + struct ironside_call_buf *const buf = ironside_call_alloc(); + + buf->id = IRONSIDE_CALL_ID_DVFS_SERVICE_V0; + buf->args[IRONSIDE_DVFS_SERVICE_OPPOINT_IDX] = oppoint; + + ironside_call_dispatch(buf); + + if (buf->status == IRONSIDE_CALL_STATUS_RSP_SUCCESS) { + err = buf->args[IRONSIDE_DVFS_SERVICE_RETCODE_IDX]; + } else { + err = buf->status; + } + + ironside_call_release(buf); + + return err; +} + +int ironside_dvfs_change_oppoint(enum ironside_dvfs_oppoint dvfs_oppoint) +{ + int status = 0; + + if (!ironside_dvfs_is_oppoint_valid(dvfs_oppoint)) { + return -IRONSIDE_DVFS_ERROR_WRONG_OPPOINT; + } + + if (!ironside_dvfs_is_abb_locked(NRF_ABB)) { + return -IRONSIDE_DVFS_ERROR_BUSY; + } + + if (dvfs_oppoint == current_dvfs_oppoint) { + return status; + } + + if (k_is_in_isr()) { + return -IRONSIDE_DVFS_ERROR_ISR_NOT_ALLOWED; + } + + ironside_dvfs_prepare_to_scale(dvfs_oppoint); + + status = ironside_dvfs_req_oppoint(dvfs_oppoint); + + if (status != 0) { + return status; + } + ironside_dvfs_change_oppoint_complete(dvfs_oppoint); + + return status; +} diff --git a/drivers/firmware/nrf_ironside/tdd.c b/drivers/firmware/nrf_ironside/tdd.c new file mode 100644 index 000000000000..29f1c5dead03 --- /dev/null +++ b/drivers/firmware/nrf_ironside/tdd.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +int ironside_se_tdd_configure(const enum ironside_se_tdd_config config) +{ + int err; + struct ironside_call_buf *const buf = ironside_call_alloc(); + + buf->id = IRONSIDE_SE_CALL_ID_TDD_V0; + buf->args[IRONSIDE_SE_TDD_SERVICE_REQ_CONFIG_IDX] = (uint32_t)config; + + ironside_call_dispatch(buf); + + if (buf->status == IRONSIDE_CALL_STATUS_RSP_SUCCESS) { + err = buf->args[IRONSIDE_SE_TDD_SERVICE_RSP_RETCODE_IDX]; + } else { + err = buf->status; + } + + ironside_call_release(buf); + + return err; +} diff --git a/drivers/flash/Kconfig.nrf_rram b/drivers/flash/Kconfig.nrf_rram index 3dea687a0f80..a59560e86a46 100644 --- a/drivers/flash/Kconfig.nrf_rram +++ b/drivers/flash/Kconfig.nrf_rram @@ -70,14 +70,14 @@ config SOC_FLASH_NRF_TIMEOUT_MULTIPLIER config NRF_RRAM_REGION_ADDRESS_RESOLUTION hex - default 0x400 + default 0x1000 help RRAMC's region protection address resolution. Applies to region with configurable start address. config NRF_RRAM_REGION_SIZE_UNIT hex - default 0x400 + default 0x1000 help Base unit for the size of RRAMC's region protection. diff --git a/drivers/flash/flash_mspi_nor.c b/drivers/flash/flash_mspi_nor.c index e297b01f5d98..b7ca6341d3ae 100644 --- a/drivers/flash/flash_mspi_nor.c +++ b/drivers/flash/flash_mspi_nor.c @@ -567,15 +567,20 @@ static int default_io_mode(const struct device *dev) enum mspi_io_mode io_mode = dev_config->mspi_nor_cfg.io_mode; int rc = 0; - /* For Quad 1-1-4 and 1-4-4, entering or leaving mode is defined in JEDEC216 BFP DW15 QER */ - if (io_mode == MSPI_IO_MODE_SINGLE) { - rc = quad_enable_set(dev, false); - } else if ((io_mode == MSPI_IO_MODE_QUAD_1_1_4) || (io_mode == MSPI_IO_MODE_QUAD_1_4_4)) { - rc = quad_enable_set(dev, true); - } + if (dev_config->dw15_qer != JESD216_DW15_QER_VAL_NONE) { + /* For Quad 1-1-4 and 1-4-4, entering or leaving mode is defined + * in JEDEC216 BFP DW15 QER + */ + if (io_mode == MSPI_IO_MODE_SINGLE) { + rc = quad_enable_set(dev, false); + } else if (io_mode == MSPI_IO_MODE_QUAD_1_1_4 || + io_mode == MSPI_IO_MODE_QUAD_1_4_4) { + rc = quad_enable_set(dev, true); + } - if (rc < 0) { - LOG_ERR("Failed to modify Quad Enable bit: %d", rc); + if (rc < 0) { + LOG_ERR("Failed to modify Quad Enable bit: %d", rc); + } } if ((dev_config->quirks != NULL) && (dev_config->quirks->post_switch_mode != NULL)) { @@ -646,8 +651,10 @@ static int flash_chip_init(const struct device *dev) /* Some chips reuse RESET pin for data in Quad modes: * force single line mode before resetting. */ - if ((io_mode == MSPI_IO_MODE_SINGLE) || (io_mode == MSPI_IO_MODE_QUAD_1_1_4) || - (io_mode == MSPI_IO_MODE_QUAD_1_4_4)) { + if (dev_config->dw15_qer != JESD216_DW15_QER_VAL_NONE && + (io_mode == MSPI_IO_MODE_SINGLE || + io_mode == MSPI_IO_MODE_QUAD_1_1_4 || + io_mode == MSPI_IO_MODE_QUAD_1_4_4)) { rc = quad_enable_set(dev, false); if (rc < 0) { diff --git a/drivers/flash/nrf_qspi_nor.c b/drivers/flash/nrf_qspi_nor.c index 12eeb3f4a3e2..34b36b4d7e31 100644 --- a/drivers/flash/nrf_qspi_nor.c +++ b/drivers/flash/nrf_qspi_nor.c @@ -41,7 +41,7 @@ struct qspi_nor_data { */ volatile bool ready; #endif /* CONFIG_MULTITHREADING */ - bool xip_enabled; + uint32_t xip_users; }; struct qspi_nor_config { @@ -313,7 +313,7 @@ static void qspi_acquire(const struct device *dev) qspi_lock(dev); - if (!dev_data->xip_enabled) { + if (dev_data->xip_users == 0) { qspi_clock_div_change(); pm_device_busy_set(dev); @@ -331,7 +331,7 @@ static void qspi_release(const struct device *dev) deactivate = atomic_dec(&dev_data->usage_count) == 1; #endif - if (!dev_data->xip_enabled) { + if (dev_data->xip_users == 0) { qspi_clock_div_restore(); if (deactivate) { @@ -1344,35 +1344,54 @@ static int qspi_nor_pm_action(const struct device *dev, } #endif /* CONFIG_PM_DEVICE */ +static void on_xip_enable(const struct device *dev) +{ +#if NRF_QSPI_HAS_XIPEN + nrf_qspi_xip_set(NRF_QSPI, true); +#endif + (void)nrfx_qspi_activate(false); +} + +static void on_xip_disable(const struct device *dev) +{ + /* It turns out that when the QSPI peripheral is deactivated + * after a XIP transaction, it cannot be later successfully + * reactivated and an attempt to perform another XIP transaction + * results in the CPU being hung; even a debug session cannot be + * started then and the SoC has to be recovered. + * As a workaround, at least until the cause of such behavior + * is fully clarified, perform a simple non-XIP transaction + * (a read of the status register) before deactivating the QSPI. + * This prevents the issue from occurring. + */ + (void)qspi_rdsr(dev, 1); + +#if NRF_QSPI_HAS_XIPEN + nrf_qspi_xip_set(NRF_QSPI, false); +#endif +} + void z_impl_nrf_qspi_nor_xip_enable(const struct device *dev, bool enable) { struct qspi_nor_data *dev_data = dev->data; - if (dev_data->xip_enabled == enable) { - return; - } - qspi_acquire(dev); -#if NRF_QSPI_HAS_XIPEN - nrf_qspi_xip_set(NRF_QSPI, enable); -#endif if (enable) { - (void)nrfx_qspi_activate(false); + if (dev_data->xip_users == 0) { + on_xip_enable(dev); + } + + ++dev_data->xip_users; + } else if (dev_data->xip_users == 0) { + LOG_ERR("Unbalanced XIP disabling"); } else { - /* It turns out that when the QSPI peripheral is deactivated - * after a XIP transaction, it cannot be later successfully - * reactivated and an attempt to perform another XIP transaction - * results in the CPU being hung; even a debug session cannot be - * started then and the SoC has to be recovered. - * As a workaround, at least until the cause of such behavior - * is fully clarified, perform a simple non-XIP transaction - * (a read of the status register) before deactivating the QSPI. - * This prevents the issue from occurring. - */ - (void)qspi_rdsr(dev, 1); + --dev_data->xip_users; + + if (dev_data->xip_users == 0) { + on_xip_disable(dev); + } } - dev_data->xip_enabled = enable; qspi_release(dev); } diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 9e1ba68319ff..574739082dc4 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -37,6 +37,11 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -166,6 +171,12 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index d26a15cf7236..d46e3524ea8d 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -279,6 +284,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + memcpy(data, (void *)addr, len); return 0; diff --git a/drivers/gpio/CMakeLists.txt b/drivers/gpio/CMakeLists.txt index 728a883e1093..08adaf2d640f 100644 --- a/drivers/gpio/CMakeLists.txt +++ b/drivers/gpio/CMakeLists.txt @@ -67,7 +67,7 @@ zephyr_library_sources_ifdef(CONFIG_GPIO_NCT38XX gpio_nct38xx_port.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NCT38XX_ALERT gpio_nct38xx_alert.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NEORV32 gpio_neorv32.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NPCX gpio_npcx.c) -zephyr_library_sources_ifdef(CONFIG_GPIO_NPM1300 gpio_npm1300.c) +zephyr_library_sources_ifdef(CONFIG_GPIO_NPM13XX gpio_npm13xx.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NPM2100 gpio_npm2100.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NPM6001 gpio_npm6001.c) zephyr_library_sources_ifdef(CONFIG_GPIO_NRFX gpio_nrfx.c) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index e95aded5613a..dcf5a8c043c6 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -153,7 +153,7 @@ source "drivers/gpio/Kconfig.mspm0" source "drivers/gpio/Kconfig.nct38xx" source "drivers/gpio/Kconfig.neorv32" source "drivers/gpio/Kconfig.npcx" -source "drivers/gpio/Kconfig.npm1300" +source "drivers/gpio/Kconfig.npm13xx" source "drivers/gpio/Kconfig.npm2100" source "drivers/gpio/Kconfig.npm6001" source "drivers/gpio/Kconfig.nrfx" diff --git a/drivers/gpio/Kconfig.npm1300 b/drivers/gpio/Kconfig.npm1300 deleted file mode 100644 index 65cb81a36868..000000000000 --- a/drivers/gpio/Kconfig.npm1300 +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config GPIO_NPM1300 - bool "nPM1300 GPIO driver" - default y - depends on DT_HAS_NORDIC_NPM1300_GPIO_ENABLED - select I2C - select MFD - help - Enable the nPM1300 GPIO driver. - -config GPIO_NPM1300_INIT_PRIORITY - int "nPM1300 GPIO driver initialization priority" - depends on GPIO_NPM1300 - default 85 - help - Initialization priority for the nPM1300 GPIO driver. It must be - greater than the I2C controller init priority. diff --git a/drivers/gpio/Kconfig.npm13xx b/drivers/gpio/Kconfig.npm13xx new file mode 100644 index 000000000000..1d3bade047db --- /dev/null +++ b/drivers/gpio/Kconfig.npm13xx @@ -0,0 +1,19 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config GPIO_NPM13XX + bool "nPM13xx GPIO driver" + default y + depends on DT_HAS_NORDIC_NPM1300_GPIO_ENABLED || DT_HAS_NORDIC_NPM1304_GPIO_ENABLED + select I2C + select MFD + help + Enable the nPM13xx GPIO driver. + +config GPIO_NPM13XX_INIT_PRIORITY + int "nPM13xx GPIO driver initialization priority" + depends on GPIO_NPM13XX + default 85 + help + Initialization priority for the nPM13xx GPIO driver. It must be + greater than the I2C controller init priority. diff --git a/drivers/gpio/gpio_npm1300.c b/drivers/gpio/gpio_npm1300.c deleted file mode 100644 index a941e1f3f6f9..000000000000 --- a/drivers/gpio/gpio_npm1300.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -#define DT_DRV_COMPAT nordic_npm1300_gpio - -#include - -#include -#include -#include -#include -#include -#include - -/* nPM1300 GPIO base address */ -#define NPM_GPIO_BASE 0x06U - -/* nPM1300 GPIO registers offsets */ -#define NPM_GPIO_OFFSET_MODE 0x00U -#define NPM_GPIO_OFFSET_DRIVE 0x05U -#define NPM_GPIO_OFFSET_PULLUP 0x0AU -#define NPM_GPIO_OFFSET_PULLDOWN 0x0FU -#define NPM_GPIO_OFFSET_OPENDRAIN 0x14U -#define NPM_GPIO_OFFSET_DEBOUNCE 0x19U -#define NPM_GPIO_OFFSET_STATUS 0x1EU - -/* nPM1300 Channel counts */ -#define NPM1300_GPIO_PINS 5U - -#define NPM1300_GPIO_GPIINPUT 0 -#define NPM1300_GPIO_GPILOGIC1 1 -#define NPM1300_GPIO_GPILOGIC0 2 -#define NPM1300_GPIO_GPIEVENTRISE 3 -#define NPM1300_GPIO_GPIEVENTFALL 4 -#define NPM1300_GPIO_GPOIRQ 5 -#define NPM1300_GPIO_GPORESET 6 -#define NPM1300_GPIO_GPOPWRLOSSWARN 7 -#define NPM1300_GPIO_GPOLOGIC1 8 -#define NPM1300_GPIO_GPOLOGIC0 9 - -struct gpio_npm1300_config { - struct gpio_driver_config common; - const struct device *mfd; -}; - -struct gpio_npm1300_data { - struct gpio_driver_data common; -}; - -static int gpio_npm1300_port_get_raw(const struct device *dev, uint32_t *value) -{ - const struct gpio_npm1300_config *config = dev->config; - int ret; - uint8_t data; - - ret = mfd_npm1300_reg_read(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_STATUS, &data); - - if (ret < 0) { - return ret; - } - - *value = data; - - return 0; -} - -static int gpio_npm1300_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, - gpio_port_value_t value) -{ - const struct gpio_npm1300_config *config = dev->config; - int ret = 0; - - for (size_t idx = 0; idx < NPM1300_GPIO_PINS; idx++) { - if ((mask & BIT(idx)) != 0U) { - if ((value & BIT(idx)) != 0U) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, - NPM_GPIO_OFFSET_MODE + idx, - NPM1300_GPIO_GPOLOGIC1); - } else { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, - NPM_GPIO_OFFSET_MODE + idx, - NPM1300_GPIO_GPOLOGIC0); - } - if (ret != 0U) { - return ret; - } - } - } - - return ret; -} - -static int gpio_npm1300_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) -{ - return gpio_npm1300_port_set_masked_raw(dev, pins, pins); -} - -static int gpio_npm1300_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) -{ - return gpio_npm1300_port_set_masked_raw(dev, pins, 0U); -} - -static inline int gpio_npm1300_configure(const struct device *dev, gpio_pin_t pin, - gpio_flags_t flags) -{ - const struct gpio_npm1300_config *config = dev->config; - int ret = 0; - - if (k_is_in_isr()) { - return -EWOULDBLOCK; - } - - if (pin >= NPM1300_GPIO_PINS) { - return -EINVAL; - } - - /* Configure mode */ - if ((flags & GPIO_INPUT) != 0U) { - if (flags & GPIO_ACTIVE_LOW) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, - NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPIEVENTFALL); - } else { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, - NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPIEVENTRISE); - } - } else if ((flags & NPM1300_GPIO_WDT_RESET_ON) != 0U) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPORESET); - } else if ((flags & NPM1300_GPIO_PWRLOSSWARN_ON) != 0U) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPOPWRLOSSWARN); - } else if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0U) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPOLOGIC1); - } else if ((flags & GPIO_OUTPUT) != 0U) { - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, - NPM1300_GPIO_GPOLOGIC0); - } - - if (ret < 0) { - return ret; - } - - /* Configure open drain */ - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_OPENDRAIN + pin, - !!(flags & GPIO_SINGLE_ENDED)); - if (ret < 0) { - return ret; - } - - /* Configure pulls */ - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_PULLUP + pin, - !!(flags & GPIO_PULL_UP)); - if (ret < 0) { - return ret; - } - - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_PULLDOWN + pin, - !!(flags & GPIO_PULL_DOWN)); - if (ret < 0) { - return ret; - } - - /* Configure drive strength and debounce */ - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_DRIVE + pin, - !!(flags & NPM1300_GPIO_DRIVE_6MA)); - if (ret < 0) { - return ret; - } - - ret = mfd_npm1300_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_DEBOUNCE + pin, - !!(flags & NPM1300_GPIO_DEBOUNCE_ON)); - - return ret; -} - -static int gpio_npm1300_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) -{ - int ret; - uint32_t value; - - ret = gpio_npm1300_port_get_raw(dev, &value); - - if (ret < 0) { - return ret; - } - - return gpio_npm1300_port_set_masked_raw(dev, pins, ~value); -} - -static DEVICE_API(gpio, gpio_npm1300_api) = { - .pin_configure = gpio_npm1300_configure, - .port_get_raw = gpio_npm1300_port_get_raw, - .port_set_masked_raw = gpio_npm1300_port_set_masked_raw, - .port_set_bits_raw = gpio_npm1300_port_set_bits_raw, - .port_clear_bits_raw = gpio_npm1300_port_clear_bits_raw, - .port_toggle_bits = gpio_npm1300_port_toggle_bits, -}; - -static int gpio_npm1300_init(const struct device *dev) -{ - const struct gpio_npm1300_config *config = dev->config; - - if (!device_is_ready(config->mfd)) { - return -ENODEV; - } - - return 0; -} - -#define GPIO_NPM1300_DEFINE(n) \ - static const struct gpio_npm1300_config gpio_npm1300_config##n = { \ - .common = \ - { \ - .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \ - }, \ - .mfd = DEVICE_DT_GET(DT_INST_PARENT(n))}; \ - \ - static struct gpio_npm1300_data gpio_npm1300_data##n; \ - \ - DEVICE_DT_INST_DEFINE(n, gpio_npm1300_init, NULL, &gpio_npm1300_data##n, \ - &gpio_npm1300_config##n, POST_KERNEL, \ - CONFIG_GPIO_NPM1300_INIT_PRIORITY, &gpio_npm1300_api); - -DT_INST_FOREACH_STATUS_OKAY(GPIO_NPM1300_DEFINE) diff --git a/drivers/gpio/gpio_npm13xx.c b/drivers/gpio/gpio_npm13xx.c new file mode 100644 index 000000000000..d6eeb4b73b01 --- /dev/null +++ b/drivers/gpio/gpio_npm13xx.c @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include +#include +#include +#include +#include +#include + +/* nPM13xx GPIO base address */ +#define NPM_GPIO_BASE 0x06U + +/* nPM13xx GPIO registers offsets */ +#define NPM_GPIO_OFFSET_MODE 0x00U +#define NPM_GPIO_OFFSET_DRIVE 0x05U +#define NPM_GPIO_OFFSET_PULLUP 0x0AU +#define NPM_GPIO_OFFSET_PULLDOWN 0x0FU +#define NPM_GPIO_OFFSET_OPENDRAIN 0x14U +#define NPM_GPIO_OFFSET_DEBOUNCE 0x19U +#define NPM_GPIO_OFFSET_STATUS 0x1EU + +/* nPM13xx Channel counts */ +#define NPM13XX_GPIO_PINS 5U + +#define NPM13XX_GPIO_GPIINPUT 0 +#define NPM13XX_GPIO_GPILOGIC1 1 +#define NPM13XX_GPIO_GPILOGIC0 2 +#define NPM13XX_GPIO_GPIEVENTRISE 3 +#define NPM13XX_GPIO_GPIEVENTFALL 4 +#define NPM13XX_GPIO_GPOIRQ 5 +#define NPM13XX_GPIO_GPORESET 6 +#define NPM13XX_GPIO_GPOPWRLOSSWARN 7 +#define NPM13XX_GPIO_GPOLOGIC1 8 +#define NPM13XX_GPIO_GPOLOGIC0 9 + +struct gpio_npm13xx_config { + struct gpio_driver_config common; + const struct device *mfd; +}; + +struct gpio_npm13xx_data { + struct gpio_driver_data common; +}; + +static int gpio_npm13xx_port_get_raw(const struct device *dev, uint32_t *value) +{ + const struct gpio_npm13xx_config *config = dev->config; + int ret; + uint8_t data; + + ret = mfd_npm13xx_reg_read(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_STATUS, &data); + + if (ret < 0) { + return ret; + } + + *value = data; + + return 0; +} + +static int gpio_npm13xx_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, + gpio_port_value_t value) +{ + const struct gpio_npm13xx_config *config = dev->config; + int ret = 0; + + for (size_t idx = 0; idx < NPM13XX_GPIO_PINS; idx++) { + if ((mask & BIT(idx)) != 0U) { + if ((value & BIT(idx)) != 0U) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, + NPM_GPIO_OFFSET_MODE + idx, + NPM13XX_GPIO_GPOLOGIC1); + } else { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, + NPM_GPIO_OFFSET_MODE + idx, + NPM13XX_GPIO_GPOLOGIC0); + } + if (ret != 0U) { + return ret; + } + } + } + + return ret; +} + +static int gpio_npm13xx_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) +{ + return gpio_npm13xx_port_set_masked_raw(dev, pins, pins); +} + +static int gpio_npm13xx_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) +{ + return gpio_npm13xx_port_set_masked_raw(dev, pins, 0U); +} + +static inline int gpio_npm13xx_configure(const struct device *dev, gpio_pin_t pin, + gpio_flags_t flags) +{ + const struct gpio_npm13xx_config *config = dev->config; + int ret = 0; + + if (k_is_in_isr()) { + return -EWOULDBLOCK; + } + + if (pin >= NPM13XX_GPIO_PINS) { + return -EINVAL; + } + + /* Configure mode */ + if ((flags & GPIO_INPUT) != 0U) { + if (flags & GPIO_ACTIVE_LOW) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, + NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPIEVENTFALL); + } else { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, + NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPIEVENTRISE); + } + } else if ((flags & NPM13XX_GPIO_WDT_RESET_ON) != 0U) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPORESET); + } else if ((flags & NPM13XX_GPIO_PWRLOSSWARN_ON) != 0U) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPOPWRLOSSWARN); + } else if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0U) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPOLOGIC1); + } else if ((flags & GPIO_OUTPUT) != 0U) { + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_MODE + pin, + NPM13XX_GPIO_GPOLOGIC0); + } + + if (ret < 0) { + return ret; + } + + /* Configure open drain */ + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_OPENDRAIN + pin, + !!(flags & GPIO_SINGLE_ENDED)); + if (ret < 0) { + return ret; + } + + /* Configure pulls */ + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_PULLUP + pin, + !!(flags & GPIO_PULL_UP)); + if (ret < 0) { + return ret; + } + + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_PULLDOWN + pin, + !!(flags & GPIO_PULL_DOWN)); + if (ret < 0) { + return ret; + } + + /* Configure drive strength and debounce */ + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_DRIVE + pin, + !!(flags & NPM13XX_GPIO_DRIVE_6MA)); + if (ret < 0) { + return ret; + } + + ret = mfd_npm13xx_reg_write(config->mfd, NPM_GPIO_BASE, NPM_GPIO_OFFSET_DEBOUNCE + pin, + !!(flags & NPM13XX_GPIO_DEBOUNCE_ON)); + + return ret; +} + +static int gpio_npm13xx_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) +{ + int ret; + uint32_t value; + + ret = gpio_npm13xx_port_get_raw(dev, &value); + + if (ret < 0) { + return ret; + } + + return gpio_npm13xx_port_set_masked_raw(dev, pins, ~value); +} + +static DEVICE_API(gpio, gpio_npm13xx_api) = { + .pin_configure = gpio_npm13xx_configure, + .port_get_raw = gpio_npm13xx_port_get_raw, + .port_set_masked_raw = gpio_npm13xx_port_set_masked_raw, + .port_set_bits_raw = gpio_npm13xx_port_set_bits_raw, + .port_clear_bits_raw = gpio_npm13xx_port_clear_bits_raw, + .port_toggle_bits = gpio_npm13xx_port_toggle_bits, +}; + +static int gpio_npm13xx_init(const struct device *dev) +{ + const struct gpio_npm13xx_config *config = dev->config; + + if (!device_is_ready(config->mfd)) { + return -ENODEV; + } + + return 0; +} + +#define GPIO_NPM13XX_DEFINE(partno, n) \ + static const struct gpio_npm13xx_config gpio_##partno##_config##n = { \ + .common = \ + { \ + .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(n), \ + }, \ + .mfd = DEVICE_DT_GET(DT_INST_PARENT(n))}; \ + \ + static struct gpio_npm13xx_data gpio_##partno##_data##n; \ + \ + DEVICE_DT_INST_DEFINE(n, gpio_npm13xx_init, NULL, &gpio_##partno##_data##n, \ + &gpio_##partno##_config##n, POST_KERNEL, \ + CONFIG_GPIO_NPM13XX_INIT_PRIORITY, &gpio_npm13xx_api); + +#define DT_DRV_COMPAT nordic_npm1300_gpio +#define GPIO_NPM1300_DEFINE(n) GPIO_NPM13XX_DEFINE(npm1300, n) +DT_INST_FOREACH_STATUS_OKAY(GPIO_NPM1300_DEFINE) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304_gpio +#define GPIO_NPM1304_DEFINE(n) GPIO_NPM13XX_DEFINE(npm1304, n) +DT_INST_FOREACH_STATUS_OKAY(GPIO_NPM1304_DEFINE) diff --git a/drivers/gpio/gpio_nrfx.c b/drivers/gpio/gpio_nrfx.c index 39377d7b7776..0a94b84c67fd 100644 --- a/drivers/gpio/gpio_nrfx.c +++ b/drivers/gpio/gpio_nrfx.c @@ -64,20 +64,15 @@ static nrf_gpio_pin_pull_t get_pull(gpio_flags_t flags) return NRF_GPIO_PIN_NOPULL; } -static void gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask, gpio_flags_t flags) +static void gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask) { #ifdef CONFIG_SOC_NRF54H20_GPD const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); - if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1 || !(flags & GPIO_OUTPUT)) { - return; - } - nrf_gpio_port_retain_enable(cfg->port, mask); #else ARG_UNUSED(port); ARG_UNUSED(mask); - ARG_UNUSED(flags); #endif } @@ -86,10 +81,6 @@ static void gpio_nrfx_gpd_retain_clear(const struct device *port, uint32_t mask) #ifdef CONFIG_SOC_NRF54H20_GPD const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); - if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1) { - return; - } - nrf_gpio_port_retain_disable(cfg->port, mask); #else ARG_UNUSED(port); @@ -225,7 +216,7 @@ static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin, } end: - gpio_nrfx_gpd_retain_set(port, BIT(pin), flags); + gpio_nrfx_gpd_retain_set(port, BIT(pin)); return pm_device_runtime_put(port); } @@ -329,7 +320,7 @@ static int gpio_nrfx_port_set_masked_raw(const struct device *port, gpio_nrfx_gpd_retain_clear(port, mask); nrf_gpio_port_out_set(reg, set_mask); nrf_gpio_port_out_clear(reg, clear_mask); - gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); + gpio_nrfx_gpd_retain_set(port, mask); return pm_device_runtime_put(port); } @@ -346,7 +337,7 @@ static int gpio_nrfx_port_set_bits_raw(const struct device *port, gpio_nrfx_gpd_retain_clear(port, mask); nrf_gpio_port_out_set(reg, mask); - gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); + gpio_nrfx_gpd_retain_set(port, mask); return pm_device_runtime_put(port); } @@ -363,7 +354,7 @@ static int gpio_nrfx_port_clear_bits_raw(const struct device *port, gpio_nrfx_gpd_retain_clear(port, mask); nrf_gpio_port_out_clear(reg, mask); - gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); + gpio_nrfx_gpd_retain_set(port, mask); return pm_device_runtime_put(port); } @@ -384,7 +375,7 @@ static int gpio_nrfx_port_toggle_bits(const struct device *port, gpio_nrfx_gpd_retain_clear(port, mask); nrf_gpio_port_out_set(reg, set_mask); nrf_gpio_port_out_clear(reg, clear_mask); - gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT); + gpio_nrfx_gpd_retain_set(port, mask); return pm_device_runtime_put(port); } @@ -444,6 +435,15 @@ static int gpio_nrfx_pin_interrupt_configure(const struct device *port, } trigger_config.p_in_channel = &ch; + } else { + /* If edge mode with channel was previously used and we are changing to sense or + * level triggered, we must free the channel. + */ + err = nrfx_gpiote_channel_get(&cfg->gpiote, abs_pin, &ch); + if (err == NRFX_SUCCESS) { + err = nrfx_gpiote_channel_free(&cfg->gpiote, ch); + __ASSERT_NO_MSG(err == NRFX_SUCCESS); + } } err = nrfx_gpiote_input_configure(&cfg->gpiote, abs_pin, &input_pin_config); diff --git a/drivers/i2c/Kconfig.nrfx b/drivers/i2c/Kconfig.nrfx index 2213175d5d60..54d533636747 100644 --- a/drivers/i2c/Kconfig.nrfx +++ b/drivers/i2c/Kconfig.nrfx @@ -30,6 +30,8 @@ config I2C_NRFX_TWIM select NRFX_TWIM20 if HAS_HW_NRF_TWIM20 select NRFX_TWIM21 if HAS_HW_NRF_TWIM21 select NRFX_TWIM22 if HAS_HW_NRF_TWIM22 + select NRFX_TWIM23 if HAS_HW_NRF_TWIM23 + select NRFX_TWIM24 if HAS_HW_NRF_TWIM24 select NRFX_TWIM30 if HAS_HW_NRF_TWIM30 select NRFX_TWIM120 if HAS_HW_NRF_TWIM120 select NRFX_TWIM130 if HAS_HW_NRF_TWIM130 @@ -61,6 +63,8 @@ config I2C_NRFX_TWIS select NRFX_TWIS20 if HAS_HW_NRF_TWIS20 select NRFX_TWIS21 if HAS_HW_NRF_TWIS21 select NRFX_TWIS22 if HAS_HW_NRF_TWIS22 + select NRFX_TWIS23 if HAS_HW_NRF_TWIS23 + select NRFX_TWIS24 if HAS_HW_NRF_TWIS24 select NRFX_TWIS30 if HAS_HW_NRF_TWIS30 select NRFX_TWIS130 if HAS_HW_NRF_TWIS130 select NRFX_TWIS131 if HAS_HW_NRF_TWIS131 diff --git a/drivers/i2c/i2c_nrfx_twim.c b/drivers/i2c/i2c_nrfx_twim.c index 953a03a7b73d..b6c37f455dc1 100644 --- a/drivers/i2c/i2c_nrfx_twim.c +++ b/drivers/i2c/i2c_nrfx_twim.c @@ -224,6 +224,11 @@ static int i2c_nrfx_twim_init(const struct device *dev) return i2c_nrfx_twim_common_init(dev); } +static int i2c_nrfx_twim_deinit(const struct device *dev) +{ + return i2c_nrfx_twim_common_deinit(dev); +} + static DEVICE_API(i2c, i2c_nrfx_twim_driver_api) = { .configure = i2c_nrfx_twim_configure, .transfer = i2c_nrfx_twim_transfer, @@ -280,8 +285,9 @@ static DEVICE_API(i2c, i2c_nrfx_twim_driver_api) = { }; \ PM_DEVICE_DT_DEFINE(I2C(idx), twim_nrfx_pm_action, \ PM_DEVICE_ISR_SAFE); \ - I2C_DEVICE_DT_DEFINE(I2C(idx), \ + I2C_DEVICE_DT_DEINIT_DEFINE(I2C(idx), \ i2c_nrfx_twim_init, \ + i2c_nrfx_twim_deinit, \ PM_DEVICE_DT_GET(I2C(idx)), \ &twim_##idx##_data, \ &twim_##idx##z_config, \ @@ -323,6 +329,14 @@ I2C_NRFX_TWIM_DEVICE(21); I2C_NRFX_TWIM_DEVICE(22); #endif +#ifdef CONFIG_HAS_HW_NRF_TWIM23 +I2C_NRFX_TWIM_DEVICE(23); +#endif + +#ifdef CONFIG_HAS_HW_NRF_TWIM24 +I2C_NRFX_TWIM_DEVICE(24); +#endif + #ifdef CONFIG_HAS_HW_NRF_TWIM30 I2C_NRFX_TWIM_DEVICE(30); #endif diff --git a/drivers/i2c/i2c_nrfx_twim_common.c b/drivers/i2c/i2c_nrfx_twim_common.c index 1539d7c90ddd..f7fd0d097b0a 100644 --- a/drivers/i2c/i2c_nrfx_twim_common.c +++ b/drivers/i2c/i2c_nrfx_twim_common.c @@ -102,18 +102,30 @@ int i2c_nrfx_twim_msg_transfer(const struct device *dev, uint8_t flags, uint8_t return ret; } -int twim_nrfx_pm_action(const struct device *dev, enum pm_device_action action) +void twim_nrfx_pm_resume(const struct device *dev) { const struct i2c_nrfx_twim_common_config *config = dev->config; + (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); + nrfx_twim_enable(&config->twim); +} + +void twim_nrfx_pm_suspend(const struct device *dev) +{ + const struct i2c_nrfx_twim_common_config *config = dev->config; + + nrfx_twim_disable(&config->twim); + (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); +} + +int twim_nrfx_pm_action(const struct device *dev, enum pm_device_action action) +{ switch (action) { case PM_DEVICE_ACTION_RESUME: - (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); - nrfx_twim_enable(&config->twim); + twim_nrfx_pm_resume(dev); break; case PM_DEVICE_ACTION_SUSPEND: - nrfx_twim_disable(&config->twim); - (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); + twim_nrfx_pm_suspend(dev); break; default: return -ENOTSUP; @@ -138,3 +150,31 @@ int i2c_nrfx_twim_common_init(const struct device *dev) return pm_device_driver_init(dev, twim_nrfx_pm_action); } + +int i2c_nrfx_twim_common_deinit(const struct device *dev) +{ + const struct i2c_nrfx_twim_common_config *config = dev->config; +#if CONFIG_PM_DEVICE + enum pm_device_state state; +#endif + +#if CONFIG_PM_DEVICE + /* + * PM must have suspended the device before driver can + * be deinitialized + */ + (void)pm_device_state_get(dev, &state); + if (state != PM_DEVICE_STATE_SUSPENDED && + state != PM_DEVICE_STATE_OFF) { + LOG_ERR("device active"); + return -EBUSY; + } +#else + /* Suspend device */ + twim_nrfx_pm_suspend(dev); +#endif + + /* Uninit device hardware */ + nrfx_twim_uninit(&config->twim); + return 0; +} diff --git a/drivers/i2c/i2c_nrfx_twim_common.h b/drivers/i2c/i2c_nrfx_twim_common.h index ba7fa72f0198..3c5c82311bae 100644 --- a/drivers/i2c/i2c_nrfx_twim_common.h +++ b/drivers/i2c/i2c_nrfx_twim_common.h @@ -43,6 +43,7 @@ struct i2c_nrfx_twim_common_config { }; int i2c_nrfx_twim_common_init(const struct device *dev); +int i2c_nrfx_twim_common_deinit(const struct device *dev); int i2c_nrfx_twim_configure(const struct device *dev, uint32_t i2c_config); int i2c_nrfx_twim_recover_bus(const struct device *dev); int i2c_nrfx_twim_msg_transfer(const struct device *dev, uint8_t flags, uint8_t *buf, diff --git a/drivers/i2c/i2c_nrfx_twim_rtio.c b/drivers/i2c/i2c_nrfx_twim_rtio.c index 68d93a3a06e5..5eef549ba2e7 100644 --- a/drivers/i2c/i2c_nrfx_twim_rtio.c +++ b/drivers/i2c/i2c_nrfx_twim_rtio.c @@ -203,7 +203,7 @@ static DEVICE_API(i2c, i2c_nrfx_twim_driver_api) = { .iodev_submit = i2c_nrfx_twim_rtio_submit, }; -int i2c_nrfx_twim_rtio_init(const struct device *dev) +static int i2c_nrfx_twim_rtio_init(const struct device *dev) { const struct i2c_nrfx_twim_rtio_config *config = dev->config; @@ -211,6 +211,11 @@ int i2c_nrfx_twim_rtio_init(const struct device *dev) return i2c_nrfx_twim_common_init(dev); } +static int i2c_nrfx_twim_rtio_deinit(const struct device *dev) +{ + return i2c_nrfx_twim_common_deinit(dev); +} + #define CONCAT_BUF_SIZE(idx) \ COND_CODE_1(DT_NODE_HAS_PROP(I2C(idx), zephyr_concat_buf_size), \ (DT_PROP(I2C(idx), zephyr_concat_buf_size)), (0)) @@ -282,9 +287,10 @@ int i2c_nrfx_twim_rtio_init(const struct device *dev) .ctx = &_i2c##idx##_twim_rtio, \ }; \ PM_DEVICE_DT_DEFINE(I2C(idx), twim_nrfx_pm_action, PM_DEVICE_ISR_SAFE); \ - I2C_DEVICE_DT_DEFINE(I2C(idx), i2c_nrfx_twim_rtio_init, PM_DEVICE_DT_GET(I2C(idx)), \ - &twim_##idx##z_data, &twim_##idx##z_config, POST_KERNEL, \ - CONFIG_I2C_INIT_PRIORITY, &i2c_nrfx_twim_driver_api); + I2C_DEVICE_DT_DEINIT_DEFINE(I2C(idx), i2c_nrfx_twim_rtio_init, i2c_nrfx_twim_rtio_deinit, \ + PM_DEVICE_DT_GET(I2C(idx)), &twim_##idx##z_data, \ + &twim_##idx##z_config, POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, \ + &i2c_nrfx_twim_driver_api); #ifdef CONFIG_HAS_HW_NRF_TWIM0 I2C_NRFX_TWIM_RTIO_DEVICE(0); @@ -314,6 +320,14 @@ I2C_NRFX_TWIM_RTIO_DEVICE(21); I2C_NRFX_TWIM_RTIO_DEVICE(22); #endif +#ifdef CONFIG_HAS_HW_NRF_TWIM23 +I2C_NRFX_TWIM_RTIO_DEVICE(23); +#endif + +#ifdef CONFIG_HAS_HW_NRF_TWIM24 +I2C_NRFX_TWIM_RTIO_DEVICE(24); +#endif + #ifdef CONFIG_HAS_HW_NRF_TWIM30 I2C_NRFX_TWIM_RTIO_DEVICE(30); #endif diff --git a/drivers/i2c/i2c_nrfx_twis.c b/drivers/i2c/i2c_nrfx_twis.c index 9e2b0759f2a3..dca3a457cf22 100644 --- a/drivers/i2c/i2c_nrfx_twis.c +++ b/drivers/i2c/i2c_nrfx_twis.c @@ -73,6 +73,15 @@ static bool shim_nrf_twis_is_resumed(const struct device *dev) (void)pm_device_state_get(dev, &state); return state == PM_DEVICE_STATE_ACTIVE; } + +static bool shim_nrf_twis_is_suspended(const struct device *dev) +{ + enum pm_device_state state; + + (void)pm_device_state_get(dev, &state); + return state == PM_DEVICE_STATE_SUSPENDED || + state == PM_DEVICE_STATE_OFF; +} #else static bool shim_nrf_twis_is_resumed(const struct device *dev) { @@ -199,7 +208,7 @@ static int shim_nrf_twis_pm_action_cb(const struct device *dev, #if CONFIG_PM_DEVICE case PM_DEVICE_ACTION_SUSPEND: - shim_nrf_twis_disable(); + shim_nrf_twis_disable(dev); break; #endif @@ -283,6 +292,35 @@ static int shim_nrf_twis_init(const struct device *dev) return pm_device_driver_init(dev, shim_nrf_twis_pm_action_cb); } +static int shim_nrf_twis_deinit(const struct device *dev) +{ + const struct shim_nrf_twis_config *dev_config = dev->config; + struct shim_nrf_twis_data *dev_data = dev->data; + + if (dev_data->target_config != NULL) { + LOG_ERR("target registered"); + return -EPERM; + } + +#if CONFIG_PM_DEVICE + /* + * PM must have suspended the device before driver can + * be deinitialized + */ + if (!shim_nrf_twis_is_suspended(dev)) { + LOG_ERR("device active"); + return -EBUSY; + } +#else + /* Suspend device */ + shim_nrf_twis_disable(dev); +#endif + + /* Uninit device hardware */ + nrfx_twis_uninit(&dev_config->twis); + return 0; +} + #define SHIM_NRF_TWIS_NAME(id, name) \ _CONCAT_4(shim_nrf_twis_, name, _, id) @@ -323,9 +361,10 @@ static int shim_nrf_twis_init(const struct device *dev) shim_nrf_twis_pm_action_cb, \ ); \ \ - DEVICE_DT_DEFINE( \ + DEVICE_DT_DEINIT_DEFINE( \ SHIM_NRF_TWIS_NODE(id), \ shim_nrf_twis_init, \ + shim_nrf_twis_deinit, \ PM_DEVICE_DT_GET(SHIM_NRF_TWIS_NODE(id)), \ &SHIM_NRF_TWIS_NAME(id, data), \ &SHIM_NRF_TWIS_NAME(id, config), \ @@ -362,6 +401,14 @@ SHIM_NRF_TWIS_DEVICE_DEFINE(21); SHIM_NRF_TWIS_DEVICE_DEFINE(22); #endif +#ifdef CONFIG_HAS_HW_NRF_TWIS23 +SHIM_NRF_TWIS_DEVICE_DEFINE(23); +#endif + +#ifdef CONFIG_HAS_HW_NRF_TWIS24 +SHIM_NRF_TWIS_DEVICE_DEFINE(24); +#endif + #ifdef CONFIG_HAS_HW_NRF_TWIS30 SHIM_NRF_TWIS_DEVICE_DEFINE(30); #endif diff --git a/drivers/i2s/i2s_nrf_tdm.c b/drivers/i2s/i2s_nrf_tdm.c index f61c5c8849b1..f8fa4773d37e 100644 --- a/drivers/i2s/i2s_nrf_tdm.c +++ b/drivers/i2s/i2s_nrf_tdm.c @@ -127,7 +127,7 @@ static int audio_clock_request(struct tdm_drv_data *drv_data) { #if DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRF return onoff_request(drv_data->clk_mgr, &drv_data->clk_cli); -#elif DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL return nrf_clock_control_request(audiopll, &aclk_spec, &drv_data->clk_cli); #else (void)drv_data; @@ -140,7 +140,7 @@ static int audio_clock_release(struct tdm_drv_data *drv_data) { #if DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRF return onoff_release(drv_data->clk_mgr); -#elif DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRF2_AUDIOPLL +#elif DT_NODE_HAS_STATUS_OKAY(NODE_ACLK) && CONFIG_CLOCK_CONTROL_NRFS_AUDIOPLL (void)drv_data; return nrf_clock_control_release(audiopll, &aclk_spec); diff --git a/drivers/led/CMakeLists.txt b/drivers/led/CMakeLists.txt index 73a808d7d5a2..1d8b9d2aa960 100644 --- a/drivers/led/CMakeLists.txt +++ b/drivers/led/CMakeLists.txt @@ -12,7 +12,7 @@ zephyr_library_sources_ifdef(CONFIG_IS31FL3733 is31fl3733.c) zephyr_library_sources_ifdef(CONFIG_LED_AXP192_AXP2101 led_axp192.c) zephyr_library_sources_ifdef(CONFIG_LED_DAC led_dac.c) zephyr_library_sources_ifdef(CONFIG_LED_GPIO led_gpio.c) -zephyr_library_sources_ifdef(CONFIG_LED_NPM1300 led_npm1300.c) +zephyr_library_sources_ifdef(CONFIG_LED_NPM13XX led_npm13xx.c) zephyr_library_sources_ifdef(CONFIG_LED_PWM led_pwm.c) zephyr_library_sources_ifdef(CONFIG_LED_XEC led_mchp_xec.c) zephyr_library_sources_ifdef(CONFIG_LP3943 lp3943.c) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index bac815242c39..0e411ce21f04 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -40,7 +40,7 @@ source "drivers/led/Kconfig.lp5562" source "drivers/led/Kconfig.lp5569" source "drivers/led/Kconfig.modulino" source "drivers/led/Kconfig.ncp5623" -source "drivers/led/Kconfig.npm1300" +source "drivers/led/Kconfig.npm13xx" source "drivers/led/Kconfig.pca9633" source "drivers/led/Kconfig.pwm" source "drivers/led/Kconfig.tlc59108" diff --git a/drivers/led/Kconfig.npm1300 b/drivers/led/Kconfig.npm1300 deleted file mode 100644 index e5180aa1dd1d..000000000000 --- a/drivers/led/Kconfig.npm1300 +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config LED_NPM1300 - bool "nPM1300 LED driver" - default y - depends on DT_HAS_NORDIC_NPM1300_LED_ENABLED - select I2C - select MFD - help - Enable the nPM1300 LED driver. diff --git a/drivers/led/Kconfig.npm13xx b/drivers/led/Kconfig.npm13xx new file mode 100644 index 000000000000..5431c7c8326f --- /dev/null +++ b/drivers/led/Kconfig.npm13xx @@ -0,0 +1,11 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config LED_NPM13XX + bool "nPM13xx LED driver" + default y + depends on DT_HAS_NORDIC_NPM1300_LED_ENABLED || DT_HAS_NORDIC_NPM1304_LED_ENABLED + select I2C + select MFD + help + Enable the nPM13xx LED driver. diff --git a/drivers/led/led_npm1300.c b/drivers/led/led_npm1300.c deleted file mode 100644 index f23fde1dfa28..000000000000 --- a/drivers/led/led_npm1300.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -#define DT_DRV_COMPAT nordic_npm1300_led - -#include - -#include -#include -#include - -/* nPM1300 LED base address */ -#define NPM_LED_BASE 0x0AU - -/* nPM1300 LED register offsets */ -#define NPM_LED_OFFSET_MODE 0x00U -#define NPM_LED_OFFSET_SET 0x03U -#define NPM_LED_OFFSET_CLR 0x04U - -/* nPM1300 Channel counts */ -#define NPM1300_LED_PINS 3U - -/* nPM1300 LED modes */ -#define NPM_LED_HOST 2U - -struct led_npm1300_config { - const struct device *mfd; - uint8_t mode[NPM1300_LED_PINS]; -}; - -static int led_npm1300_on(const struct device *dev, uint32_t led) -{ - const struct led_npm1300_config *config = dev->config; - - if (led >= NPM1300_LED_PINS) { - return -EINVAL; - } - - if (config->mode[led] != NPM_LED_HOST) { - return -EPERM; - } - - return mfd_npm1300_reg_write(config->mfd, NPM_LED_BASE, NPM_LED_OFFSET_SET + (led * 2U), - 1U); -} - -static int led_npm1300_off(const struct device *dev, uint32_t led) -{ - const struct led_npm1300_config *config = dev->config; - - if (led >= NPM1300_LED_PINS) { - return -EINVAL; - } - - if (config->mode[led] != NPM_LED_HOST) { - return -EPERM; - } - - return mfd_npm1300_reg_write(config->mfd, NPM_LED_BASE, NPM_LED_OFFSET_CLR + (led * 2U), - 1U); -} - -static DEVICE_API(led, led_npm1300_api) = { - .on = led_npm1300_on, - .off = led_npm1300_off, -}; - -static int led_npm1300_init(const struct device *dev) -{ - const struct led_npm1300_config *config = dev->config; - - if (!device_is_ready(config->mfd)) { - return -ENODEV; - } - - for (uint8_t led = 0U; led < NPM1300_LED_PINS; led++) { - int ret = mfd_npm1300_reg_write(config->mfd, NPM_LED_BASE, - NPM_LED_OFFSET_MODE + led, config->mode[led]); - - if (ret < 0) { - return ret; - } - } - - return 0; -} - -#define LED_NPM1300_DEFINE(n) \ - static const struct led_npm1300_config led_npm1300_config##n = { \ - .mfd = DEVICE_DT_GET(DT_INST_PARENT(n)), \ - .mode = {DT_INST_ENUM_IDX(n, nordic_led0_mode), \ - DT_INST_ENUM_IDX(n, nordic_led1_mode), \ - DT_INST_ENUM_IDX(n, nordic_led2_mode)}}; \ - \ - DEVICE_DT_INST_DEFINE(n, &led_npm1300_init, NULL, NULL, &led_npm1300_config##n, \ - POST_KERNEL, CONFIG_LED_INIT_PRIORITY, &led_npm1300_api); - -DT_INST_FOREACH_STATUS_OKAY(LED_NPM1300_DEFINE) diff --git a/drivers/led/led_npm13xx.c b/drivers/led/led_npm13xx.c new file mode 100644 index 000000000000..f00864fc74a6 --- /dev/null +++ b/drivers/led/led_npm13xx.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include +#include +#include + +/* nPM13xx LED base address */ +#define NPM_LED_BASE 0x0AU + +/* nPM13xx LED register offsets */ +#define NPM_LED_OFFSET_MODE 0x00U +#define NPM_LED_OFFSET_SET 0x03U +#define NPM_LED_OFFSET_CLR 0x04U + +/* nPM13xx Channel counts */ +#define NPM13XX_LED_PINS 3U + +/* nPM13xx LED modes */ +#define NPM_LED_HOST 2U + +struct led_npm13xx_config { + const struct device *mfd; + uint8_t mode[NPM13XX_LED_PINS]; +}; + +static int led_npm13xx_on(const struct device *dev, uint32_t led) +{ + const struct led_npm13xx_config *config = dev->config; + + if (led >= NPM13XX_LED_PINS) { + return -EINVAL; + } + + if (config->mode[led] != NPM_LED_HOST) { + return -EPERM; + } + + return mfd_npm13xx_reg_write(config->mfd, NPM_LED_BASE, NPM_LED_OFFSET_SET + (led * 2U), + 1U); +} + +static int led_npm13xx_off(const struct device *dev, uint32_t led) +{ + const struct led_npm13xx_config *config = dev->config; + + if (led >= NPM13XX_LED_PINS) { + return -EINVAL; + } + + if (config->mode[led] != NPM_LED_HOST) { + return -EPERM; + } + + return mfd_npm13xx_reg_write(config->mfd, NPM_LED_BASE, NPM_LED_OFFSET_CLR + (led * 2U), + 1U); +} + +static DEVICE_API(led, led_npm13xx_api) = { + .on = led_npm13xx_on, + .off = led_npm13xx_off, +}; + +static int led_npm13xx_init(const struct device *dev) +{ + const struct led_npm13xx_config *config = dev->config; + + if (!device_is_ready(config->mfd)) { + return -ENODEV; + } + + for (uint8_t led = 0U; led < NPM13XX_LED_PINS; led++) { + int ret = mfd_npm13xx_reg_write(config->mfd, NPM_LED_BASE, + NPM_LED_OFFSET_MODE + led, config->mode[led]); + + if (ret < 0) { + return ret; + } + } + + return 0; +} + +#define LED_NPM13XX_DEFINE(partno, n) \ + static const struct led_npm13xx_config led_##partno##_config##n = { \ + .mfd = DEVICE_DT_GET(DT_INST_PARENT(n)), \ + .mode = {DT_INST_ENUM_IDX(n, nordic_led0_mode), \ + DT_INST_ENUM_IDX(n, nordic_led1_mode), \ + DT_INST_ENUM_IDX(n, nordic_led2_mode)}}; \ + \ + DEVICE_DT_INST_DEFINE(n, &led_npm13xx_init, NULL, NULL, &led_##partno##_config##n, \ + POST_KERNEL, CONFIG_LED_INIT_PRIORITY, &led_npm13xx_api); + +#define DT_DRV_COMPAT nordic_npm1300_led +#define LED_NPM1300_DEFINE(n) LED_NPM13XX_DEFINE(npm1300, n) +DT_INST_FOREACH_STATUS_OKAY(LED_NPM1300_DEFINE) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304_led +#define LED_NPM1304_DEFINE(n) LED_NPM13XX_DEFINE(npm1304, n) +DT_INST_FOREACH_STATUS_OKAY(LED_NPM1304_DEFINE) diff --git a/drivers/mfd/CMakeLists.txt b/drivers/mfd/CMakeLists.txt index 8560a10655f0..3c477fc7da86 100644 --- a/drivers/mfd/CMakeLists.txt +++ b/drivers/mfd/CMakeLists.txt @@ -6,7 +6,7 @@ zephyr_library() zephyr_library_sources_ifdef(CONFIG_MFD_ADP5585 mfd_adp5585.c) zephyr_library_sources_ifdef(CONFIG_MFD_MAX20335 mfd_max20335.c) zephyr_library_sources_ifdef(CONFIG_MFD_NCT38XX mfd_nct38xx.c) -zephyr_library_sources_ifdef(CONFIG_MFD_NPM1300 mfd_npm1300.c) +zephyr_library_sources_ifdef(CONFIG_MFD_NPM13XX mfd_npm13xx.c) zephyr_library_sources_ifdef(CONFIG_MFD_NPM2100 mfd_npm2100.c) zephyr_library_sources_ifdef(CONFIG_MFD_NPM6001 mfd_npm6001.c) zephyr_library_sources_ifdef(CONFIG_MFD_AXP192_AXP2101 mfd_axp192.c) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 325e29c864ae..86a11a72b410 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -30,7 +30,7 @@ source "drivers/mfd/Kconfig.max31790" source "drivers/mfd/Kconfig.maxq10xx" source "drivers/mfd/Kconfig.mchp_sam" source "drivers/mfd/Kconfig.nct38xx" -source "drivers/mfd/Kconfig.npm1300" +source "drivers/mfd/Kconfig.npm13xx" source "drivers/mfd/Kconfig.npm2100" source "drivers/mfd/Kconfig.npm6001" source "drivers/mfd/Kconfig.pf1550" diff --git a/drivers/mfd/Kconfig.npm1300 b/drivers/mfd/Kconfig.npm1300 deleted file mode 100644 index 56a54f3005ab..000000000000 --- a/drivers/mfd/Kconfig.npm1300 +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config MFD_NPM1300 - bool "nPM1300 PMIC multi-function device driver" - default y - depends on DT_HAS_NORDIC_NPM1300_ENABLED - select I2C - help - Enable the Nordic nPM1300 PMIC multi-function device driver - -config MFD_NPM1300_INIT_PRIORITY - int "nPM1300 MFD initialization priority" - default MFD_INIT_PRIORITY - depends on MFD_NPM1300 - help - Multi-function device initialization priority for nPM1300. diff --git a/drivers/mfd/Kconfig.npm13xx b/drivers/mfd/Kconfig.npm13xx new file mode 100644 index 000000000000..6170c074aa8a --- /dev/null +++ b/drivers/mfd/Kconfig.npm13xx @@ -0,0 +1,17 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config MFD_NPM13XX + bool "nPM13xx PMIC multi-function device driver" + default y + depends on DT_HAS_NORDIC_NPM1300_ENABLED || DT_HAS_NORDIC_NPM1304_ENABLED + select I2C + help + Enable the Nordic nPM13xx PMIC multi-function device driver + +config MFD_NPM13XX_INIT_PRIORITY + int "nPM13xx MFD initialization priority" + default MFD_INIT_PRIORITY + depends on MFD_NPM13XX + help + Multi-function device initialization priority for nPM13xx. diff --git a/drivers/mfd/mfd_npm1300.c b/drivers/mfd/mfd_npm13xx.c similarity index 55% rename from drivers/mfd/mfd_npm1300.c rename to drivers/mfd/mfd_npm13xx.c index 2ea0818faeec..0d0b8e89f5f9 100644 --- a/drivers/mfd/mfd_npm1300.c +++ b/drivers/mfd/mfd_npm13xx.c @@ -3,8 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_npm1300 - #include #include @@ -12,7 +10,7 @@ #include #include #include -#include +#include #define TIME_BASE 0x07U #define MAIN_BASE 0x00U @@ -42,7 +40,7 @@ #define GPIO_MODE_GPOIRQ 5 -struct mfd_npm1300_config { +struct mfd_npm13xx_config { struct i2c_dt_spec i2c; struct gpio_dt_spec host_int_gpios; uint8_t pmic_int_pin; @@ -50,7 +48,7 @@ struct mfd_npm1300_config { uint8_t lp_reset; }; -struct mfd_npm1300_data { +struct mfd_npm13xx_data { struct k_mutex mutex; const struct device *dev; struct gpio_callback gpio_cb; @@ -63,51 +61,51 @@ struct event_reg_t { uint8_t mask; }; -static const struct event_reg_t event_reg[NPM1300_EVENT_MAX] = { - [NPM1300_EVENT_CHG_COMPLETED] = {0x0AU, 0x10U}, - [NPM1300_EVENT_CHG_ERROR] = {0x0AU, 0x20U}, - [NPM1300_EVENT_BATTERY_DETECTED] = {0x0EU, 0x01U}, - [NPM1300_EVENT_BATTERY_REMOVED] = {0x0EU, 0x02U}, - [NPM1300_EVENT_SHIPHOLD_PRESS] = {0x12U, 0x01U}, - [NPM1300_EVENT_SHIPHOLD_RELEASE] = {0x12U, 0x02U}, - [NPM1300_EVENT_WATCHDOG_WARN] = {0x12U, 0x08U}, - [NPM1300_EVENT_VBUS_DETECTED] = {0x16U, 0x01U}, - [NPM1300_EVENT_VBUS_REMOVED] = {0x16U, 0x02U}, - [NPM1300_EVENT_GPIO0_EDGE] = {0x22U, 0x01U}, - [NPM1300_EVENT_GPIO1_EDGE] = {0x22U, 0x02U}, - [NPM1300_EVENT_GPIO2_EDGE] = {0x22U, 0x04U}, - [NPM1300_EVENT_GPIO3_EDGE] = {0x22U, 0x08U}, - [NPM1300_EVENT_GPIO4_EDGE] = {0x22U, 0x10U}, +static const struct event_reg_t event_reg[NPM13XX_EVENT_MAX] = { + [NPM13XX_EVENT_CHG_COMPLETED] = {0x0AU, 0x10U}, + [NPM13XX_EVENT_CHG_ERROR] = {0x0AU, 0x20U}, + [NPM13XX_EVENT_BATTERY_DETECTED] = {0x0EU, 0x01U}, + [NPM13XX_EVENT_BATTERY_REMOVED] = {0x0EU, 0x02U}, + [NPM13XX_EVENT_SHIPHOLD_PRESS] = {0x12U, 0x01U}, + [NPM13XX_EVENT_SHIPHOLD_RELEASE] = {0x12U, 0x02U}, + [NPM13XX_EVENT_WATCHDOG_WARN] = {0x12U, 0x08U}, + [NPM13XX_EVENT_VBUS_DETECTED] = {0x16U, 0x01U}, + [NPM13XX_EVENT_VBUS_REMOVED] = {0x16U, 0x02U}, + [NPM13XX_EVENT_GPIO0_EDGE] = {0x22U, 0x01U}, + [NPM13XX_EVENT_GPIO1_EDGE] = {0x22U, 0x02U}, + [NPM13XX_EVENT_GPIO2_EDGE] = {0x22U, 0x04U}, + [NPM13XX_EVENT_GPIO3_EDGE] = {0x22U, 0x08U}, + [NPM13XX_EVENT_GPIO4_EDGE] = {0x22U, 0x10U}, }; static void gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { - struct mfd_npm1300_data *data = CONTAINER_OF(cb, struct mfd_npm1300_data, gpio_cb); + struct mfd_npm13xx_data *data = CONTAINER_OF(cb, struct mfd_npm13xx_data, gpio_cb); k_work_submit(&data->work); } static void work_callback(struct k_work *work) { - struct mfd_npm1300_data *data = CONTAINER_OF(work, struct mfd_npm1300_data, work); - const struct mfd_npm1300_config *config = data->dev->config; + struct mfd_npm13xx_data *data = CONTAINER_OF(work, struct mfd_npm13xx_data, work); + const struct mfd_npm13xx_config *config = data->dev->config; uint8_t buf[MAIN_SIZE]; int ret; /* Read all MAIN registers into temporary buffer */ - ret = mfd_npm1300_reg_read_burst(data->dev, MAIN_BASE, 0U, buf, sizeof(buf)); + ret = mfd_npm13xx_reg_read_burst(data->dev, MAIN_BASE, 0U, buf, sizeof(buf)); if (ret < 0) { k_work_submit(&data->work); return; } - for (int i = 0; i < NPM1300_EVENT_MAX; i++) { + for (int i = 0; i < NPM13XX_EVENT_MAX; i++) { int offset = event_reg[i].offset + MAIN_OFFSET_CLR; if ((buf[offset] & event_reg[i].mask) != 0U) { gpio_fire_callbacks(&data->callbacks, data->dev, BIT(i)); - ret = mfd_npm1300_reg_write(data->dev, MAIN_BASE, offset, + ret = mfd_npm13xx_reg_write(data->dev, MAIN_BASE, offset, event_reg[i].mask); if (ret < 0) { k_work_submit(&data->work); @@ -122,10 +120,10 @@ static void work_callback(struct k_work *work) } } -static int mfd_npm1300_init(const struct device *dev) +static int mfd_npm13xx_init(const struct device *dev) { - const struct mfd_npm1300_config *config = dev->config; - struct mfd_npm1300_data *mfd_data = dev->data; + const struct mfd_npm13xx_config *config = dev->config; + struct mfd_npm13xx_data *mfd_data = dev->data; int ret; if (!i2c_is_ready_dt(&config->i2c)) { @@ -138,7 +136,7 @@ static int mfd_npm1300_init(const struct device *dev) if (config->host_int_gpios.port != NULL) { /* Set specified PMIC pin to be interrupt output */ - ret = mfd_npm1300_reg_write(dev, GPIO_BASE, GPIO_OFFSET_MODE + config->pmic_int_pin, + ret = mfd_npm13xx_reg_write(dev, GPIO_BASE, GPIO_OFFSET_MODE + config->pmic_int_pin, GPIO_MODE_GPOIRQ); if (ret < 0) { return ret; @@ -171,64 +169,64 @@ static int mfd_npm1300_init(const struct device *dev) } } - ret = mfd_npm1300_reg_write(dev, SHIP_BASE, SHIP_OFFSET_CONFIG, config->active_time); + ret = mfd_npm13xx_reg_write(dev, SHIP_BASE, SHIP_OFFSET_CONFIG, config->active_time); if (ret < 0) { return ret; } - ret = mfd_npm1300_reg_write(dev, SHIP_BASE, SHIP_OFFSET_LPCONFIG, config->lp_reset); + ret = mfd_npm13xx_reg_write(dev, SHIP_BASE, SHIP_OFFSET_LPCONFIG, config->lp_reset); if (ret < 0) { return ret; } - return mfd_npm1300_reg_write(dev, SHIP_BASE, SHIP_OFFSET_CFGSTROBE, 1U); + return mfd_npm13xx_reg_write(dev, SHIP_BASE, SHIP_OFFSET_CFGSTROBE, 1U); } -int mfd_npm1300_reg_read_burst(const struct device *dev, uint8_t base, uint8_t offset, void *data, +int mfd_npm13xx_reg_read_burst(const struct device *dev, uint8_t base, uint8_t offset, void *data, size_t len) { - const struct mfd_npm1300_config *config = dev->config; + const struct mfd_npm13xx_config *config = dev->config; uint8_t buff[] = {base, offset}; return i2c_write_read_dt(&config->i2c, buff, sizeof(buff), data, len); } -int mfd_npm1300_reg_read(const struct device *dev, uint8_t base, uint8_t offset, uint8_t *data) +int mfd_npm13xx_reg_read(const struct device *dev, uint8_t base, uint8_t offset, uint8_t *data) { - return mfd_npm1300_reg_read_burst(dev, base, offset, data, 1U); + return mfd_npm13xx_reg_read_burst(dev, base, offset, data, 1U); } -int mfd_npm1300_reg_write(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data) +int mfd_npm13xx_reg_write(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data) { - const struct mfd_npm1300_config *config = dev->config; + const struct mfd_npm13xx_config *config = dev->config; uint8_t buff[] = {base, offset, data}; return i2c_write_dt(&config->i2c, buff, sizeof(buff)); } -int mfd_npm1300_reg_write2(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data1, +int mfd_npm13xx_reg_write2(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data1, uint8_t data2) { - const struct mfd_npm1300_config *config = dev->config; + const struct mfd_npm13xx_config *config = dev->config; uint8_t buff[] = {base, offset, data1, data2}; return i2c_write_dt(&config->i2c, buff, sizeof(buff)); } -int mfd_npm1300_reg_update(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data, +int mfd_npm13xx_reg_update(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data, uint8_t mask) { - struct mfd_npm1300_data *mfd_data = dev->data; + struct mfd_npm13xx_data *mfd_data = dev->data; uint8_t reg; int ret; k_mutex_lock(&mfd_data->mutex, K_FOREVER); - ret = mfd_npm1300_reg_read(dev, base, offset, ®); + ret = mfd_npm13xx_reg_read(dev, base, offset, ®); if (ret == 0) { reg = (reg & ~mask) | (data & mask); - ret = mfd_npm1300_reg_write(dev, base, offset, reg); + ret = mfd_npm13xx_reg_write(dev, base, offset, reg); } k_mutex_unlock(&mfd_data->mutex); @@ -236,9 +234,9 @@ int mfd_npm1300_reg_update(const struct device *dev, uint8_t base, uint8_t offse return ret; } -int mfd_npm1300_set_timer(const struct device *dev, uint32_t time_ms) +int mfd_npm13xx_set_timer(const struct device *dev, uint32_t time_ms) { - const struct mfd_npm1300_config *config = dev->config; + const struct mfd_npm13xx_config *config = dev->config; uint8_t buff[5] = {TIME_BASE, TIME_OFFSET_TIMER}; uint32_t ticks = time_ms / TIMER_PRESCALER_MS; @@ -254,34 +252,34 @@ int mfd_npm1300_set_timer(const struct device *dev, uint32_t time_ms) return ret; } - return mfd_npm1300_reg_write(dev, TIME_BASE, TIME_OFFSET_LOAD, 1U); + return mfd_npm13xx_reg_write(dev, TIME_BASE, TIME_OFFSET_LOAD, 1U); } -int mfd_npm1300_reset(const struct device *dev) +int mfd_npm13xx_reset(const struct device *dev) { - return mfd_npm1300_reg_write(dev, MAIN_BASE, MAIN_OFFSET_RESET, 1U); + return mfd_npm13xx_reg_write(dev, MAIN_BASE, MAIN_OFFSET_RESET, 1U); } -int mfd_npm1300_hibernate(const struct device *dev, uint32_t time_ms) +int mfd_npm13xx_hibernate(const struct device *dev, uint32_t time_ms) { - int ret = mfd_npm1300_set_timer(dev, time_ms); + int ret = mfd_npm13xx_set_timer(dev, time_ms); if (ret != 0) { return ret; } - return mfd_npm1300_reg_write(dev, SHIP_BASE, SHIP_OFFSET_HIBERNATE, 1U); + return mfd_npm13xx_reg_write(dev, SHIP_BASE, SHIP_OFFSET_HIBERNATE, 1U); } -int mfd_npm1300_add_callback(const struct device *dev, struct gpio_callback *callback) +int mfd_npm13xx_add_callback(const struct device *dev, struct gpio_callback *callback) { - struct mfd_npm1300_data *data = dev->data; + struct mfd_npm13xx_data *data = dev->data; /* Enable interrupts for specified events */ - for (int i = 0; i < NPM1300_EVENT_MAX; i++) { + for (int i = 0; i < NPM13XX_EVENT_MAX; i++) { if ((callback->pin_mask & BIT(i)) != 0U) { /* Clear pending interrupt */ - int ret = mfd_npm1300_reg_write(data->dev, MAIN_BASE, + int ret = mfd_npm13xx_reg_write(data->dev, MAIN_BASE, event_reg[i].offset + MAIN_OFFSET_CLR, event_reg[i].mask); @@ -289,7 +287,7 @@ int mfd_npm1300_add_callback(const struct device *dev, struct gpio_callback *cal return ret; } - ret = mfd_npm1300_reg_write(data->dev, MAIN_BASE, + ret = mfd_npm13xx_reg_write(data->dev, MAIN_BASE, event_reg[i].offset + MAIN_OFFSET_INTENSET, event_reg[i].mask); if (ret < 0) { @@ -301,25 +299,33 @@ int mfd_npm1300_add_callback(const struct device *dev, struct gpio_callback *cal return gpio_manage_callback(&data->callbacks, callback, true); } -int mfd_npm1300_remove_callback(const struct device *dev, struct gpio_callback *callback) +int mfd_npm13xx_remove_callback(const struct device *dev, struct gpio_callback *callback) { - struct mfd_npm1300_data *data = dev->data; + struct mfd_npm13xx_data *data = dev->data; return gpio_manage_callback(&data->callbacks, callback, false); } -#define MFD_NPM1300_DEFINE(inst) \ - static struct mfd_npm1300_data data_##inst; \ +#define MFD_NPM13XX_DEFINE(partno, n) \ + static struct mfd_npm13xx_data mfd_##partno##_data##n; \ \ - static const struct mfd_npm1300_config config##inst = { \ - .i2c = I2C_DT_SPEC_INST_GET(inst), \ - .host_int_gpios = GPIO_DT_SPEC_INST_GET_OR(inst, host_int_gpios, {0}), \ - .pmic_int_pin = DT_INST_PROP_OR(inst, pmic_int_pin, 0), \ - .active_time = DT_INST_ENUM_IDX(inst, ship_to_active_time_ms), \ - .lp_reset = DT_INST_ENUM_IDX_OR(inst, long_press_reset, 0), \ + static const struct mfd_npm13xx_config mfd_##partno##_config##n = { \ + .i2c = I2C_DT_SPEC_INST_GET(n), \ + .host_int_gpios = GPIO_DT_SPEC_INST_GET_OR(n, host_int_gpios, {0}), \ + .pmic_int_pin = DT_INST_PROP_OR(n, pmic_int_pin, 0), \ + .active_time = DT_INST_ENUM_IDX(n, ship_to_active_time_ms), \ + .lp_reset = DT_INST_ENUM_IDX_OR(n, long_press_reset, 0), \ }; \ \ - DEVICE_DT_INST_DEFINE(inst, mfd_npm1300_init, NULL, &data_##inst, &config##inst, \ - POST_KERNEL, CONFIG_MFD_NPM1300_INIT_PRIORITY, NULL); + DEVICE_DT_INST_DEFINE(n, mfd_npm13xx_init, NULL, &mfd_##partno##_data##n, \ + &mfd_##partno##_config##n, POST_KERNEL, \ + CONFIG_MFD_NPM13XX_INIT_PRIORITY, NULL); +#define DT_DRV_COMPAT nordic_npm1300 +#define MFD_NPM1300_DEFINE(n) MFD_NPM13XX_DEFINE(npm1300, n) DT_INST_FOREACH_STATUS_OKAY(MFD_NPM1300_DEFINE) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304 +#define MFD_NPM1304_DEFINE(n) MFD_NPM13XX_DEFINE(npm1304, n) +DT_INST_FOREACH_STATUS_OKAY(MFD_NPM1304_DEFINE) diff --git a/drivers/mspi/mspi_dw.c b/drivers/mspi/mspi_dw.c index 39cf463f4bee..adc59e765b11 100644 --- a/drivers/mspi/mspi_dw.c +++ b/drivers/mspi/mspi_dw.c @@ -16,12 +16,9 @@ #include #include "mspi_dw.h" -#include "mspi_dw_vendor_specific.h" LOG_MODULE_REGISTER(mspi_dw, CONFIG_MSPI_LOG_LEVEL); -#define DUMMY_BYTE 0xAA - #if defined(CONFIG_MSPI_XIP) struct xip_params { uint32_t read_cmd; @@ -104,6 +101,7 @@ DEFINE_MM_REG_RD(rxflr, 0x24) DEFINE_MM_REG_RD(sr, 0x28) DEFINE_MM_REG_WR(imr, 0x2c) DEFINE_MM_REG_RD(isr, 0x30) +DEFINE_MM_REG_RD(risr, 0x34) DEFINE_MM_REG_RD_WR(dr, 0x60) DEFINE_MM_REG_WR(spi_ctrlr0, 0xf4) @@ -116,6 +114,8 @@ DEFINE_MM_REG_WR(xip_write_wrap_inst, 0x144) DEFINE_MM_REG_WR(xip_write_ctrl, 0x148) #endif +#include "mspi_dw_vendor_specific.h" + static void tx_data(const struct device *dev, const struct mspi_xfer_packet *packet) { @@ -150,6 +150,9 @@ static void tx_data(const struct device *dev, write_dr(dev, data); if (buf_pos >= buf_end) { + /* Set the threshold to 0 to get the next interrupt + * when the FIFO is completely emptied. + */ write_txftlr(dev, 0); break; } @@ -163,35 +166,38 @@ static void tx_data(const struct device *dev, dev_data->buf_pos = (uint8_t *)buf_pos; } -static bool make_rx_cycles(const struct device *dev) +static bool tx_dummy_bytes(const struct device *dev) { struct mspi_dw_data *dev_data = dev->data; const struct mspi_dw_config *dev_config = dev->config; + uint8_t fifo_room = dev_config->tx_fifo_depth_minus_1 + 1 + - FIELD_GET(TXFLR_TXTFL_MASK, read_txflr(dev)); uint16_t dummy_bytes = dev_data->dummy_bytes; - /* See tx_data(). */ - uint32_t room = 1; - uint8_t tx_fifo_depth = dev_config->tx_fifo_depth_minus_1 + 1; + const uint8_t dummy_val = 0; - do { - write_dr(dev, DUMMY_BYTE); + if (dummy_bytes > fifo_room) { + dev_data->dummy_bytes = dummy_bytes - fifo_room; - --dummy_bytes; - if (!dummy_bytes) { - dev_data->dummy_bytes = 0; - return true; - } + do { + write_dr(dev, dummy_val); + } while (--fifo_room); - if (--room == 0) { - room = tx_fifo_depth - - FIELD_GET(TXFLR_TXTFL_MASK, read_txflr(dev)); - } - } while (room); + return false; + } - dev_data->dummy_bytes = dummy_bytes; - return false; + do { + write_dr(dev, dummy_val); + } while (--dummy_bytes); + + /* Set the threshold to 0 to get the next interrupt when the FIFO is + * completely emptied. + */ + write_txftlr(dev, 0); + + return true; } -static void read_rx_fifo(const struct device *dev, +static bool read_rx_fifo(const struct device *dev, const struct mspi_xfer_packet *packet) { struct mspi_dw_data *dev_data = dev->data; @@ -222,9 +228,8 @@ static void read_rx_fifo(const struct device *dev, } if (buf_pos >= buf_end) { - dev_data->bytes_to_discard = bytes_to_discard; dev_data->buf_pos = buf_pos; - return; + return true; } } @@ -241,6 +246,7 @@ static void read_rx_fifo(const struct device *dev, dev_data->bytes_to_discard = bytes_to_discard; dev_data->buf_pos = buf_pos; + return false; } static void mspi_dw_isr(const struct device *dev) @@ -248,32 +254,54 @@ static void mspi_dw_isr(const struct device *dev) struct mspi_dw_data *dev_data = dev->data; const struct mspi_xfer_packet *packet = &dev_data->xfer.packets[dev_data->packets_done]; - uint32_t int_status = read_isr(dev); + bool finished = false; - if (int_status & ISR_RXFIS_BIT) { - read_rx_fifo(dev, packet); - } + if (packet->dir == MSPI_TX) { + if (dev_data->buf_pos < dev_data->buf_end) { + tx_data(dev, packet); + } else { + /* It may happen that at this point the controller is + * still shifting out the last frame (the last interrupt + * occurs when the TX FIFO is empty). Wait if it signals + * that it is busy. + */ + while (read_sr(dev) & SR_BUSY_BIT) { + } - if (dev_data->buf_pos >= dev_data->buf_end) { - write_imr(dev, 0); - /* It may happen that at this point the controller is still - * shifting out the last frame (the last interrupt occurs when - * the TX FIFO is empty). Wait if it signals that it is busy. - */ - while (read_sr(dev) & SR_BUSY_BIT) { + finished = true; } - - k_sem_give(&dev_data->finished); } else { - if (int_status & ISR_TXEIS_BIT) { - if (dev_data->dummy_bytes) { - if (make_rx_cycles(dev)) { + uint32_t int_status = read_isr(dev); + + do { + if (int_status & ISR_RXFIS_BIT) { + if (read_rx_fifo(dev, packet)) { + finished = true; + break; + } + + if (read_risr(dev) & RISR_RXOIR_BIT) { + finished = true; + break; + } + + int_status = read_isr(dev); + } + + if (int_status & ISR_TXEIS_BIT) { + if (tx_dummy_bytes(dev)) { write_imr(dev, IMR_RXFIM_BIT); } - } else { - tx_data(dev, packet); + + int_status = read_isr(dev); } - } + } while (int_status); + } + + if (finished) { + write_imr(dev, 0); + + k_sem_give(&dev_data->finished); } vendor_specific_irq_clear(dev); @@ -372,7 +400,7 @@ static bool apply_cmd_length(struct mspi_dw_data *dev_data, uint32_t cmd_length) SPI_CTRLR0_INST_L16); break; default: - LOG_ERR("Command length %d not supported", cmd_length); + LOG_ERR("Command length %u not supported", cmd_length); return false; } @@ -382,6 +410,11 @@ static bool apply_cmd_length(struct mspi_dw_data *dev_data, uint32_t cmd_length) static bool apply_addr_length(struct mspi_dw_data *dev_data, uint32_t addr_length) { + if (addr_length > 4) { + LOG_ERR("Address length %u not supported", addr_length); + return false; + } + dev_data->spi_ctrlr0 |= FIELD_PREP(SPI_CTRLR0_ADDR_L_MASK, addr_length * 2); @@ -493,7 +526,7 @@ static bool apply_xip_cmd_length(const struct mspi_dw_data *dev_data, XIP_WRITE_CTRL_INST_L16); break; default: - LOG_ERR("Command length %d not supported", cmd_length); + LOG_ERR("Command length %u not supported", cmd_length); return false; } @@ -505,6 +538,11 @@ static bool apply_xip_addr_length(const struct mspi_dw_data *dev_data, { uint8_t addr_length = dev_data->xip_params_active.addr_length; + if (addr_length > 4) { + LOG_ERR("Address length %u not supported", addr_length); + return false; + } + ctrl->read |= FIELD_PREP(XIP_CTRL_ADDR_L_MASK, addr_length * 2); ctrl->write |= FIELD_PREP(XIP_WRITE_CTRL_ADDR_L_MASK, addr_length * 2); @@ -738,7 +776,6 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) (dev_data->xip_enabled != 0), (false)); unsigned int key; - uint8_t tx_fifo_threshold; uint32_t packet_frames; uint32_t imr; int rc = 0; @@ -750,6 +787,7 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) } dev_data->dummy_bytes = 0; + dev_data->bytes_to_discard = 0; dev_data->ctrlr0 &= ~CTRLR0_TMOD_MASK & ~CTRLR0_DFS_MASK; @@ -790,7 +828,6 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) dev_data->xfer.tx_dummy); write_rxftlr(dev, 0); - tx_fifo_threshold = dev_config->tx_fifo_threshold; } else { uint32_t tmod; uint8_t rx_fifo_threshold; @@ -807,31 +844,34 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) (dev_data->xfer.cmd_length != 0 || dev_data->xfer.addr_length != 0)) { uint32_t rx_total_bytes; + uint32_t dummy_cycles = dev_data->xfer.rx_dummy; dev_data->bytes_to_discard = dev_data->xfer.cmd_length - + dev_data->xfer.addr_length; + + dev_data->xfer.addr_length + + dummy_cycles / 8; rx_total_bytes = dev_data->bytes_to_discard + packet->num_bytes; - dev_data->dummy_bytes = packet->num_bytes; + dev_data->dummy_bytes = dummy_cycles / 8 + + packet->num_bytes; imr = IMR_TXEIM_BIT | IMR_RXFIM_BIT; tmod = CTRLR0_TMOD_TX_RX; - tx_fifo_threshold = dev_config->tx_fifo_threshold; /* For standard SPI, only 1-byte frames are used. */ rx_fifo_threshold = MIN(rx_total_bytes - 1, dev_config->rx_fifo_threshold); } else { imr = IMR_RXFIM_BIT; tmod = CTRLR0_TMOD_RX; - tx_fifo_threshold = 0; rx_fifo_threshold = MIN(packet_frames - 1, dev_config->rx_fifo_threshold); + + dev_data->spi_ctrlr0 |= + FIELD_PREP(SPI_CTRLR0_WAIT_CYCLES_MASK, + dev_data->xfer.rx_dummy); } dev_data->ctrlr0 |= FIELD_PREP(CTRLR0_TMOD_MASK, tmod); - dev_data->spi_ctrlr0 |= FIELD_PREP(SPI_CTRLR0_WAIT_CYCLES_MASK, - dev_data->xfer.rx_dummy); write_rxftlr(dev, FIELD_PREP(RXFTLR_RFT_MASK, rx_fifo_threshold)); @@ -870,23 +910,49 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) dev_data->buf_pos = packet->data_buf; dev_data->buf_end = &packet->data_buf[packet->num_bytes]; - if ((imr & IMR_TXEIM_BIT) && dev_data->buf_pos < dev_data->buf_end) { - uint32_t start_level = tx_fifo_threshold; + /* Set the TX FIFO threshold and its transmit start level. */ + if (packet->num_bytes) { + /* If there is some data to send/receive, set the threshold to + * the value configured for the driver instance and the start + * level to the maximum possible value (it will be updated later + * in tx_fifo() or tx_dummy_bytes() when TX is to be finished). + * This helps avoid a situation when the TX FIFO becomes empty + * before the transfer is complete and the SSI core finishes the + * transaction and deactivates the CE line. This could occur + * right before the data phase in enhanced SPI modes, when the + * clock stretching feature does not work yet, or in Standard + * SPI mode, where the clock stretching is not available at all. + */ + write_txftlr(dev, FIELD_PREP(TXFTLR_TXFTHR_MASK, + dev_config->tx_fifo_depth_minus_1) | + FIELD_PREP(TXFTLR_TFT_MASK, + dev_config->tx_fifo_threshold)); + } else { + uint32_t total_tx_entries = 0; - if (dev_data->dummy_bytes) { - uint32_t tx_total = dev_data->bytes_to_discard - + dev_data->dummy_bytes; + /* It the whole transfer is to contain only the command and/or + * address, set up the transfer to start right after entries + * for those appear in the TX FIFO, and the threshold to 0, + * so that the interrupt occurs when the TX FIFO gets emptied. + */ + if (dev_data->xfer.cmd_length) { + if (dev_data->standard_spi) { + total_tx_entries += dev_data->xfer.cmd_length; + } else { + total_tx_entries += 1; + } + } - if (start_level > tx_total - 1) { - start_level = tx_total - 1; + if (dev_data->xfer.addr_length) { + if (dev_data->standard_spi) { + total_tx_entries += dev_data->xfer.addr_length; + } else { + total_tx_entries += 1; } } - write_txftlr(dev, - FIELD_PREP(TXFTLR_TXFTHR_MASK, start_level) | - FIELD_PREP(TXFTLR_TFT_MASK, tx_fifo_threshold)); - } else { - write_txftlr(dev, 0); + write_txftlr(dev, FIELD_PREP(TXFTLR_TXFTHR_MASK, + total_tx_entries - 1)); } /* Ensure that there will be no interrupt from the controller yet. */ @@ -894,6 +960,10 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) /* Enable the controller. This must be done before DR is written. */ write_ssienr(dev, SSIENR_SSIC_EN_BIT); + /* Since the FIFO depth in SSI is always at least 8, it can be safely + * assumed that the command and address fields (max. 2 and 4 bytes, + * respectively) can be written here before the TX FIFO gets filled up. + */ if (dev_data->standard_spi) { if (dev_data->xfer.cmd_length) { tx_control_field(dev, packet->cmd, @@ -914,19 +984,15 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout) } } - if (dev_data->dummy_bytes) { - if (make_rx_cycles(dev)) { - imr = IMR_RXFIM_BIT; - } - } else if (packet->dir == MSPI_TX && packet->num_bytes) { - tx_data(dev, packet); - } - /* Enable interrupts now and wait until the packet is done. */ write_imr(dev, imr); rc = k_sem_take(&dev_data->finished, timeout); - if (rc < 0) { + if (read_risr(dev) & RISR_RXOIR_BIT) { + LOG_ERR("RX FIFO overflow occurred"); + rc = -EIO; + } else if (rc < 0) { + LOG_ERR("Transfer timed out"); rc = -ETIMEDOUT; } @@ -970,8 +1036,7 @@ static int _api_transceive(const struct device *dev, struct mspi_dw_data *dev_data = dev->data; int rc; - dev_data->spi_ctrlr0 &= ~SPI_CTRLR0_WAIT_CYCLES_MASK - & ~SPI_CTRLR0_INST_L_MASK + dev_data->spi_ctrlr0 &= ~SPI_CTRLR0_INST_L_MASK & ~SPI_CTRLR0_ADDR_L_MASK; if (!apply_cmd_length(dev_data, req->cmd_length) || @@ -979,10 +1044,15 @@ static int _api_transceive(const struct device *dev, return -EINVAL; } - if (dev_data->standard_spi && - (req->rx_dummy != 0 || req->tx_dummy != 0)) { - LOG_ERR("Dummy cycles unsupported in single line mode"); - return -EINVAL; + if (dev_data->standard_spi) { + if (req->tx_dummy) { + LOG_ERR("TX dummy cycles unsupported in single line mode"); + return -EINVAL; + } + if (req->rx_dummy % 8) { + LOG_ERR("Unsupported RX (%u) dummy cycles", req->rx_dummy); + return -EINVAL; + } } else if (req->rx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX || req->tx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX) { LOG_ERR("Unsupported RX (%u) or TX (%u) dummy cycles", @@ -1091,8 +1161,8 @@ static int _api_xip_config(const struct device *dev, return -EINVAL; } - if (params->rx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX || - params->tx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX) { + if (params->rx_dummy > XIP_CTRL_WAIT_CYCLES_MAX || + params->tx_dummy > XIP_WRITE_CTRL_WAIT_CYCLES_MAX) { LOG_ERR("Unsupported RX (%u) or TX (%u) dummy cycles", params->rx_dummy, params->tx_dummy); return -EINVAL; diff --git a/drivers/mspi/mspi_dw.h b/drivers/mspi/mspi_dw.h index bd81d061e09a..c35778cb1c59 100644 --- a/drivers/mspi/mspi_dw.h +++ b/drivers/mspi/mspi_dw.h @@ -66,6 +66,19 @@ #define ISR_RXFIS_BIT BIT(4) #define ISR_MSTIS_BIT BIT(5) +/* RISR - Raw Interrupt Status Register */ +#define RISR_TXEIR_BIT BIT(0) +#define RISR_TXOIR_BIT BIT(1) +#define RISR_RXUIR_BIT BIT(2) +#define RISR_RXOIR_BIT BIT(3) +#define RISR_RXFIR_BIT BIT(4) +#define RISR_MSTIR_BIT BIT(5) +#define RISR_XRXOIR_BIT BIT(6) +#define RISR_TXUIR_BIT BIT(7) +#define RISR_AXIER_BIT BIT(8) +#define RISR_SPITER_BIT BIT(10) +#define RISR_DONER_BIT BIT(11) + /* SPI_CTRLR0 - SPI Control Register */ #define SPI_CTRLR0_CLK_STRETCH_EN_BIT BIT(30) #define SPI_CTRLR0_XIP_PREFETCH_EN_BIT BIT(29) @@ -127,21 +140,6 @@ #define XIP_CTRL_FRF_QUAD 2UL #define XIP_CTRL_FRF_OCTAL 3UL -/* XIP_CTRL - XIP Control Register */ -#define XIP_CTRL_XIP_PREFETCH_EN_BIT BIT(28) -#define XIP_CTRL_XIP_MBL_MASK GENMASK(27, 26) -#define XIP_CTRL_XIP_MBL_2 0UL -#define XIP_CTRL_XIP_MBL_4 1UL -#define XIP_CTRL_XIP_MBL_8 2UL -#define XIP_CTRL_XIP_MBL_16 3UL -#define XIP_CTRL_XIP_HYBERBUS_EN_BIT BIT(24) -#define XIP_CTRL_CONT_XFER_EN_BIT BIT(23) -#define XIP_CTRL_INST_EN_BIT BIT(22) -#define XIP_CTRL_RXDS_EN_BIT BIT(21) -#define XIP_CTRL_INST_DDR_EN_BIT BIT(20) -#define XIP_CTRL_DDR_EN_BIT BIT(19) -#define XIP_CTRL_DFS_HC_BIT BIT(18) - /* XIP_WRITE_CTRL - XIP Write Control Register */ #define XIP_WRITE_CTRL_WAIT_CYCLES_MASK GENMASK(20, 16) #define XIP_WRITE_CTRL_WAIT_CYCLES_MAX BIT_MASK(5) diff --git a/drivers/mspi/mspi_dw_vendor_specific.h b/drivers/mspi/mspi_dw_vendor_specific.h index 4913e536c92d..e34d8a5db60b 100644 --- a/drivers/mspi/mspi_dw_vendor_specific.h +++ b/drivers/mspi/mspi_dw_vendor_specific.h @@ -33,6 +33,17 @@ static inline void vendor_specific_resume(const struct device *dev) ARG_UNUSED(dev); NRF_EXMIF->TASKS_START = 1; + + /* Try to write an SSI register and wait until the write is successful + * to ensure that the clock that drives the SSI core is ready. + */ + uint32_t rxftlr = read_rxftlr(dev); + uint32_t rxftlr_mod = rxftlr ^ 1; + + do { + write_rxftlr(dev, rxftlr_mod); + rxftlr = read_rxftlr(dev); + } while (rxftlr != rxftlr_mod); } static inline void vendor_specific_irq_clear(const struct device *dev) diff --git a/drivers/pinctrl/pinctrl_nrf.c b/drivers/pinctrl/pinctrl_nrf.c index 3744abf80313..34c0107b591b 100644 --- a/drivers/pinctrl/pinctrl_nrf.c +++ b/drivers/pinctrl/pinctrl_nrf.c @@ -112,6 +112,18 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = { #define NRF_PSEL_TDM(reg, line) ((NRF_TDM_Type *)reg)->PSEL.line #endif +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_hpf_mspi_controller) || \ + defined(CONFIG_MSPI_HPF) || \ + DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(nordic_nrf_vpr_coprocessor, pinctrl_0) +#if defined(CONFIG_SOC_SERIES_NRF54LX) +#define NRF_PSEL_SDP_MSPI(psel) \ + nrf_gpio_pin_control_select(psel, NRF_GPIO_PIN_SEL_VPR); +#elif defined(CONFIG_SOC_SERIES_NRF54HX) +/* On nRF54H, pin routing is controlled by secure domain, via UICR. */ +#define NRF_PSEL_SDP_MSPI(psel) +#endif +#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_hpf_mspi_controller) || ... */ + int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg) { @@ -428,7 +440,8 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_can) */ -#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) || \ + DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif_spi) /* Pin routing is controlled by secure domain, via UICR */ case NRF_FUN_EXMIF_CK: case NRF_FUN_EXMIF_DQ0: @@ -464,6 +477,26 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* defined(NRF_PSEL_TWIS) */ +#if defined(NRF_PSEL_SDP_MSPI) + case NRF_FUN_SDP_MSPI_CS0: + case NRF_FUN_SDP_MSPI_CS1: + case NRF_FUN_SDP_MSPI_CS2: + case NRF_FUN_SDP_MSPI_CS3: + case NRF_FUN_SDP_MSPI_CS4: + case NRF_FUN_SDP_MSPI_SCK: + case NRF_FUN_SDP_MSPI_DQ0: + case NRF_FUN_SDP_MSPI_DQ1: + case NRF_FUN_SDP_MSPI_DQ2: + case NRF_FUN_SDP_MSPI_DQ3: + case NRF_FUN_SDP_MSPI_DQ4: + case NRF_FUN_SDP_MSPI_DQ5: + case NRF_FUN_SDP_MSPI_DQ6: + case NRF_FUN_SDP_MSPI_DQ7: + NRF_PSEL_SDP_MSPI(psel); + dir = NRF_GPIO_PIN_DIR_OUTPUT; + input = NRF_GPIO_PIN_INPUT_CONNECT; + break; +#endif /* defined(NRF_PSEL_SDP_MSPI) */ default: return -ENOTSUP; } @@ -483,9 +516,13 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, } gpd_requested = true; } - - nrf_gpio_pin_retain_disable(pin); } + + /* + * Pad power domain now on, retain no longer needed + * as pad config will be persists as pad is powered. + */ + nrf_gpio_pin_retain_disable(pin); #endif /* CONFIG_SOC_NRF54H20_GPD */ if (write != NO_WRITE) { @@ -504,7 +541,13 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, nrf_gpio_pin_clock_set(pin, NRF_GET_CLOCKPIN_ENABLE(pins[i])); #endif #ifdef CONFIG_SOC_NRF54H20_GPD - if (NRF_GET_GPD_FAST_ACTIVE1(pins[i]) == 1U) { + if (NRF_GET_LP(pins[i]) == NRF_LP_ENABLE) { + /* + * Pad power domain may be turned off, and pad is not + * actively used as pincnf is low-power. Enable retain + * to ensure pad output and config persists if pad + * power domain is suspended. + */ nrf_gpio_pin_retain_enable(pin); } #endif /* CONFIG_SOC_NRF54H20_GPD */ diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index bab8b0f003e7..ec55bef69604 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -55,7 +55,7 @@ LOG_MODULE_REGISTER(pwm_nrfx, CONFIG_PWM_LOG_LEVEL); BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED)); #endif -#if defined(PWM_NRFX_FAST_PRESENT) && CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL +#if defined(PWM_NRFX_FAST_PRESENT) && CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL #define PWM_NRFX_USE_CLOCK_CONTROL 1 #endif @@ -493,11 +493,11 @@ static int pwm_nrfx_init(const struct device *dev) * must be initialized after that controller driver, hence the default PWM * initialization priority may be too early for them. */ -#if defined(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY) && \ - CONFIG_PWM_INIT_PRIORITY < CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY) && \ + CONFIG_PWM_INIT_PRIORITY < CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY #define PWM_INIT_PRIORITY(idx) \ COND_CODE_1(PWM_NRFX_IS_FAST(_, /*empty*/, idx, _), \ - (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY)), \ + (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \ (CONFIG_PWM_INIT_PRIORITY)) #else #define PWM_INIT_PRIORITY(idx) CONFIG_PWM_INIT_PRIORITY diff --git a/drivers/regulator/CMakeLists.txt b/drivers/regulator/CMakeLists.txt index ed5a1996da9b..283fd976de73 100644 --- a/drivers/regulator/CMakeLists.txt +++ b/drivers/regulator/CMakeLists.txt @@ -13,7 +13,7 @@ zephyr_library_sources_ifdef(CONFIG_REGULATOR_FIXED regulator_fixed.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_GPIO regulator_gpio.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_MAX20335 regulator_max20335.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_NPM1100 regulator_npm1100.c) -zephyr_library_sources_ifdef(CONFIG_REGULATOR_NPM1300 regulator_npm1300.c) +zephyr_library_sources_ifdef(CONFIG_REGULATOR_NPM13XX regulator_npm13xx.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_NPM2100 regulator_npm2100.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_NPM6001 regulator_npm6001.c) zephyr_library_sources_ifdef(CONFIG_REGULATOR_PCA9420 regulator_pca9420.c) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dc331b2139d3..ca2bf41ae895 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -35,7 +35,7 @@ source "drivers/regulator/Kconfig.fixed" source "drivers/regulator/Kconfig.gpio" source "drivers/regulator/Kconfig.max20335" source "drivers/regulator/Kconfig.npm1100" -source "drivers/regulator/Kconfig.npm1300" +source "drivers/regulator/Kconfig.npm13xx" source "drivers/regulator/Kconfig.npm2100" source "drivers/regulator/Kconfig.npm6001" source "drivers/regulator/Kconfig.pca9420" diff --git a/drivers/regulator/Kconfig.npm1300 b/drivers/regulator/Kconfig.npm1300 deleted file mode 100644 index 19adee0ebab2..000000000000 --- a/drivers/regulator/Kconfig.npm1300 +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config REGULATOR_NPM1300 - bool "nPM1300 PMIC regulator driver" - default y - depends on DT_HAS_NORDIC_NPM1300_REGULATOR_ENABLED - select I2C - select MFD - help - Enable the Nordic nPM1300 PMIC regulator driver - -if REGULATOR_NPM1300 - -config REGULATOR_NPM1300_COMMON_INIT_PRIORITY - int "nPM1300 regulator driver init priority (common part)" - default 85 - help - Init priority for the Nordic nPM1300 regulator driver (common part). - It must be greater than I2C init priority. - -config REGULATOR_NPM1300_INIT_PRIORITY - int "nPM1300 regulator driver init priority" - default 86 - help - Init priority for the Nordic nPM1300 regulator driver. It must be - greater than REGULATOR_NPM1300_COMMON_INIT_PRIORITY. - -endif diff --git a/drivers/regulator/Kconfig.npm13xx b/drivers/regulator/Kconfig.npm13xx new file mode 100644 index 000000000000..a075ca72dc7c --- /dev/null +++ b/drivers/regulator/Kconfig.npm13xx @@ -0,0 +1,29 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config REGULATOR_NPM13XX + bool "nPM13xx PMIC regulator driver" + default y + depends on DT_HAS_NORDIC_NPM1300_REGULATOR_ENABLED || DT_HAS_NORDIC_NPM1304_REGULATOR_ENABLED + select I2C + select MFD + help + Enable the Nordic nPM13xx PMIC regulator driver + +if REGULATOR_NPM13XX + +config REGULATOR_NPM13XX_COMMON_INIT_PRIORITY + int "nPM13xx regulator driver init priority (common part)" + default 85 + help + Init priority for the Nordic nPM13xx regulator driver (common part). + It must be greater than I2C init priority. + +config REGULATOR_NPM13XX_INIT_PRIORITY + int "nPM13xx regulator driver init priority" + default 86 + help + Init priority for the Nordic nPM13xx regulator driver. It must be + greater than REGULATOR_NPM13XX_COMMON_INIT_PRIORITY. + +endif diff --git a/drivers/regulator/regulator_npm1300.c b/drivers/regulator/regulator_npm13xx.c similarity index 50% rename from drivers/regulator/regulator_npm1300.c rename to drivers/regulator/regulator_npm13xx.c index 8b5b64572c45..c07970bb5c64 100644 --- a/drivers/regulator/regulator_npm1300.c +++ b/drivers/regulator/regulator_npm13xx.c @@ -3,39 +3,37 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_npm1300_regulator - #include #include #include #include -#include -#include +#include +#include #include #include -/* nPM1300 voltage sources */ -enum npm1300_sources { - NPM1300_SOURCE_BUCK1, - NPM1300_SOURCE_BUCK2, - NPM1300_SOURCE_LDO1, - NPM1300_SOURCE_LDO2, +/* nPM13xx voltage sources */ +enum npm13xx_sources { + NPM13XX_SOURCE_BUCK1, + NPM13XX_SOURCE_BUCK2, + NPM13XX_SOURCE_LDO1, + NPM13XX_SOURCE_LDO2, }; -/* nPM1300 gpio control channels */ -enum npm1300_gpio_type { - NPM1300_GPIO_TYPE_ENABLE, - NPM1300_GPIO_TYPE_RETENTION, - NPM1300_GPIO_TYPE_PWM +/* nPM13xx gpio control channels */ +enum npm13xx_gpio_type { + NPM13XX_GPIO_TYPE_ENABLE, + NPM13XX_GPIO_TYPE_RETENTION, + NPM13XX_GPIO_TYPE_PWM }; -/* nPM1300 regulator base addresses */ +/* nPM13xx regulator base addresses */ #define BUCK_BASE 0x04U #define LDSW_BASE 0x08U #define SHIP_BASE 0x0BU -/* nPM1300 regulator register offsets */ +/* nPM13xx regulator register offsets */ #define BUCK_OFFSET_EN_SET 0x00U #define BUCK_OFFSET_EN_CLR 0x01U #define BUCK_OFFSET_PWM_SET 0x04U @@ -50,7 +48,7 @@ enum npm1300_gpio_type { #define BUCK_OFFSET_CTRL0 0x15U #define BUCK_OFFSET_STATUS 0x34U -/* nPM1300 ldsw register offsets */ +/* nPM13xx ldsw register offsets */ #define LDSW_OFFSET_EN_SET 0x00U #define LDSW_OFFSET_EN_CLR 0x01U #define LDSW_OFFSET_STATUS 0x04U @@ -59,75 +57,80 @@ enum npm1300_gpio_type { #define LDSW_OFFSET_LDOSEL 0x08U #define LDSW_OFFSET_VOUTSEL 0x0CU -/* nPM1300 ship register offsets */ +/* nPM13xx ship register offsets */ #define SHIP_OFFSET_SHIP 0x02U -#define BUCK1_ON_MASK 0x04U -#define BUCK2_ON_MASK 0x40U +#define BUCK1_ON_MASK 0x04U +#define BUCK2_ON_MASK 0x40U +#define BUCK1_EN_PULLDOWN_MASK BIT(2) +#define BUCK2_EN_PULLDOWN_MASK BIT(3) #define LDSW1_ON_MASK 0x03U #define LDSW2_ON_MASK 0x0CU -#define LDSW1_SOFTSTART_MASK 0x0CU -#define LDSW1_SOFTSTART_SHIFT 2U -#define LDSW2_SOFTSTART_MASK 0x30U -#define LDSW2_SOFTSTART_SHIFT 4U +#define LDSW1_SOFTSTART_MASK 0x0CU +#define LDSW1_SOFTSTART_SHIFT 2U +#define LDSW1_ACTIVE_DISCHARGE_MASK BIT(6) +#define LDSW2_SOFTSTART_MASK 0x30U +#define LDSW2_SOFTSTART_SHIFT 4U +#define LDSW2_ACTIVE_DISCHARGE_MASK BIT(7) -#define NPM1300_GPIO_UNUSED UINT8_MAX +#define NPM13XX_GPIO_UNUSED UINT8_MAX -struct npm1300_gpio_info { +struct npm13xx_gpio_info { uint8_t pin; bool invert; }; -struct regulator_npm1300_pconfig { +struct regulator_npm13xx_pconfig { const struct device *mfd; struct gpio_dt_spec dvs_state_pins[5]; }; -struct regulator_npm1300_config { +struct regulator_npm13xx_config { struct regulator_common_config common; const struct device *mfd; uint8_t source; int32_t retention_uv; - struct npm1300_gpio_info enable_gpios; - struct npm1300_gpio_info retention_gpios; - struct npm1300_gpio_info pwm_gpios; + struct npm13xx_gpio_info enable_gpios; + struct npm13xx_gpio_info retention_gpios; + struct npm13xx_gpio_info pwm_gpios; uint8_t soft_start; + bool active_discharge; bool ldo_disable_workaround; }; -struct regulator_npm1300_data { +struct regulator_npm13xx_data { struct regulator_common_data data; }; /* Linear range for output voltage, common for all bucks and LDOs on this device */ static const struct linear_range buckldo_range = LINEAR_RANGE_INIT(1000000, 100000, 0U, 23U); -unsigned int regulator_npm1300_count_voltages(const struct device *dev) +unsigned int regulator_npm13xx_count_voltages(const struct device *dev) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: - case NPM1300_SOURCE_BUCK2: - case NPM1300_SOURCE_LDO1: - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK2: + case NPM13XX_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO2: return linear_range_values_count(&buckldo_range); default: return 0; } } -int regulator_npm1300_list_voltage(const struct device *dev, unsigned int idx, int32_t *volt_uv) +int regulator_npm13xx_list_voltage(const struct device *dev, unsigned int idx, int32_t *volt_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: - case NPM1300_SOURCE_BUCK2: - case NPM1300_SOURCE_LDO1: - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK2: + case NPM13XX_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO2: return linear_range_get_value(&buckldo_range, idx, volt_uv); default: return -EINVAL; @@ -136,16 +139,16 @@ int regulator_npm1300_list_voltage(const struct device *dev, unsigned int idx, i static int retention_set_voltage(const struct device *dev, int32_t retention_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint16_t idx; uint8_t chan; int ret; switch (config->source) { - case NPM1300_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK1: chan = 0U; break; - case NPM1300_SOURCE_BUCK2: + case NPM13XX_SOURCE_BUCK2: chan = 1U; break; default: @@ -158,17 +161,17 @@ static int retention_set_voltage(const struct device *dev, int32_t retention_uv) return ret; } - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_RET + (chan * 2U), + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_RET + (chan * 2U), idx); } static int buck_get_voltage_index(const struct device *dev, uint8_t chan, uint8_t *idx) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t sel; int ret; - ret = mfd_npm1300_reg_read(config->mfd, BUCK_BASE, BUCK_OFFSET_SW_CTRL, &sel); + ret = mfd_npm13xx_reg_read(config->mfd, BUCK_BASE, BUCK_OFFSET_SW_CTRL, &sel); if (ret < 0) { return ret; @@ -176,17 +179,17 @@ static int buck_get_voltage_index(const struct device *dev, uint8_t chan, uint8_ if ((sel >> chan) & 1U) { /* SW control */ - return mfd_npm1300_reg_read(config->mfd, BUCK_BASE, + return mfd_npm13xx_reg_read(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_NORM + (chan * 2U), idx); } /* VSET pin control */ - return mfd_npm1300_reg_read(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_STAT + chan, idx); + return mfd_npm13xx_reg_read(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_STAT + chan, idx); } static int buck_set_voltage(const struct device *dev, uint8_t chan, int32_t min_uv, int32_t max_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t mask; uint8_t curr_idx; uint16_t idx; @@ -205,7 +208,7 @@ static int buck_set_voltage(const struct device *dev, uint8_t chan, int32_t min_ return ret; } - ret = mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_NORM + (chan * 2U), + ret = mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_VOUT_NORM + (chan * 2U), idx); if (ret < 0) { @@ -214,12 +217,12 @@ static int buck_set_voltage(const struct device *dev, uint8_t chan, int32_t min_ /* Enable SW control of buck output */ mask = BIT(chan); - return mfd_npm1300_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_SW_CTRL, mask, mask); + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_SW_CTRL, mask, mask); } static int ldo_set_voltage(const struct device *dev, uint8_t chan, int32_t min_uv, int32_t max_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint16_t idx; int ret; @@ -229,21 +232,21 @@ static int ldo_set_voltage(const struct device *dev, uint8_t chan, int32_t min_u return ret; } - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_VOUTSEL + chan, idx); + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_VOUTSEL + chan, idx); } -int regulator_npm1300_set_voltage(const struct device *dev, int32_t min_uv, int32_t max_uv) +int regulator_npm13xx_set_voltage(const struct device *dev, int32_t min_uv, int32_t max_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK1: return buck_set_voltage(dev, 0, min_uv, max_uv); - case NPM1300_SOURCE_BUCK2: + case NPM13XX_SOURCE_BUCK2: return buck_set_voltage(dev, 1, min_uv, max_uv); - case NPM1300_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO1: return ldo_set_voltage(dev, 0, min_uv, max_uv); - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_LDO2: return ldo_set_voltage(dev, 1, min_uv, max_uv); default: return -ENODEV; @@ -266,11 +269,11 @@ static int buck_get_voltage(const struct device *dev, uint8_t chan, int32_t *vol static int ldo_get_voltage(const struct device *dev, uint8_t chan, int32_t *volt_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t idx; int ret; - ret = mfd_npm1300_reg_read(config->mfd, LDSW_BASE, LDSW_OFFSET_VOUTSEL + chan, &idx); + ret = mfd_npm13xx_reg_read(config->mfd, LDSW_BASE, LDSW_OFFSET_VOUTSEL + chan, &idx); if (ret < 0) { return ret; @@ -279,18 +282,18 @@ static int ldo_get_voltage(const struct device *dev, uint8_t chan, int32_t *volt return linear_range_get_value(&buckldo_range, idx, volt_uv); } -int regulator_npm1300_get_voltage(const struct device *dev, int32_t *volt_uv) +int regulator_npm13xx_get_voltage(const struct device *dev, int32_t *volt_uv) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK1: return buck_get_voltage(dev, 0, volt_uv); - case NPM1300_SOURCE_BUCK2: + case NPM13XX_SOURCE_BUCK2: return buck_get_voltage(dev, 1, volt_uv); - case NPM1300_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO1: return ldo_get_voltage(dev, 0, volt_uv); - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_LDO2: return ldo_get_voltage(dev, 1, volt_uv); default: return -ENODEV; @@ -299,22 +302,22 @@ int regulator_npm1300_get_voltage(const struct device *dev, int32_t *volt_uv) static int set_buck_mode(const struct device *dev, uint8_t chan, regulator_mode_t mode) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t pfm_mask = BIT(chan); uint8_t pfm_data; uint8_t pwm_reg; int ret; switch (mode) { - case NPM1300_BUCK_MODE_PWM: + case NPM13XX_BUCK_MODE_PWM: pfm_data = 0U; pwm_reg = BUCK_OFFSET_PWM_SET; break; - case NPM1300_BUCK_MODE_AUTO: + case NPM13XX_BUCK_MODE_AUTO: pfm_data = 0U; pwm_reg = BUCK_OFFSET_PWM_CLR; break; - case NPM1300_BUCK_MODE_PFM: + case NPM13XX_BUCK_MODE_PFM: pfm_data = pfm_mask; pwm_reg = BUCK_OFFSET_PWM_CLR; break; @@ -322,61 +325,61 @@ static int set_buck_mode(const struct device *dev, uint8_t chan, regulator_mode_ return -ENOTSUP; } - ret = mfd_npm1300_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_CTRL0, pfm_data, pfm_mask); + ret = mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_CTRL0, pfm_data, pfm_mask); if (ret < 0) { return ret; } - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, pwm_reg + (chan * 2U), 1U); + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, pwm_reg + (chan * 2U), 1U); } static int set_ldsw_mode(const struct device *dev, uint8_t chan, regulator_mode_t mode) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (mode) { - case NPM1300_LDSW_MODE_LDO: - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_LDOSEL + chan, 1U); - case NPM1300_LDSW_MODE_LDSW: - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_LDOSEL + chan, 0U); + case NPM13XX_LDSW_MODE_LDO: + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_LDOSEL + chan, 1U); + case NPM13XX_LDSW_MODE_LDSW: + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_LDOSEL + chan, 0U); default: return -ENOTSUP; } } -int regulator_npm1300_set_mode(const struct device *dev, regulator_mode_t mode) +int regulator_npm13xx_set_mode(const struct device *dev, regulator_mode_t mode) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK1: return set_buck_mode(dev, 0, mode); - case NPM1300_SOURCE_BUCK2: + case NPM13XX_SOURCE_BUCK2: return set_buck_mode(dev, 1, mode); - case NPM1300_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO1: return set_ldsw_mode(dev, 0, mode); - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_LDO2: return set_ldsw_mode(dev, 1, mode); default: return -ENOTSUP; } } -int regulator_npm1300_enable(const struct device *dev) +int regulator_npm13xx_enable(const struct device *dev) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; int ret; switch (config->source) { - case NPM1300_SOURCE_BUCK1: - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET, 1U); - case NPM1300_SOURCE_BUCK2: - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET + 2U, 1U); - case NPM1300_SOURCE_LDO1: - ret = mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET, 1U); + case NPM13XX_SOURCE_BUCK1: + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET, 1U); + case NPM13XX_SOURCE_BUCK2: + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET + 2U, 1U); + case NPM13XX_SOURCE_LDO1: + ret = mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET, 1U); break; - case NPM1300_SOURCE_LDO2: - ret = mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET + 2U, 1U); + case NPM13XX_SOURCE_LDO2: + ret = mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET + 2U, 1U); break; default: return 0; @@ -390,35 +393,35 @@ int regulator_npm1300_enable(const struct device *dev) uint8_t unused; k_msleep(2); - return mfd_npm1300_reg_read(config->mfd, LDSW_BASE, LDSW_OFFSET_STATUS, &unused); + return mfd_npm13xx_reg_read(config->mfd, LDSW_BASE, LDSW_OFFSET_STATUS, &unused); } return ret; } -int regulator_npm1300_disable(const struct device *dev) +int regulator_npm13xx_disable(const struct device *dev) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CLR, 1U); - case NPM1300_SOURCE_BUCK2: - return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CLR + 2U, 1U); - case NPM1300_SOURCE_LDO1: - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_CLR, 1U); - case NPM1300_SOURCE_LDO2: - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_CLR + 2U, 1U); + case NPM13XX_SOURCE_BUCK1: + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CLR, 1U); + case NPM13XX_SOURCE_BUCK2: + return mfd_npm13xx_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CLR + 2U, 1U); + case NPM13XX_SOURCE_LDO1: + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_CLR, 1U); + case NPM13XX_SOURCE_LDO2: + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_CLR + 2U, 1U); default: return 0; } } -static int regulator_npm1300_set_buck_pin_ctrl(const struct device *dev, uint8_t chan, - const struct npm1300_gpio_info *pin_info, - enum npm1300_gpio_type type) +static int regulator_npm13xx_set_buck_pin_ctrl(const struct device *dev, uint8_t chan, + const struct npm13xx_gpio_info *pin_info, + enum npm13xx_gpio_type type) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t inv = pin_info->invert ? 1 : 0; uint8_t ctrl; uint8_t mask; @@ -439,63 +442,63 @@ static int regulator_npm1300_set_buck_pin_ctrl(const struct device *dev, uint8_t } switch (type) { - case NPM1300_GPIO_TYPE_ENABLE: - return mfd_npm1300_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CTRL, ctrl, + case NPM13XX_GPIO_TYPE_ENABLE: + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_CTRL, ctrl, mask); - case NPM1300_GPIO_TYPE_PWM: - return mfd_npm1300_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_PWM_CTRL, ctrl, + case NPM13XX_GPIO_TYPE_PWM: + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_PWM_CTRL, ctrl, mask); - case NPM1300_GPIO_TYPE_RETENTION: - return mfd_npm1300_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_VRET_CTRL, ctrl, + case NPM13XX_GPIO_TYPE_RETENTION: + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_VRET_CTRL, ctrl, mask); default: return -ENOTSUP; } } -static int regulator_npm1300_set_ldsw_pin_ctrl(const struct device *dev, uint8_t chan, - const struct npm1300_gpio_info *pin_info, - enum npm1300_gpio_type type) +static int regulator_npm13xx_set_ldsw_pin_ctrl(const struct device *dev, uint8_t chan, + const struct npm13xx_gpio_info *pin_info, + enum npm13xx_gpio_type type) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t inv = pin_info->invert ? 1 : 0; uint8_t ctrl; - if (type != NPM1300_GPIO_TYPE_ENABLE) { + if (type != NPM13XX_GPIO_TYPE_ENABLE) { return -ENOTSUP; } ctrl = (pin_info->pin + 1U) | (inv << 3U); - return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_GPISEL + chan, ctrl); + return mfd_npm13xx_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_GPISEL + chan, ctrl); } -int regulator_npm1300_set_pin_ctrl(const struct device *dev, const struct npm1300_gpio_info *info, - enum npm1300_gpio_type type) +int regulator_npm13xx_set_pin_ctrl(const struct device *dev, const struct npm13xx_gpio_info *info, + enum npm13xx_gpio_type type) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; - if (info->pin == NPM1300_GPIO_UNUSED) { + if (info->pin == NPM13XX_GPIO_UNUSED) { return 0; } switch (config->source) { - case NPM1300_SOURCE_BUCK1: - return regulator_npm1300_set_buck_pin_ctrl(dev, 0, info, type); - case NPM1300_SOURCE_BUCK2: - return regulator_npm1300_set_buck_pin_ctrl(dev, 1, info, type); - case NPM1300_SOURCE_LDO1: - return regulator_npm1300_set_ldsw_pin_ctrl(dev, 0, info, type); - case NPM1300_SOURCE_LDO2: - return regulator_npm1300_set_ldsw_pin_ctrl(dev, 1, info, type); + case NPM13XX_SOURCE_BUCK1: + return regulator_npm13xx_set_buck_pin_ctrl(dev, 0, info, type); + case NPM13XX_SOURCE_BUCK2: + return regulator_npm13xx_set_buck_pin_ctrl(dev, 1, info, type); + case NPM13XX_SOURCE_LDO1: + return regulator_npm13xx_set_ldsw_pin_ctrl(dev, 0, info, type); + case NPM13XX_SOURCE_LDO2: + return regulator_npm13xx_set_ldsw_pin_ctrl(dev, 1, info, type); default: return -ENODEV; } } -int regulator_npm1300_dvs_state_set(const struct device *dev, regulator_dvs_state_t state) +int regulator_npm13xx_dvs_state_set(const struct device *dev, regulator_dvs_state_t state) { - const struct regulator_npm1300_pconfig *pconfig = dev->config; + const struct regulator_npm13xx_pconfig *pconfig = dev->config; const struct gpio_dt_spec *spec; int ret; @@ -514,21 +517,21 @@ int regulator_npm1300_dvs_state_set(const struct device *dev, regulator_dvs_stat return 0; } -int regulator_npm1300_ship_mode(const struct device *dev) +int regulator_npm13xx_ship_mode(const struct device *dev) { - const struct regulator_npm1300_pconfig *pconfig = dev->config; + const struct regulator_npm13xx_pconfig *pconfig = dev->config; - return mfd_npm1300_reg_write(pconfig->mfd, SHIP_BASE, SHIP_OFFSET_SHIP, 1U); + return mfd_npm13xx_reg_write(pconfig->mfd, SHIP_BASE, SHIP_OFFSET_SHIP, 1U); } static DEVICE_API(regulator_parent, parent_api) = { - .dvs_state_set = regulator_npm1300_dvs_state_set, - .ship_mode = regulator_npm1300_ship_mode, + .dvs_state_set = regulator_npm13xx_dvs_state_set, + .ship_mode = regulator_npm13xx_ship_mode, }; -int regulator_npm1300_common_init(const struct device *dev) +int regulator_npm13xx_common_init(const struct device *dev) { - const struct regulator_npm1300_pconfig *pconfig = dev->config; + const struct regulator_npm13xx_pconfig *pconfig = dev->config; const struct gpio_dt_spec *spec; int ret; @@ -553,10 +556,10 @@ int regulator_npm1300_common_init(const struct device *dev) static int get_enabled_reg(const struct device *dev, uint8_t base, uint8_t offset, uint8_t mask, bool *enabled) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; uint8_t data; - int ret = mfd_npm1300_reg_read(config->mfd, base, offset, &data); + int ret = mfd_npm13xx_reg_read(config->mfd, base, offset, &data); if (ret < 0) { return ret; @@ -569,16 +572,16 @@ static int get_enabled_reg(const struct device *dev, uint8_t base, uint8_t offse static int get_enabled(const struct device *dev, bool *enabled) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_BUCK1: + case NPM13XX_SOURCE_BUCK1: return get_enabled_reg(dev, BUCK_BASE, BUCK_OFFSET_STATUS, BUCK1_ON_MASK, enabled); - case NPM1300_SOURCE_BUCK2: + case NPM13XX_SOURCE_BUCK2: return get_enabled_reg(dev, BUCK_BASE, BUCK_OFFSET_STATUS, BUCK2_ON_MASK, enabled); - case NPM1300_SOURCE_LDO1: + case NPM13XX_SOURCE_LDO1: return get_enabled_reg(dev, LDSW_BASE, LDSW_OFFSET_STATUS, LDSW1_ON_MASK, enabled); - case NPM1300_SOURCE_LDO2: + case NPM13XX_SOURCE_LDO2: return get_enabled_reg(dev, LDSW_BASE, LDSW_OFFSET_STATUS, LDSW2_ON_MASK, enabled); default: return -ENODEV; @@ -587,15 +590,15 @@ static int get_enabled(const struct device *dev, bool *enabled) static int soft_start_set(const struct device *dev, uint8_t soft_start) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; switch (config->source) { - case NPM1300_SOURCE_LDO1: - return mfd_npm1300_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, + case NPM13XX_SOURCE_LDO1: + return mfd_npm13xx_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, soft_start << LDSW1_SOFTSTART_SHIFT, LDSW1_SOFTSTART_MASK); - case NPM1300_SOURCE_LDO2: - return mfd_npm1300_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, + case NPM13XX_SOURCE_LDO2: + return mfd_npm13xx_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, soft_start << LDSW2_SOFTSTART_SHIFT, LDSW2_SOFTSTART_MASK); default: @@ -603,9 +606,35 @@ static int soft_start_set(const struct device *dev, uint8_t soft_start) } } -int regulator_npm1300_init(const struct device *dev) +static int active_discharge_set(const struct device *dev, bool enabled) { - const struct regulator_npm1300_config *config = dev->config; + const struct regulator_npm13xx_config *config = dev->config; + + switch (config->source) { + case NPM13XX_SOURCE_BUCK1: + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_CTRL0, + enabled ? BUCK1_EN_PULLDOWN_MASK : 0, + BUCK1_EN_PULLDOWN_MASK); + case NPM13XX_SOURCE_BUCK2: + return mfd_npm13xx_reg_update(config->mfd, BUCK_BASE, BUCK_OFFSET_CTRL0, + enabled ? BUCK2_EN_PULLDOWN_MASK : 0, + BUCK2_EN_PULLDOWN_MASK); + case NPM13XX_SOURCE_LDO1: + return mfd_npm13xx_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, + enabled ? LDSW1_ACTIVE_DISCHARGE_MASK : 0, + LDSW1_ACTIVE_DISCHARGE_MASK); + case NPM13XX_SOURCE_LDO2: + return mfd_npm13xx_reg_update(config->mfd, LDSW_BASE, LDSW_OFFSET_CONFIG, + enabled ? LDSW2_ACTIVE_DISCHARGE_MASK : 0, + LDSW2_ACTIVE_DISCHARGE_MASK); + default: + return -ENODEV; + } +} + +int regulator_npm13xx_init(const struct device *dev) +{ + const struct regulator_npm13xx_config *config = dev->config; bool enabled; int ret = 0; @@ -639,49 +668,52 @@ int regulator_npm1300_init(const struct device *dev) } } - /* Configure GPIO pin control */ - ret = regulator_npm1300_set_pin_ctrl(dev, &config->enable_gpios, NPM1300_GPIO_TYPE_ENABLE); + /* Configure active discharge */ + ret = active_discharge_set(dev, config->active_discharge); if (ret != 0) { return ret; } - ret = regulator_npm1300_set_pin_ctrl(dev, &config->retention_gpios, - NPM1300_GPIO_TYPE_RETENTION); + /* Configure GPIO pin control */ + ret = regulator_npm13xx_set_pin_ctrl(dev, &config->enable_gpios, NPM13XX_GPIO_TYPE_ENABLE); if (ret != 0) { return ret; } - ret = regulator_npm1300_set_pin_ctrl(dev, &config->pwm_gpios, NPM1300_GPIO_TYPE_PWM); + ret = regulator_npm13xx_set_pin_ctrl(dev, &config->retention_gpios, + NPM13XX_GPIO_TYPE_RETENTION); if (ret != 0) { return ret; } + ret = regulator_npm13xx_set_pin_ctrl(dev, &config->pwm_gpios, NPM13XX_GPIO_TYPE_PWM); + return ret; } static DEVICE_API(regulator, api) = { - .enable = regulator_npm1300_enable, - .disable = regulator_npm1300_disable, - .count_voltages = regulator_npm1300_count_voltages, - .list_voltage = regulator_npm1300_list_voltage, - .set_voltage = regulator_npm1300_set_voltage, - .get_voltage = regulator_npm1300_get_voltage, - .set_mode = regulator_npm1300_set_mode, + .enable = regulator_npm13xx_enable, + .disable = regulator_npm13xx_disable, + .count_voltages = regulator_npm13xx_count_voltages, + .list_voltage = regulator_npm13xx_list_voltage, + .set_voltage = regulator_npm13xx_set_voltage, + .get_voltage = regulator_npm13xx_get_voltage, + .set_mode = regulator_npm13xx_set_mode, }; #define GPIO_CONFIG_DEFINE(node_id, prop) \ COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \ ({DT_PROP_BY_IDX(node_id, prop, 0), \ !!(DT_PROP_BY_IDX(node_id, prop, 1) & GPIO_ACTIVE_LOW)}), \ - ({NPM1300_GPIO_UNUSED, false})) + ({NPM13XX_GPIO_UNUSED, false})) -#define REGULATOR_NPM1300_DEFINE(node_id, id, _source) \ +#define REGULATOR_NPM13XX_DEFINE(partno, node_id, id, _source) \ BUILD_ASSERT(DT_PROP_LEN_OR(node_id, enable_gpio_config, 2) == 2); \ BUILD_ASSERT(DT_PROP_LEN_OR(node_id, retention_gpio_config, 2) == 2); \ BUILD_ASSERT(DT_PROP_LEN_OR(node_id, pwm_gpio_config, 2) == 2); \ - static struct regulator_npm1300_data data_##id; \ + static struct regulator_npm13xx_data regulator_##partno##_data_##id; \ \ - static const struct regulator_npm1300_config config_##id = { \ + static const struct regulator_npm13xx_config regulator_##partno##_config_##id = { \ .common = REGULATOR_DT_COMMON_CONFIG_INIT(node_id), \ .mfd = DEVICE_DT_GET(DT_GPARENT(node_id)), \ .source = _source, \ @@ -690,32 +722,42 @@ static DEVICE_API(regulator, api) = { .enable_gpios = GPIO_CONFIG_DEFINE(node_id, enable_gpio_config), \ .retention_gpios = GPIO_CONFIG_DEFINE(node_id, retention_gpio_config), \ .pwm_gpios = GPIO_CONFIG_DEFINE(node_id, pwm_gpio_config), \ + .active_discharge = DT_PROP(node_id, active_discharge), \ .ldo_disable_workaround = DT_PROP(node_id, nordic_anomaly38_disable_workaround)}; \ \ - DEVICE_DT_DEFINE(node_id, regulator_npm1300_init, NULL, &data_##id, &config_##id, \ - POST_KERNEL, CONFIG_REGULATOR_NPM1300_INIT_PRIORITY, &api); + DEVICE_DT_DEFINE(node_id, regulator_npm13xx_init, NULL, ®ulator_##partno##_data_##id, \ + ®ulator_##partno##_config_##id, POST_KERNEL, \ + CONFIG_REGULATOR_NPM13XX_INIT_PRIORITY, &api); -#define REGULATOR_NPM1300_DEFINE_COND(inst, child, source) \ - COND_CODE_1(DT_NODE_EXISTS(DT_INST_CHILD(inst, child)), \ - (REGULATOR_NPM1300_DEFINE(DT_INST_CHILD(inst, child), child##inst, source)), \ +#define REGULATOR_NPM13XX_DEFINE_COND(partno, n, child, source) \ + COND_CODE_1(DT_NODE_EXISTS(DT_INST_CHILD(n, child)), \ + (REGULATOR_NPM13XX_DEFINE(partno, DT_INST_CHILD(n, child), child##n, source)), \ ()) -#define REGULATOR_NPM1300_DEFINE_ALL(inst) \ - static const struct regulator_npm1300_pconfig config_##inst = { \ - .mfd = DEVICE_DT_GET(DT_INST_PARENT(inst)), \ - .dvs_state_pins = {GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 0, {0}), \ - GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 1, {0}), \ - GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 2, {0}), \ - GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 3, {0}), \ - GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 4, {0})}}; \ +#define REGULATOR_NPM13XX_DEFINE_ALL(partno, n) \ + static const struct regulator_npm13xx_pconfig regulator_##partno##_config##n = { \ + .mfd = DEVICE_DT_GET(DT_INST_PARENT(n)), \ + .dvs_state_pins = {GPIO_DT_SPEC_INST_GET_BY_IDX_OR(n, dvs_gpios, 0, {0}), \ + GPIO_DT_SPEC_INST_GET_BY_IDX_OR(n, dvs_gpios, 1, {0}), \ + GPIO_DT_SPEC_INST_GET_BY_IDX_OR(n, dvs_gpios, 2, {0}), \ + GPIO_DT_SPEC_INST_GET_BY_IDX_OR(n, dvs_gpios, 3, {0}), \ + GPIO_DT_SPEC_INST_GET_BY_IDX_OR(n, dvs_gpios, 4, {0})}}; \ \ - DEVICE_DT_INST_DEFINE(inst, regulator_npm1300_common_init, NULL, NULL, &config_##inst, \ - POST_KERNEL, CONFIG_REGULATOR_NPM1300_COMMON_INIT_PRIORITY, \ + DEVICE_DT_INST_DEFINE(n, regulator_npm13xx_common_init, NULL, NULL, \ + ®ulator_##partno##_config##n, POST_KERNEL, \ + CONFIG_REGULATOR_NPM13XX_COMMON_INIT_PRIORITY, \ &parent_api); \ \ - REGULATOR_NPM1300_DEFINE_COND(inst, buck1, NPM1300_SOURCE_BUCK1) \ - REGULATOR_NPM1300_DEFINE_COND(inst, buck2, NPM1300_SOURCE_BUCK2) \ - REGULATOR_NPM1300_DEFINE_COND(inst, ldo1, NPM1300_SOURCE_LDO1) \ - REGULATOR_NPM1300_DEFINE_COND(inst, ldo2, NPM1300_SOURCE_LDO2) + REGULATOR_NPM13XX_DEFINE_COND(partno, n, buck1, NPM13XX_SOURCE_BUCK1) \ + REGULATOR_NPM13XX_DEFINE_COND(partno, n, buck2, NPM13XX_SOURCE_BUCK2) \ + REGULATOR_NPM13XX_DEFINE_COND(partno, n, ldo1, NPM13XX_SOURCE_LDO1) \ + REGULATOR_NPM13XX_DEFINE_COND(partno, n, ldo2, NPM13XX_SOURCE_LDO2) +#define DT_DRV_COMPAT nordic_npm1300_regulator +#define REGULATOR_NPM1300_DEFINE_ALL(n) REGULATOR_NPM13XX_DEFINE_ALL(npm1300, n) DT_INST_FOREACH_STATUS_OKAY(REGULATOR_NPM1300_DEFINE_ALL) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304_regulator +#define REGULATOR_NPM1304_DEFINE_ALL(n) REGULATOR_NPM13XX_DEFINE_ALL(npm1304, n) +DT_INST_FOREACH_STATUS_OKAY(REGULATOR_NPM1304_DEFINE_ALL) diff --git a/drivers/sensor/nordic/CMakeLists.txt b/drivers/sensor/nordic/CMakeLists.txt index 49a0a48d7fd9..bd72ded9ccc2 100644 --- a/drivers/sensor/nordic/CMakeLists.txt +++ b/drivers/sensor/nordic/CMakeLists.txt @@ -3,7 +3,7 @@ # zephyr-keep-sorted-start add_subdirectory(temp) -add_subdirectory_ifdef(CONFIG_NPM1300_CHARGER npm1300_charger) +add_subdirectory_ifdef(CONFIG_NPM13XX_CHARGER npm13xx_charger) add_subdirectory_ifdef(CONFIG_NPM2100_VBAT npm2100_vbat) add_subdirectory_ifdef(CONFIG_QDEC_NRFX qdec_nrfx) # zephyr-keep-sorted-stop diff --git a/drivers/sensor/nordic/Kconfig b/drivers/sensor/nordic/Kconfig index 0cdbaaf41e71..717c941973f9 100644 --- a/drivers/sensor/nordic/Kconfig +++ b/drivers/sensor/nordic/Kconfig @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # zephyr-keep-sorted-start -source "drivers/sensor/nordic/npm1300_charger/Kconfig" +source "drivers/sensor/nordic/npm13xx_charger/Kconfig" source "drivers/sensor/nordic/npm2100_vbat/Kconfig" source "drivers/sensor/nordic/qdec_nrfx/Kconfig" source "drivers/sensor/nordic/temp/Kconfig" diff --git a/drivers/sensor/nordic/npm1300_charger/Kconfig b/drivers/sensor/nordic/npm1300_charger/Kconfig deleted file mode 100644 index abafa5309504..000000000000 --- a/drivers/sensor/nordic/npm1300_charger/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: Apache-2.0 - -config NPM1300_CHARGER - bool "NPM1300 Charger" - default y - depends on DT_HAS_NORDIC_NPM1300_CHARGER_ENABLED - select I2C - select MFD - select REQUIRES_FULL_LIBC - help - Enable NPM1300 charger driver. diff --git a/drivers/sensor/nordic/npm1300_charger/CMakeLists.txt b/drivers/sensor/nordic/npm13xx_charger/CMakeLists.txt similarity index 71% rename from drivers/sensor/nordic/npm1300_charger/CMakeLists.txt rename to drivers/sensor/nordic/npm13xx_charger/CMakeLists.txt index 51083775eff7..512e0f9eecd4 100644 --- a/drivers/sensor/nordic/npm1300_charger/CMakeLists.txt +++ b/drivers/sensor/nordic/npm13xx_charger/CMakeLists.txt @@ -4,4 +4,4 @@ zephyr_library() -zephyr_library_sources(npm1300_charger.c) +zephyr_library_sources(npm13xx_charger.c) diff --git a/drivers/sensor/nordic/npm13xx_charger/Kconfig b/drivers/sensor/nordic/npm13xx_charger/Kconfig new file mode 100644 index 000000000000..a113a4ede474 --- /dev/null +++ b/drivers/sensor/nordic/npm13xx_charger/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 + +config NPM13XX_CHARGER + bool "nPM13xx Charger" + default y + depends on DT_HAS_NORDIC_NPM1300_CHARGER_ENABLED || DT_HAS_NORDIC_NPM1304_CHARGER_ENABLED + select I2C + select MFD + select REQUIRES_FULL_LIBC + help + Enable nPM13xx charger driver. diff --git a/drivers/sensor/nordic/npm1300_charger/npm1300_charger.c b/drivers/sensor/nordic/npm13xx_charger/npm13xx_charger.c similarity index 63% rename from drivers/sensor/nordic/npm1300_charger/npm1300_charger.c rename to drivers/sensor/nordic/npm13xx_charger/npm13xx_charger.c index a5b2a0b1054b..08e2763e6558 100644 --- a/drivers/sensor/nordic/npm1300_charger/npm1300_charger.c +++ b/drivers/sensor/nordic/npm13xx_charger/npm13xx_charger.c @@ -3,20 +3,21 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_npm1300_charger - #include #include -#include +#include #include #include -#include +#include -struct npm1300_charger_config { +struct npm13xx_charger_config { const struct device *mfd; int32_t term_microvolt; int32_t term_warm_microvolt; + const struct linear_range term_volt_ranges[2U]; int32_t current_microamp; + const struct linear_range current_range; + const int32_t full_scale_discharge_factors[2U]; int32_t dischg_limit_microamp; uint8_t dischg_limit_idx; int32_t vbus_limit_microamp; @@ -32,7 +33,7 @@ struct npm1300_charger_config { bool disable_recharge; }; -struct npm1300_charger_data { +struct npm13xx_charger_data { uint16_t voltage; uint16_t current; uint16_t temp; @@ -43,12 +44,12 @@ struct npm1300_charger_data { uint8_t vbus_stat; }; -/* nPM1300 base addresses */ +/* nPM13xx base addresses */ #define CHGR_BASE 0x03U #define ADC_BASE 0x05U #define VBUS_BASE 0x02U -/* nPM1300 charger register offsets */ +/* nPM13xx charger register offsets */ #define CHGR_OFFSET_ERR_CLR 0x00U #define CHGR_OFFSET_EN_SET 0x04U #define CHGR_OFFSET_EN_CLR 0x05U @@ -65,7 +66,7 @@ struct npm1300_charger_data { #define CHGR_OFFSET_ERR_REASON 0x36U #define CHGR_OFFSET_VBATLOW_EN 0x50U -/* nPM1300 ADC register offsets */ +/* nPM13xx ADC register offsets */ #define ADC_OFFSET_TASK_VBAT 0x00U #define ADC_OFFSET_TASK_TEMP 0x01U #define ADC_OFFSET_TASK_DIE 0x02U @@ -75,7 +76,7 @@ struct npm1300_charger_data { #define ADC_OFFSET_RESULTS 0x10U #define ADC_OFFSET_IBAT_EN 0x24U -/* nPM1300 VBUS register offsets */ +/* nPM13xx VBUS register offsets */ #define VBUS_OFFSET_ILIMUPDATE 0x00U #define VBUS_OFFSET_ILIM 0x01U #define VBUS_OFFSET_ILIMSTARTUP 0x02U @@ -137,19 +138,27 @@ struct adc_results_t { #define DIETEMP_FACTOR_DIV 5000 /* Linear range for charger terminal voltage */ -static const struct linear_range charger_volt_ranges[] = { - LINEAR_RANGE_INIT(3500000, 50000, 0U, 3U), LINEAR_RANGE_INIT(4000000, 50000, 4U, 13U)}; +#define NPM1300_CHARGER_VOLT_RANGES \ + {LINEAR_RANGE_INIT(3500000, 50000, 0U, 3U), LINEAR_RANGE_INIT(4000000, 50000, 4U, 13U)} +#define NPM1304_CHARGER_VOLT_RANGES \ + {LINEAR_RANGE_INIT(3600000, 50000, 0U, 1U), LINEAR_RANGE_INIT(4000000, 50000, 2U, 15U)} /* Linear range for charger current */ -static const struct linear_range charger_current_range = LINEAR_RANGE_INIT(32000, 2000, 16U, 400U); +#define NPM1300_CHARGER_CURRENT_RANGE LINEAR_RANGE_INIT(32000, 2000, 16U, 400U) +#define NPM1304_CHARGER_CURRENT_RANGE LINEAR_RANGE_INIT(4000, 500, 8U, 200U) + +/* Full-scale factors for calculating current */ +#define NPM1300_FULL_SCALE_DISCHARGE_FACTORS {112, 100} +#define NPM1304_FULL_SCALE_DISCHARGE_FACTORS {415, 400} +static const int32_t full_scale_charge_factors[] = {125, 100}; /* Allowed values for discharge limit */ -static const uint16_t discharge_limits[] = {84U, 415U}; +static const uint16_t npm1300_discharge_limits[] = {84U, 415U}; /* Linear range for vbusin current limit */ static const struct linear_range vbus_current_range = LINEAR_RANGE_INIT(100000, 100000, 1U, 15U); -static void calc_temp(const struct npm1300_charger_config *const config, uint16_t code, +static void calc_temp(const struct npm13xx_charger_config *const config, uint16_t code, struct sensor_value *valp) { /* Ref: PS v1.2 Section 7.1.4: Battery temperature (Kelvin) */ @@ -161,7 +170,7 @@ static void calc_temp(const struct npm1300_charger_config *const config, uint16_ (void)sensor_value_from_float(valp, temp); } -static void calc_dietemp(const struct npm1300_charger_config *const config, uint16_t code, +static void calc_dietemp(const struct npm13xx_charger_config *const config, uint16_t code, struct sensor_value *valp) { /* Ref: PS v1.2 Section 7.1.4: Die temperature (Celsius) */ @@ -171,7 +180,7 @@ static void calc_dietemp(const struct npm1300_charger_config *const config, uint (void)sensor_value_from_milli(valp, temp); } -static uint32_t calc_ntc_res(const struct npm1300_charger_config *const config, int32_t temp_mdegc) +static uint32_t calc_ntc_res(const struct npm13xx_charger_config *const config, int32_t temp_mdegc) { float inv_t0 = 1.f / 298.15f; float temp = (float)temp_mdegc / 1000.f; @@ -187,56 +196,64 @@ static uint16_t adc_get_res(uint8_t msb, uint8_t lsb, uint16_t lsb_shift) return ((uint16_t)msb << ADC_MSB_SHIFT) | ((lsb >> lsb_shift) & ADC_LSB_MASK); } -static void calc_current(const struct npm1300_charger_config *const config, - struct npm1300_charger_data *const data, struct sensor_value *valp) +static void calc_current(const struct npm13xx_charger_config *const config, + struct npm13xx_charger_data *const data, struct sensor_value *valp) { int32_t full_scale_ua; int32_t current_ua; - /* Largest value of discharge limit and charge limit is 1A. - * We can therefore guarantee that multiplying the uA by 1000 does not overflow. - * 1000 * 1'000'000 uA < 2**31 - * 1000000000 < 2147483648 - */ switch (data->ibat_stat) { case IBAT_STAT_DISCHARGE: - /* Ref: PS v1.2 Section 7.1.7: Full scale multiplied by 1.12 */ - full_scale_ua = -(1000 * config->dischg_limit_microamp) / 893; + /* nPM1300: Largest discharge limit is 1A. Multiplying it by 112 will not overflow. + * 112 * -1_000_000 > INT32_MIN + * -112_000_000 > -2_147_483_648 + * nPM1304: Discharge limit is 125mA. Multiplying it by 415 will not overflow. + * 415 * -125_000 > INT32_MIN + * -51_875_000 > -2_147_483_648 + */ + full_scale_ua = -config->dischg_limit_microamp * + config->full_scale_discharge_factors[0] / + config->full_scale_discharge_factors[1]; break; case IBAT_STAT_CHARGE_TRICKLE: /* Fallthrough */ case IBAT_STAT_CHARGE_COOL: /* Fallthrough */ case IBAT_STAT_CHARGE_NORMAL: - /* Ref: PS v1.2 Section 7.1.7: Full scale multiplied by 1.25 */ - full_scale_ua = (1000 * config->current_microamp) / 800; + /* nPM1300: Largest charge limit is 800mA. Multiplying it by 125 will not overflow. + * 125 * 800_000 < INT32_MAX + * 100_000_000 < 2_147_483_647 + * nPM1304: Largest charge limit is even lower - no overflow. + */ + full_scale_ua = config->current_microamp * full_scale_charge_factors[0] / + full_scale_charge_factors[1]; break; default: full_scale_ua = 0; break; } - /* Largest possible value for data->current is 1023 - * Limits for full_scale_ua are -1'119'820 and 1'000'000 - * 1023 * -1119820 > -2**31 - * -1145575860 > -2147483648 - * 1023 * 1000000 < 2**31 - * 1023000000 < 2147483648 + /* Largest possible value for data->current is 1023 (10-bit ADC) + * Limits for full_scale_ua are -1_120_000 and 1_000_000 + * 1023 * -1_120_000 > INT32_MIN + * -1_145_760_000 > -2_147_483_648 + * 1023 * 1_000_000 < INT32_MAX + * 1_023_000_000 < 2_147_483_647 */ __ASSERT_NO_MSG(data->current <= 1023); __ASSERT_NO_MSG(full_scale_ua <= 1000000); - __ASSERT_NO_MSG(full_scale_ua >= -1119820); + __ASSERT_NO_MSG(full_scale_ua >= -1120000); - current_ua = (data->current * full_scale_ua) / 1024; + current_ua = (data->current * full_scale_ua) / 1023; (void)sensor_value_from_micro(valp, current_ua); } -int npm1300_charger_channel_get(const struct device *dev, enum sensor_channel chan, +int npm13xx_charger_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *valp) { - const struct npm1300_charger_config *const config = dev->config; - struct npm1300_charger_data *const data = dev->data; + const struct npm13xx_charger_config *const config = dev->config; + struct npm13xx_charger_data *const data = dev->data; switch ((uint32_t)chan) { case SENSOR_CHAN_GAUGE_VOLTAGE: @@ -251,11 +268,11 @@ int npm1300_charger_channel_get(const struct device *dev, enum sensor_channel ch case SENSOR_CHAN_GAUGE_AVG_CURRENT: calc_current(config, data, valp); break; - case SENSOR_CHAN_NPM1300_CHARGER_STATUS: + case SENSOR_CHAN_NPM13XX_CHARGER_STATUS: valp->val1 = data->status; valp->val2 = 0; break; - case SENSOR_CHAN_NPM1300_CHARGER_ERROR: + case SENSOR_CHAN_NPM13XX_CHARGER_ERROR: valp->val1 = data->error; valp->val2 = 0; break; @@ -268,7 +285,7 @@ int npm1300_charger_channel_get(const struct device *dev, enum sensor_channel ch case SENSOR_CHAN_DIE_TEMP: calc_dietemp(config, data->dietemp, valp); break; - case SENSOR_CHAN_NPM1300_CHARGER_VBUS_STATUS: + case SENSOR_CHAN_NPM13XX_CHARGER_VBUS_STATUS: valp->val1 = data->vbus_stat; valp->val2 = 0; break; @@ -279,26 +296,26 @@ int npm1300_charger_channel_get(const struct device *dev, enum sensor_channel ch return 0; } -int npm1300_charger_sample_fetch(const struct device *dev, enum sensor_channel chan) +int npm13xx_charger_sample_fetch(const struct device *dev, enum sensor_channel chan) { - const struct npm1300_charger_config *const config = dev->config; - struct npm1300_charger_data *data = dev->data; + const struct npm13xx_charger_config *const config = dev->config; + struct npm13xx_charger_data *data = dev->data; struct adc_results_t results; int ret; /* Read charge status and error reason */ - ret = mfd_npm1300_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_CHG_STAT, &data->status); + ret = mfd_npm13xx_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_CHG_STAT, &data->status); if (ret != 0) { return ret; } - ret = mfd_npm1300_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_ERR_REASON, &data->error); + ret = mfd_npm13xx_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_ERR_REASON, &data->error); if (ret != 0) { return ret; } /* Read adc results */ - ret = mfd_npm1300_reg_read_burst(config->mfd, ADC_BASE, ADC_OFFSET_RESULTS, &results, + ret = mfd_npm13xx_reg_read_burst(config->mfd, ADC_BASE, ADC_OFFSET_RESULTS, &results, sizeof(results)); if (ret != 0) { return ret; @@ -311,27 +328,24 @@ int npm1300_charger_sample_fetch(const struct device *dev, enum sensor_channel c data->ibat_stat = results.ibat_stat; /* Trigger ntc and die temperature measurements */ - ret = mfd_npm1300_reg_write2(config->mfd, ADC_BASE, ADC_OFFSET_TASK_TEMP, 1U, 1U); + ret = mfd_npm13xx_reg_write2(config->mfd, ADC_BASE, ADC_OFFSET_TASK_TEMP, 1U, 1U); if (ret != 0) { return ret; } /* Trigger current and voltage measurement */ - ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_VBAT, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_VBAT, 1U); if (ret != 0) { return ret; } /* Read vbus status */ - ret = mfd_npm1300_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_STATUS, &data->vbus_stat); - if (ret != 0) { - return ret; - } + ret = mfd_npm13xx_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_STATUS, &data->vbus_stat); return ret; } -static int set_ntc_thresholds(const struct npm1300_charger_config *const config) +static int set_ntc_thresholds(const struct npm13xx_charger_config *const config) { for (uint8_t idx = 0U; idx < 4U; idx++) { if (config->temp_thresholds[idx] < INT32_MAX) { @@ -340,7 +354,7 @@ static int set_ntc_thresholds(const struct npm1300_charger_config *const config) /* Ref: Datasheet Figure 14: Equation for battery temperature */ uint16_t code = (1024 * res) / (res + config->thermistor_ohms); - int ret = mfd_npm1300_reg_write2( + int ret = mfd_npm13xx_reg_write2( config->mfd, CHGR_BASE, CHGR_OFFSET_NTC_TEMPS + (idx * 2U), code >> NTCTEMP_MSB_SHIFT, code & NTCTEMP_LSB_MASK); @@ -353,7 +367,7 @@ static int set_ntc_thresholds(const struct npm1300_charger_config *const config) return 0; } -static int set_dietemp_thresholds(const struct npm1300_charger_config *const config) +static int set_dietemp_thresholds(const struct npm13xx_charger_config *const config) { for (uint8_t idx = 0U; idx < 2U; idx++) { if (config->dietemp_thresholds[idx] < INT32_MAX) { @@ -363,7 +377,7 @@ static int set_dietemp_thresholds(const struct npm1300_charger_config *const con DIETEMP_FACTOR_DIV; uint16_t code = DIV_ROUND_CLOSEST(numerator, DIETEMP_FACTOR_MUL); - int ret = mfd_npm1300_reg_write2( + int ret = mfd_npm13xx_reg_write2( config->mfd, CHGR_BASE, CHGR_OFFSET_DIE_TEMPS + (idx * 2U), code >> DIETEMP_MSB_SHIFT, code & DIETEMP_LSB_MASK); @@ -376,10 +390,10 @@ static int set_dietemp_thresholds(const struct npm1300_charger_config *const con return 0; } -static int npm1300_charger_attr_get(const struct device *dev, enum sensor_channel chan, +static int npm13xx_charger_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) { - const struct npm1300_charger_config *const config = dev->config; + const struct npm13xx_charger_config *const config = dev->config; uint8_t data; int ret; @@ -389,7 +403,7 @@ static int npm1300_charger_attr_get(const struct device *dev, enum sensor_channe return -ENOTSUP; } - ret = mfd_npm1300_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, &data); + ret = mfd_npm13xx_reg_read(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, &data); if (ret == 0) { val->val1 = data; val->val2 = 0U; @@ -401,7 +415,7 @@ static int npm1300_charger_attr_get(const struct device *dev, enum sensor_channe return -ENOTSUP; } - ret = mfd_npm1300_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_DETECT, &data); + ret = mfd_npm13xx_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_DETECT, &data); if (ret < 0) { return ret; } @@ -418,29 +432,29 @@ static int npm1300_charger_attr_get(const struct device *dev, enum sensor_channe return 0; - case SENSOR_CHAN_NPM1300_CHARGER_VBUS_STATUS: - ret = mfd_npm1300_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_STATUS, &data); + case SENSOR_CHAN_NPM13XX_CHARGER_VBUS_STATUS: + ret = mfd_npm13xx_reg_read(config->mfd, VBUS_BASE, VBUS_OFFSET_STATUS, &data); if (ret < 0) { return ret; } - switch ((enum sensor_attribute_npm1300_charger)attr) { - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_PRESENT: + switch ((enum sensor_attribute_npm13xx_charger)attr) { + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_PRESENT: val->val1 = (data & STATUS_PRESENT_MASK) != 0; break; - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_CUR_LIMIT: + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_CUR_LIMIT: val->val1 = (data & STATUS_CUR_LIMIT_MASK) != 0; break; - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_OVERVLT_PROT: + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_OVERVLT_PROT: val->val1 = (data & STATUS_OVERVLT_PROT_MASK) != 0; break; - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_UNDERVLT: + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_UNDERVLT: val->val1 = (data & STATUS_UNDERVLT_MASK) != 0; break; - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_SUSPENDED: + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_SUSPENDED: val->val1 = (data & STATUS_SUSPENDED_MASK) != 0; break; - case SENSOR_ATTR_NPM1300_CHARGER_VBUS_BUSOUT: + case SENSOR_ATTR_NPM13XX_CHARGER_VBUS_BUSOUT: val->val1 = (data & STATUS_BUSOUT_MASK) != 0; break; default: @@ -454,10 +468,10 @@ static int npm1300_charger_attr_get(const struct device *dev, enum sensor_channe } } -static int npm1300_charger_attr_set(const struct device *dev, enum sensor_channel chan, +static int npm13xx_charger_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { - const struct npm1300_charger_config *const config = dev->config; + const struct npm13xx_charger_config *const config = dev->config; int ret; if (attr != SENSOR_ATTR_CONFIGURATION) { @@ -468,16 +482,16 @@ static int npm1300_charger_attr_set(const struct device *dev, enum sensor_channe case SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT: if (val->val1 == 0) { /* Disable charging */ - return mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_CLR, + return mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_CLR, 1U); } /* Clear any errors and enable charging */ - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_ERR_CLR, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_ERR_CLR, 1U); if (ret != 0) { return ret; } - return mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, 1U); + return mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, 1U); case SENSOR_CHAN_CURRENT: /* Set vbus current limit */ @@ -490,22 +504,22 @@ static int npm1300_charger_attr_set(const struct device *dev, enum sensor_channe return ret; } - ret = mfd_npm1300_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIM, idx); + ret = mfd_npm13xx_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIM, idx); if (ret != 0) { return ret; } /* Switch to new current limit, this will be reset automatically on USB removal */ - return mfd_npm1300_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIMUPDATE, 1U); + return mfd_npm13xx_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIMUPDATE, 1U); default: return -ENOTSUP; } } -int npm1300_charger_init(const struct device *dev) +int npm13xx_charger_init(const struct device *dev) { - const struct npm1300_charger_config *const config = dev->config; + const struct npm13xx_charger_config *const config = dev->config; uint16_t idx; uint8_t byte = 0U; int ret; @@ -515,7 +529,7 @@ int npm1300_charger_init(const struct device *dev) } /* Configure temperature thresholds */ - ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_NTCR_SEL, + ret = mfd_npm13xx_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_NTCR_SEL, config->thermistor_idx); if (ret != 0) { return ret; @@ -532,46 +546,53 @@ int npm1300_charger_init(const struct device *dev) } /* Configure termination voltages */ - ret = linear_range_group_get_win_index(charger_volt_ranges, ARRAY_SIZE(charger_volt_ranges), - config->term_microvolt, config->term_microvolt, - &idx); + ret = linear_range_group_get_win_index( + config->term_volt_ranges, ARRAY_SIZE(config->term_volt_ranges), + config->term_microvolt, config->term_microvolt, &idx); if (ret == -EINVAL) { return ret; } - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VTERM, idx); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VTERM, idx); if (ret != 0) { return ret; } - ret = linear_range_group_get_win_index(charger_volt_ranges, ARRAY_SIZE(charger_volt_ranges), - config->term_warm_microvolt, - config->term_warm_microvolt, &idx); + ret = linear_range_group_get_win_index( + config->term_volt_ranges, ARRAY_SIZE(config->term_volt_ranges), + config->term_warm_microvolt, config->term_warm_microvolt, &idx); if (ret == -EINVAL) { return ret; } - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VTERM_R, idx); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VTERM_R, idx); if (ret != 0) { return ret; } /* Set current, allow rounding down to closest value */ - ret = linear_range_get_win_index(&charger_current_range, - config->current_microamp - charger_current_range.step, + ret = linear_range_get_win_index(&config->current_range, + config->current_microamp - config->current_range.step + 1, config->current_microamp, &idx); if (ret == -EINVAL) { return ret; } - ret = mfd_npm1300_reg_write2(config->mfd, CHGR_BASE, CHGR_OFFSET_ISET, idx / 2U, idx & 1U); - if (ret != 0) { - return ret; - } + if (config->dischg_limit_idx == UINT8_MAX) { + /* Set only charge current MSB for nPM1304 */ + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_ISET, idx); + } else { + /* Set charge current MSB and LSB and discharge limit for nPM1300 */ + ret = mfd_npm13xx_reg_write2(config->mfd, CHGR_BASE, CHGR_OFFSET_ISET, idx / 2U, + idx & 1U); + if (ret != 0) { + return ret; + } - /* Set discharge limit */ - ret = mfd_npm1300_reg_write2(config->mfd, CHGR_BASE, CHGR_OFFSET_ISET_DISCHG, - discharge_limits[config->dischg_limit_idx] / 2U, - discharge_limits[config->dischg_limit_idx] & 1U); + ret = mfd_npm13xx_reg_write2( + config->mfd, CHGR_BASE, CHGR_OFFSET_ISET_DISCHG, + npm1300_discharge_limits[config->dischg_limit_idx] / 2U, + npm1300_discharge_limits[config->dischg_limit_idx] & 1U); + } if (ret != 0) { return ret; } @@ -582,52 +603,52 @@ int npm1300_charger_init(const struct device *dev) if (ret == -EINVAL) { return ret; } - ret = mfd_npm1300_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIMSTARTUP, idx); + ret = mfd_npm13xx_reg_write(config->mfd, VBUS_BASE, VBUS_OFFSET_ILIMSTARTUP, idx); if (ret != 0) { return ret; } /* Configure trickle voltage threshold */ - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_TRICKLE_SEL, + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_TRICKLE_SEL, config->trickle_sel); if (ret != 0) { return ret; } /* Configure termination current */ - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_ITERM_SEL, + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_ITERM_SEL, config->iterm_sel); if (ret != 0) { return ret; } /* Enable current measurement */ - ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_IBAT_EN, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_IBAT_EN, 1U); if (ret != 0) { return ret; } /* Trigger current and voltage measurement */ - ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_VBAT, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_VBAT, 1U); if (ret != 0) { return ret; } /* Trigger ntc and die temperature measurements */ - ret = mfd_npm1300_reg_write2(config->mfd, ADC_BASE, ADC_OFFSET_TASK_TEMP, 1U, 1U); + ret = mfd_npm13xx_reg_write2(config->mfd, ADC_BASE, ADC_OFFSET_TASK_TEMP, 1U, 1U); if (ret != 0) { return ret; } /* Enable automatic temperature measurements during charging */ - ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_AUTO, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_TASK_AUTO, 1U); if (ret != 0) { return ret; } /* Enable charging at low battery if configured */ if (config->vbatlow_charge_enable) { - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VBATLOW_EN, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_VBATLOW_EN, 1U); if (ret != 0) { return ret; } @@ -643,14 +664,14 @@ int npm1300_charger_init(const struct device *dev) WRITE_BIT(byte, 1U, true); } - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_DIS_SET, byte); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_DIS_SET, byte); if (ret != 0) { return ret; } /* Enable charging if configured */ if (config->charging_enable) { - ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_EN_SET, 1U); if (ret != 0) { return ret; } @@ -659,26 +680,30 @@ int npm1300_charger_init(const struct device *dev) return 0; } -static DEVICE_API(sensor, npm1300_charger_battery_driver_api) = { - .sample_fetch = npm1300_charger_sample_fetch, - .channel_get = npm1300_charger_channel_get, - .attr_set = npm1300_charger_attr_set, - .attr_get = npm1300_charger_attr_get, +static DEVICE_API(sensor, npm13xx_charger_battery_driver_api) = { + .sample_fetch = npm13xx_charger_sample_fetch, + .channel_get = npm13xx_charger_channel_get, + .attr_set = npm13xx_charger_attr_set, + .attr_get = npm13xx_charger_attr_get, }; -#define NPM1300_CHARGER_INIT(n) \ - BUILD_ASSERT(DT_INST_ENUM_IDX(n, dischg_limit_microamp) < ARRAY_SIZE(discharge_limits)); \ +#define NPM13XX_CHARGER_INIT(partno, n) \ + BUILD_ASSERT(DT_INST_ENUM_IDX_OR(n, dischg_limit_microamp, 0) < \ + ARRAY_SIZE(npm1300_discharge_limits)); \ \ - static struct npm1300_charger_data npm1300_charger_data_##n; \ + static struct npm13xx_charger_data charger_##partno##_data##n; \ \ - static const struct npm1300_charger_config npm1300_charger_config_##n = { \ + static const struct npm13xx_charger_config charger_##partno##_config##n = { \ .mfd = DEVICE_DT_GET(DT_INST_PARENT(n)), \ .term_microvolt = DT_INST_PROP(n, term_microvolt), \ .term_warm_microvolt = \ DT_INST_PROP_OR(n, term_warm_microvolt, DT_INST_PROP(n, term_microvolt)), \ + .term_volt_ranges = partno##_CHARGER_VOLT_RANGES, \ .current_microamp = DT_INST_PROP(n, current_microamp), \ + .current_range = partno##_CHARGER_CURRENT_RANGE, \ + .full_scale_discharge_factors = partno##_FULL_SCALE_DISCHARGE_FACTORS, \ .dischg_limit_microamp = DT_INST_PROP(n, dischg_limit_microamp), \ - .dischg_limit_idx = DT_INST_ENUM_IDX(n, dischg_limit_microamp), \ + .dischg_limit_idx = DT_INST_ENUM_IDX_OR(n, dischg_limit_microamp, UINT8_MAX), \ .vbus_limit_microamp = DT_INST_PROP(n, vbus_limit_microamp), \ .thermistor_ohms = DT_INST_PROP(n, thermistor_ohms), \ .thermistor_idx = DT_INST_ENUM_IDX(n, thermistor_ohms), \ @@ -696,9 +721,17 @@ static DEVICE_API(sensor, npm1300_charger_battery_driver_api) = { DT_INST_PROP_OR(n, thermistor_warm_millidegrees, INT32_MAX), \ DT_INST_PROP_OR(n, thermistor_hot_millidegrees, INT32_MAX)}}; \ \ - SENSOR_DEVICE_DT_INST_DEFINE(n, &npm1300_charger_init, NULL, &npm1300_charger_data_##n, \ - &npm1300_charger_config_##n, POST_KERNEL, \ + SENSOR_DEVICE_DT_INST_DEFINE(n, &npm13xx_charger_init, NULL, &charger_##partno##_data##n, \ + &charger_##partno##_config##n, POST_KERNEL, \ CONFIG_SENSOR_INIT_PRIORITY, \ - &npm1300_charger_battery_driver_api); + &npm13xx_charger_battery_driver_api); +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1300_charger +#define NPM1300_CHARGER_INIT(n) NPM13XX_CHARGER_INIT(NPM1300, n) DT_INST_FOREACH_STATUS_OKAY(NPM1300_CHARGER_INIT) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304_charger +#define NPM1304_CHARGER_INIT(n) NPM13XX_CHARGER_INIT(NPM1304, n) +DT_INST_FOREACH_STATUS_OKAY(NPM1304_CHARGER_INIT) diff --git a/drivers/serial/Kconfig.nrfx b/drivers/serial/Kconfig.nrfx index 3fb1f0fd1203..f91980c058b5 100644 --- a/drivers/serial/Kconfig.nrfx +++ b/drivers/serial/Kconfig.nrfx @@ -28,6 +28,13 @@ config UART_NRFX_UARTE imply NRFX_UARTE_CONFIG_SKIP_PSEL_CONFIG if !UART_NRFX_UARTE_LEGACY_SHIM imply NRFX_UARTE_CONFIG_SKIP_GPIO_CONFIG if !UART_NRFX_UARTE_LEGACY_SHIM +config UART_NRFX_UARTE_USE_CLOCK_CONTROL + def_bool y + depends on UART_NRFX_UARTE + depends on $(dt_nodelabel_enabled,uart120) + depends on !SOC_NRF54H20_CPUFLPR && !SOC_NRF54H20_CPUPPR + select CLOCK_CONTROL + config UART_NRFX_UARTE_NO_IRQ bool "Polling without interrupt" depends on UART_NRFX_UARTE @@ -135,11 +142,6 @@ rsource "Kconfig.nrfx_uart_instance" endif if HAS_HW_NRF_UARTE120 - -config UART_NRFX_UARTE_USE_CLOCK_CONTROL - def_bool y - select CLOCK_CONTROL - nrfx_uart_num = 120 rsource "Kconfig.nrfx_uart_instance" endif diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 05ffa4535706..46c5a8b83d2e 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -95,6 +95,17 @@ LOG_MODULE_REGISTER(uart_nrfx_uarte, CONFIG_UART_LOG_LEVEL); #define UARTE_HAS_FRAME_TIMEOUT 1 #endif +/* Frame timeout has a bug that countdown counter may not be triggered in some + * specific condition. It may happen if RX is manually started after ENDRX (STOPRX + * task was not triggered) and there is ongoing reception of a byte. RXDRDY event + * triggered by the reception of that byte may not trigger frame timeout counter. + * If this is the last byte of a transfer then without the workaround there will + * be no expected RX timeout. + */ +#ifdef UARTE_HAS_FRAME_TIMEOUT +#define RX_FRAMETIMEOUT_WORKAROUND 1 +#endif + #define INSTANCE_NEEDS_CACHE_MGMT(unused, prefix, i, prop) UARTE_IS_CACHEABLE(prefix##i) #if UARTE_FOR_EACH_INSTANCE(INSTANCE_NEEDS_CACHE_MGMT, (+), (0), _) @@ -118,10 +129,11 @@ LOG_MODULE_REGISTER(uart_nrfx_uarte, CONFIG_UART_LOG_LEVEL); (0))), (0)) #if UARTE_FOR_EACH_INSTANCE(INSTANCE_IS_FAST_PD, (||), (0)) -/* Instance in fast power domain (PD) requires special PM treatment so device runtime PM must - * be enabled. +/* Instance in fast power domain (PD) requires special PM treatment and clock control, so + * device runtime PM and clock control must be enabled. */ BUILD_ASSERT(IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)); +BUILD_ASSERT(IS_ENABLED(CONFIG_CLOCK_CONTROL)); #define UARTE_ANY_FAST_PD 1 #endif #endif @@ -251,6 +263,8 @@ struct uarte_nrfx_data { #define UARTE_FLAG_LOW_POWER (UARTE_FLAG_LOW_POWER_TX | UARTE_FLAG_LOW_POWER_RX) #define UARTE_FLAG_TRIG_RXTO BIT(2) #define UARTE_FLAG_POLL_OUT BIT(3) +/* Flag indicating that a workaround for not working frame timeout is active. */ +#define UARTE_FLAG_FTIMEOUT_WATCH BIT(4) /* If enabled then ENDTX is PPI'ed to TXSTOP */ #define UARTE_CFG_FLAG_PPI_ENDTX BIT(0) @@ -1317,9 +1331,22 @@ static void rx_timeout(struct k_timer *timer) NRF_UARTE_Type *uarte = get_uarte_instance(dev); #ifdef UARTE_HAS_FRAME_TIMEOUT - if (!nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXDRDY)) { - nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STOPRX); + struct uarte_nrfx_data *data = dev->data; + struct uarte_async_rx *async_rx = &data->async->rx; + bool rxdrdy = nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXDRDY); + + if (IS_ENABLED(RX_FRAMETIMEOUT_WORKAROUND) && + (atomic_and(&data->flags, ~UARTE_FLAG_FTIMEOUT_WATCH) & UARTE_FLAG_FTIMEOUT_WATCH)) { + if (rxdrdy) { + nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXDRDY); + k_timer_start(&async_rx->timer, async_rx->timeout, K_NO_WAIT); + } + } else { + if (!rxdrdy) { + nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STOPRX); + } } + return; #else /* UARTE_HAS_FRAME_TIMEOUT */ struct uarte_nrfx_data *data = dev->data; @@ -1545,6 +1572,7 @@ static void endrx_isr(const struct device *dev) async_rx->offset = 0; if (async_rx->enabled) { + bool start_timeout = false; /* If there is a next buffer, then STARTRX will have already been * invoked by the short (the next buffer will be filling up already) * and here we just do the swap of which buffer the driver is following, @@ -1570,6 +1598,11 @@ static void endrx_isr(const struct device *dev) */ if (!nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXSTARTED)) { nrf_uarte_task_trigger(uarte, NRF_UARTE_TASK_STARTRX); + nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO); + if (IS_ENABLED(RX_FRAMETIMEOUT_WORKAROUND)) { + data->flags |= UARTE_FLAG_FTIMEOUT_WATCH; + start_timeout = true; + } } /* Remove the short until the subsequent next buffer is setup */ nrf_uarte_shorts_disable(uarte, NRF_UARTE_SHORT_ENDRX_STARTRX); @@ -1578,6 +1611,11 @@ static void endrx_isr(const struct device *dev) } irq_unlock(key); + if (IS_ENABLED(UARTE_HAS_FRAME_TIMEOUT)) { + if (start_timeout && !K_TIMEOUT_EQ(async_rx->timeout, K_NO_WAIT)) { + k_timer_start(&async_rx->timer, async_rx->timeout, K_NO_WAIT); + } + } } #if !defined(CONFIG_UART_NRFX_UARTE_ENHANCED_RX) @@ -1635,6 +1673,12 @@ static void rxto_isr(const struct device *dev) struct uarte_nrfx_data *data = dev->data; struct uarte_async_rx *async_rx = &data->async->rx; + if (IS_ENABLED(RX_FRAMETIMEOUT_WORKAROUND)) { + if (atomic_test_and_clear_bit(&data->flags, UARTE_FLAG_FTIMEOUT_WATCH)) { + k_timer_stop(&async_rx->timer); + } + } + if (async_rx->buf) { #ifdef CONFIG_HAS_NORDIC_DMM (void)dmm_buffer_in_release(config->mem_reg, async_rx->usr_buf, 0, async_rx->buf); @@ -2544,7 +2588,7 @@ static int uarte_instance_init(const struct device *dev, */ #define UARTE_INIT_PRIO(idx) \ COND_CODE_1(INSTANCE_IS_FAST_PD(_, /*empty*/, idx, _), \ - (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY)), \ + (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \ (CONFIG_SERIAL_INIT_PRIORITY)) /* Macro for setting nRF specific configuration structures. */ diff --git a/drivers/spi/Kconfig.nrfx b/drivers/spi/Kconfig.nrfx index d3debe5a5de6..f3afa79c4c37 100644 --- a/drivers/spi/Kconfig.nrfx +++ b/drivers/spi/Kconfig.nrfx @@ -31,6 +31,8 @@ config SPI_NRFX_SPIM select NRFX_SPIM20 if HAS_HW_NRF_SPIM20 select NRFX_SPIM21 if HAS_HW_NRF_SPIM21 select NRFX_SPIM22 if HAS_HW_NRF_SPIM22 + select NRFX_SPIM23 if HAS_HW_NRF_SPIM23 + select NRFX_SPIM24 if HAS_HW_NRF_SPIM24 select NRFX_SPIM30 if HAS_HW_NRF_SPIM30 select NRFX_SPIM120 if HAS_HW_NRF_SPIM120 select NRFX_SPIM121 if HAS_HW_NRF_SPIM121 @@ -55,6 +57,8 @@ config SPI_NRFX_SPIS select NRFX_SPIS20 if HAS_HW_NRF_SPIS20 select NRFX_SPIS21 if HAS_HW_NRF_SPIS21 select NRFX_SPIS22 if HAS_HW_NRF_SPIS22 + select NRFX_SPIS23 if HAS_HW_NRF_SPIS23 + select NRFX_SPIS24 if HAS_HW_NRF_SPIS24 select NRFX_SPIS30 if HAS_HW_NRF_SPIS30 select NRFX_SPIS120 if HAS_HW_NRF_SPIS120 select NRFX_SPIS130 if HAS_HW_NRF_SPIS130 diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index bd10447e4429..6941bfdaaa77 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -41,6 +41,14 @@ LOG_MODULE_REGISTER(spi_dw); #include #endif +#ifdef CONFIG_HAS_NRFX +#include +#endif + +#ifdef CONFIG_SOC_NRF54H20_GPD +#include +#endif + static inline bool spi_dw_is_slave(struct spi_dw_data *spi) { return (IS_ENABLED(CONFIG_SPI_SLAVE) && @@ -258,6 +266,7 @@ static int spi_dw_configure(const struct device *dev, /* Baud rate and Slave select, for master only */ write_baudr(dev, SPI_DW_CLK_DIVIDER(info->clock_frequency, config->frequency)); + write_ser(dev, BIT(config->slave)); } if (spi_dw_is_slave(spi)) { @@ -512,6 +521,10 @@ void spi_dw_isr(const struct device *dev) uint32_t int_status; int error; +#ifdef CONFIG_HAS_NRFX + NRF_EXMIF->EVENTS_CORE = 0; +#endif + int_status = read_isr(dev); LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev, int_status, @@ -560,6 +573,18 @@ int spi_dw_init(const struct device *dev) DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); +#ifdef CONFIG_HAS_NRFX + NRF_EXMIF->INTENSET = BIT(0); + NRF_EXMIF->TASKS_START = 1; + +#ifdef CONFIG_SOC_NRF54H20_GPD + err = nrf_gpd_request(NRF_GPD_FAST_ACTIVE1); + if (err < 0) { + return err; + } +#endif +#endif + info->config_func(); /* Masking interrupt and making sure controller is disabled */ @@ -584,6 +609,11 @@ int spi_dw_init(const struct device *dev) return 0; } +#define REG_ADDR(inst) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif_spi), \ + (Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \ + (DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)))) + #define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \ IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \ DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \ @@ -656,7 +686,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \ SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \ }; \ static const struct spi_dw_config spi_dw_config_##inst = { \ - DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \ + REG_ADDR(inst), \ .clock_frequency = COND_CODE_1( \ DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \ (DT_INST_PROP_BY_PHANDLE(inst, clocks, clock_frequency)), \ diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index 21a454c5ff8f..a5c4e30f190e 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -43,9 +43,9 @@ LOG_MODULE_REGISTER(spi_nrfx_spim, CONFIG_SPI_LOG_LEVEL); #define SPI_BUFFER_IN_RAM 1 #endif -#if defined(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL) +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL) #define SPIM_REQUESTS_CLOCK(node) \ - DT_NODE_HAS_COMPAT(DT_NODELABEL(DT_CLOCKS_CTLR(node)), nordic_nrf_hsfll_global) + DT_NODE_HAS_COMPAT(DT_CLOCKS_CTLR(node), nordic_nrf_hsfll_global) #define SPIM_REQUESTS_CLOCK_OR(node) SPIM_REQUESTS_CLOCK(node) || #if (DT_FOREACH_STATUS_OKAY(nordic_nrf_spim, SPIM_REQUESTS_CLOCK_OR) 0) #define USE_CLOCK_REQUESTS 1 @@ -56,7 +56,7 @@ LOG_MODULE_REGISTER(spi_nrfx_spim, CONFIG_SPI_LOG_LEVEL); BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED)); #endif #else -#define SPIM_REQUESTS_CLOCK(idx) 0 +#define SPIM_REQUESTS_CLOCK(node) 0 #endif struct spi_nrfx_data { @@ -765,6 +765,28 @@ static int spi_nrfx_init(const struct device *dev) #endif return pm_device_driver_init(dev, spim_nrfx_pm_action); } + +static int spi_nrfx_deinit(const struct device *dev) +{ +#if defined(CONFIG_PM_DEVICE) + enum pm_device_state state; + + /* + * PM must have suspended the device before driver can + * be deinitialized + */ + (void)pm_device_state_get(dev, &state); + return state == PM_DEVICE_STATE_SUSPENDED || + state == PM_DEVICE_STATE_OFF ? + 0 : -EBUSY; +#else + /* PM suspend implementation does everything we need */ + spim_suspend(dev); +#endif + + return 0; +} + /* * We use NODELABEL here because the nrfx API requires us to call * functions which are named according to SoC peripheral instance @@ -796,11 +818,11 @@ static int spi_nrfx_init(const struct device *dev) * must be initialized after that controller driver, hence the default SPI * initialization priority may be too early for them. */ -#if defined(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY) && \ - CONFIG_SPI_INIT_PRIORITY < CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY) && \ + CONFIG_SPI_INIT_PRIORITY < CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY #define SPIM_INIT_PRIORITY(idx) \ - COND_CODE_1(SPIM_REQUESTS_CLOCK(idx), \ - (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY)), \ + COND_CODE_1(SPIM_REQUESTS_CLOCK(SPIM(idx)), \ + (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \ (CONFIG_SPI_INIT_PRIORITY)) #else #define SPIM_INIT_PRIORITY(idx) CONFIG_SPI_INIT_PRIORITY @@ -858,8 +880,8 @@ static int spi_nrfx_init(const struct device *dev) .wake_gpiote = WAKE_GPIOTE_INSTANCE(SPIM(idx)), \ IF_ENABLED(CONFIG_DCACHE, \ (.mem_attr = SPIM_GET_MEM_ATTR(idx),)) \ - IF_ENABLED(USE_CLOCK_REQUESTS, \ - (.clk_dev = SPIM_REQUESTS_CLOCK(idx) \ + IF_ENABLED(USE_CLOCK_REQUESTS, \ + (.clk_dev = SPIM_REQUESTS_CLOCK(SPIM(idx)) \ ? DEVICE_DT_GET(DT_CLOCKS_CTLR(SPIM(idx))) \ : NULL, \ .clk_spec = { \ @@ -870,8 +892,9 @@ static int spi_nrfx_init(const struct device *dev) !(DT_GPIO_FLAGS(SPIM(idx), wake_gpios) & GPIO_ACTIVE_LOW),\ "WAKE line must be configured as active high"); \ PM_DEVICE_DT_DEFINE(SPIM(idx), spim_nrfx_pm_action); \ - SPI_DEVICE_DT_DEFINE(SPIM(idx), \ + SPI_DEVICE_DT_DEINIT_DEFINE(SPIM(idx), \ spi_nrfx_init, \ + spi_nrfx_deinit, \ PM_DEVICE_DT_GET(SPIM(idx)), \ &spi_##idx##_data, \ &spi_##idx##z_config, \ diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index 285e48a57fd2..2874411de39b 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -66,6 +66,7 @@ static struct k_spinlock lock; static uint64_t last_count; /* Time (SYSCOUNTER value) @last sys_clock_announce() */ static atomic_t int_mask; static uint8_t ext_channels_allocated; +static uint64_t grtc_start_value; static nrfx_grtc_channel_t system_clock_channel_data = { .handler = sys_clock_timeout_handler, .p_context = NULL, @@ -358,6 +359,11 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) return 0; } +uint64_t z_nrf_grtc_timer_startup_value_get(void) +{ + return grtc_start_value; +} + #if defined(CONFIG_POWEROFF) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER) int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) { @@ -485,6 +491,8 @@ static int sys_clock_driver_init(void) } #endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ + last_count = sys_clock_tick_get() * CYC_PER_TICK; + grtc_start_value = last_count; int_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK; if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) { system_timeout_set_relative(CYC_PER_TICK); diff --git a/drivers/usb/udc/udc_dwc2_vendor_quirks.h b/drivers/usb/udc/udc_dwc2_vendor_quirks.h index 0a1021881399..1f450c430c2a 100644 --- a/drivers/usb/udc/udc_dwc2_vendor_quirks.h +++ b/drivers/usb/udc/udc_dwc2_vendor_quirks.h @@ -315,6 +315,191 @@ DT_INST_FOREACH_STATUS_OKAY(QUIRK_NRF_USBHS_DEFINE) #endif /*DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbhs) */ +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbhs_nrf54l) + +#define DT_DRV_COMPAT snps_dwc2 + +#define USBHS_DT_WRAPPER_REG_ADDR(n) UINT_TO_POINTER(DT_INST_REG_ADDR_BY_NAME(n, wrapper)) + +#include + +#define NRF_DEFAULT_IRQ_PRIORITY 1 + +/* + * On USBHS, we cannot access the DWC2 register until VBUS is detected and + * valid. If the user tries to force usbd_enable() and the corresponding + * udc_enable() without a "VBUS ready" notification, the event wait will block + * until a valid VBUS signal is detected or until the + * CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT timeout expires. + */ +static K_EVENT_DEFINE(usbhs_events); +#define USBHS_VBUS_READY BIT(0) + +static void vregusb_isr(const void *arg) +{ + const struct device *dev = arg; + + if (NRF_VREGUSB->EVENTS_VBUSDETECTED) { + NRF_VREGUSB->EVENTS_VBUSDETECTED = 0; + k_event_post(&usbhs_events, USBHS_VBUS_READY); + udc_submit_event(dev, UDC_EVT_VBUS_READY, 0); + } + + if (NRF_VREGUSB->EVENTS_VBUSREMOVED) { + NRF_VREGUSB->EVENTS_VBUSREMOVED = 0; + k_event_set_masked(&usbhs_events, 0, USBHS_VBUS_READY); + udc_submit_event(dev, UDC_EVT_VBUS_REMOVED, 0); + } +} + +static inline int usbhs_enable_vreg(const struct device *dev) +{ + IRQ_CONNECT(VREGUSB_IRQn, NRF_DEFAULT_IRQ_PRIORITY, + vregusb_isr, DEVICE_DT_INST_GET(0), 0); + + NRF_VREGUSB->INTEN = VREGUSB_INTEN_VBUSDETECTED_Msk | + VREGUSB_INTEN_VBUSREMOVED_Msk; + NRF_VREGUSB->TASKS_START = 1; + + /* TODO: Determine conditions when VBUSDETECTED is not generated */ + if (sys_read32((mem_addr_t)NRF_VREGUSB + 0x400) & BIT(2)) { + k_event_post(&usbhs_events, USBHS_VBUS_READY); + udc_submit_event(dev, UDC_EVT_VBUS_READY, 0); + } + + irq_enable(VREGUSB_IRQn); + + return 0; +} + +static inline int usbhs_enable_core(const struct device *dev) +{ + NRF_USBHS_Type *wrapper = USBHS_DT_WRAPPER_REG_ADDR(0); + k_timeout_t timeout = K_FOREVER; + + if (!k_event_wait(&usbhs_events, USBHS_VBUS_READY, false, K_NO_WAIT)) { + LOG_WRN("VBUS is not ready, block udc_enable()"); + if (!k_event_wait(&usbhs_events, USBHS_VBUS_READY, false, timeout)) { + return -ETIMEDOUT; + } + } + + /* TODO: Request PCLK24M using clock control driver */ + NRF_CLOCK->TASKS_XO24MSTART = 1; + while (NRF_CLOCK->EVENTS_XO24MSTARTED == 0) { + } + + /* Power up peripheral */ + wrapper->ENABLE = USBHS_ENABLE_CORE_Msk; + + /* Set ID to Device and force D+ pull-up off for now */ + wrapper->PHY.OVERRIDEVALUES = (1 << 31); + wrapper->PHY.INPUTOVERRIDE = (1 << 31) | USBHS_PHY_INPUTOVERRIDE_VBUSVALID_Msk; + + /* Release PHY power-on reset */ + wrapper->ENABLE = USBHS_ENABLE_PHY_Msk | USBHS_ENABLE_CORE_Msk; + + /* Wait for PHY clock to start */ + k_busy_wait(45); + + /* Release DWC2 reset */ + wrapper->TASKS_START = 1UL; + + /* Wait for clock to start to avoid hang on too early register read */ + k_busy_wait(1); + + /* DWC2 opmode is now guaranteed to be Non-Driving, allow D+ pull-up to + * become active once driver clears DCTL SftDiscon bit. + */ + wrapper->PHY.INPUTOVERRIDE = (1 << 31); + + return 0; +} + +static inline int usbhs_disable_core(const struct device *dev) +{ + NRF_USBHS_Type *wrapper = USBHS_DT_WRAPPER_REG_ADDR(0); + + /* Set ID to Device and forcefully disable D+ pull-up */ + wrapper->PHY.OVERRIDEVALUES = (1 << 31); + wrapper->PHY.INPUTOVERRIDE = (1 << 31) | USBHS_PHY_INPUTOVERRIDE_VBUSVALID_Msk; + + wrapper->ENABLE = 0UL; + + /* TODO: Release PCLK24M using clock control driver */ + NRF_CLOCK->EVENTS_XO24MSTARTED = 0; + NRF_CLOCK->TASKS_XO24MSTOP = 1; + + return 0; +} + +static inline int usbhs_disable_vreg(const struct device *dev) +{ + NRF_VREGUSB->INTEN = 0; + NRF_VREGUSB->TASKS_STOP = 1; + + return 0; +} + +static inline int usbhs_init_caps(const struct device *dev) +{ + struct udc_data *data = dev->data; + + data->caps.can_detect_vbus = true; + data->caps.hs = true; + + return 0; +} + +static inline int usbhs_is_phy_clk_off(const struct device *dev) +{ + return !k_event_test(&usbhs_events, USBHS_VBUS_READY); +} + +static inline int usbhs_post_hibernation_entry(const struct device *dev) +{ + const struct udc_dwc2_config *const config = dev->config; + struct usb_dwc2_reg *const base = config->base; + NRF_USBHS_Type *wrapper = USBHS_DT_WRAPPER_REG_ADDR(0); + + sys_set_bits((mem_addr_t)&base->pcgcctl, USB_DWC2_PCGCCTL_GATEHCLK); + + wrapper->TASKS_STOP = 1; + + return 0; +} + +static inline int usbhs_pre_hibernation_exit(const struct device *dev) +{ + const struct udc_dwc2_config *const config = dev->config; + struct usb_dwc2_reg *const base = config->base; + NRF_USBHS_Type *wrapper = USBHS_DT_WRAPPER_REG_ADDR(0); + + sys_clear_bits((mem_addr_t)&base->pcgcctl, USB_DWC2_PCGCCTL_GATEHCLK); + + wrapper->TASKS_START = 1; + + return 0; +} + +#define QUIRK_NRF_USBHS_DEFINE(n) \ + struct dwc2_vendor_quirks dwc2_vendor_quirks_##n = { \ + .init = usbhs_enable_vreg, \ + .pre_enable = usbhs_enable_core, \ + .disable = usbhs_disable_core, \ + .shutdown = usbhs_disable_vreg, \ + .caps = usbhs_init_caps, \ + .is_phy_clk_off = usbhs_is_phy_clk_off, \ + .post_hibernation_entry = usbhs_post_hibernation_entry, \ + .pre_hibernation_exit = usbhs_pre_hibernation_exit, \ + }; + +DT_INST_FOREACH_STATUS_OKAY(QUIRK_NRF_USBHS_DEFINE) + +#undef DT_DRV_COMPAT + +#endif /*DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_usbhs_nrf54l) */ + /* Add next vendor quirks definition above this line */ #endif /* ZEPHYR_DRIVERS_USB_UDC_DWC2_VENDOR_QUIRKS_H */ diff --git a/drivers/watchdog/CMakeLists.txt b/drivers/watchdog/CMakeLists.txt index e7264362e3f4..e247de4e9fe0 100644 --- a/drivers/watchdog/CMakeLists.txt +++ b/drivers/watchdog/CMakeLists.txt @@ -28,7 +28,7 @@ zephyr_library_sources_ifdef(CONFIG_WDT_MCUX_WDOG wdt_mcux_wdog.c) zephyr_library_sources_ifdef(CONFIG_WDT_MCUX_WDOG32 wdt_mcux_wdog32.c) zephyr_library_sources_ifdef(CONFIG_WDT_MCUX_WWDT wdt_mcux_wwdt.c) zephyr_library_sources_ifdef(CONFIG_WDT_NPCX wdt_npcx.c) -zephyr_library_sources_ifdef(CONFIG_WDT_NPM1300 wdt_npm1300.c) +zephyr_library_sources_ifdef(CONFIG_WDT_NPM13XX wdt_npm13xx.c) zephyr_library_sources_ifdef(CONFIG_WDT_NPM2100 wdt_npm2100.c) zephyr_library_sources_ifdef(CONFIG_WDT_NPM6001 wdt_npm6001.c) zephyr_library_sources_ifdef(CONFIG_WDT_NRFX wdt_nrfx.c) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index bd445bda94f9..4fed392fd223 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -107,7 +107,7 @@ source "drivers/watchdog/Kconfig.rpi_pico" source "drivers/watchdog/Kconfig.gd32" -source "drivers/watchdog/Kconfig.npm1300" +source "drivers/watchdog/Kconfig.npm13xx" source "drivers/watchdog/Kconfig.npm2100" diff --git a/drivers/watchdog/Kconfig.npm1300 b/drivers/watchdog/Kconfig.npm1300 deleted file mode 100644 index b18e4b69b13a..000000000000 --- a/drivers/watchdog/Kconfig.npm1300 +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config WDT_NPM1300 - bool "nPM1300 Watchdog driver" - default y - depends on DT_HAS_NORDIC_NPM1300_WDT_ENABLED - select I2C - select MFD - help - Enable nPM1300 Watchdog driver - -config WDT_NPM1300_INIT_PRIORITY - int "nPM1300 Watchdog driver initialization priority" - depends on WDT_NPM1300 - default 85 - help - Initialization priority for the nPM1300 Watchdog driver. - It must be greater than GPIO_NPM1300_INIT_PRIORITY. diff --git a/drivers/watchdog/Kconfig.npm13xx b/drivers/watchdog/Kconfig.npm13xx new file mode 100644 index 000000000000..910da6574a93 --- /dev/null +++ b/drivers/watchdog/Kconfig.npm13xx @@ -0,0 +1,19 @@ +# Copyright (c) 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config WDT_NPM13XX + bool "nPM13xx Watchdog driver" + default y + depends on DT_HAS_NORDIC_NPM1300_WDT_ENABLED || DT_HAS_NORDIC_NPM1304_WDT_ENABLED + select I2C + select MFD + help + Enable nPM13xx Watchdog driver + +config WDT_NPM13XX_INIT_PRIORITY + int "nPM13xx Watchdog driver initialization priority" + depends on WDT_NPM13XX + default 85 + help + Initialization priority for the nPM13xx Watchdog driver. + It must be greater than GPIO_NPM13XX_INIT_PRIORITY. diff --git a/drivers/watchdog/wdt_npm1300.c b/drivers/watchdog/wdt_npm13xx.c similarity index 53% rename from drivers/watchdog/wdt_npm1300.c rename to drivers/watchdog/wdt_npm13xx.c index 71002875af0c..351da6b7d5a8 100644 --- a/drivers/watchdog/wdt_npm1300.c +++ b/drivers/watchdog/wdt_npm13xx.c @@ -3,59 +3,57 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_npm1300_wdt - #include #include #include #include -#include -#include +#include +#include -/* nPM1300 TIMER base address */ +/* nPM13xx TIMER base address */ #define TIME_BASE 0x07U -/* nPM1300 timer register offsets */ +/* nPM13xx timer register offsets */ #define TIME_OFFSET_START 0x00U #define TIME_OFFSET_STOP 0x01U #define TIME_OFFSET_WDOG_KICK 0x04U #define TIME_OFFSET_MODE 0x05U -/* nPM1300 timer modes */ +/* nPM13xx timer modes */ #define TIME_MODE_BOOT 0x00U #define TIME_MODE_WARN 0x01U #define TIME_MODE_RESET 0x02U #define TIME_MODE_GEN 0x03U -struct wdt_npm1300_config { +struct wdt_npm13xx_config { const struct device *mfd; struct gpio_dt_spec reset_gpios; }; -struct wdt_npm1300_data { +struct wdt_npm13xx_data { bool timeout_valid; }; -static int wdt_npm1300_setup(const struct device *dev, uint8_t options) +static int wdt_npm13xx_setup(const struct device *dev, uint8_t options) { - const struct wdt_npm1300_config *config = dev->config; - struct wdt_npm1300_data *data = dev->data; + const struct wdt_npm13xx_config *config = dev->config; + struct wdt_npm13xx_data *data = dev->data; if (!data->timeout_valid) { return -EINVAL; } - return mfd_npm1300_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_START, 1U); + return mfd_npm13xx_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_START, 1U); } -static int wdt_npm1300_disable(const struct device *dev) +static int wdt_npm13xx_disable(const struct device *dev) { - const struct wdt_npm1300_config *config = dev->config; - struct wdt_npm1300_data *data = dev->data; + const struct wdt_npm13xx_config *config = dev->config; + struct wdt_npm13xx_data *data = dev->data; int ret; - ret = mfd_npm1300_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_STOP, 1U); + ret = mfd_npm13xx_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_STOP, 1U); if (ret < 0) { return ret; } @@ -65,11 +63,11 @@ static int wdt_npm1300_disable(const struct device *dev) return 0; } -static int wdt_npm1300_install_timeout(const struct device *dev, +static int wdt_npm13xx_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *timeout) { - const struct wdt_npm1300_config *config = dev->config; - struct wdt_npm1300_data *data = dev->data; + const struct wdt_npm13xx_config *config = dev->config; + struct wdt_npm13xx_data *data = dev->data; uint8_t mode; int ret; @@ -81,7 +79,7 @@ static int wdt_npm1300_install_timeout(const struct device *dev, return -EINVAL; } - ret = mfd_npm1300_set_timer(config->mfd, timeout->window.max); + ret = mfd_npm13xx_set_timer(config->mfd, timeout->window.max); if (ret < 0) { return ret; } @@ -103,7 +101,7 @@ static int wdt_npm1300_install_timeout(const struct device *dev, return -EINVAL; } - ret = mfd_npm1300_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_MODE, mode); + ret = mfd_npm13xx_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_MODE, mode); if (ret < 0) { return ret; } @@ -113,27 +111,27 @@ static int wdt_npm1300_install_timeout(const struct device *dev, return 0; } -static int wdt_npm1300_feed(const struct device *dev, int channel_id) +static int wdt_npm13xx_feed(const struct device *dev, int channel_id) { - const struct wdt_npm1300_config *config = dev->config; + const struct wdt_npm13xx_config *config = dev->config; if (channel_id != 0) { return -EINVAL; } - return mfd_npm1300_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_WDOG_KICK, 1U); + return mfd_npm13xx_reg_write(config->mfd, TIME_BASE, TIME_OFFSET_WDOG_KICK, 1U); } -static DEVICE_API(wdt, wdt_npm1300_api) = { - .setup = wdt_npm1300_setup, - .disable = wdt_npm1300_disable, - .install_timeout = wdt_npm1300_install_timeout, - .feed = wdt_npm1300_feed, +static DEVICE_API(wdt, wdt_npm13xx_api) = { + .setup = wdt_npm13xx_setup, + .disable = wdt_npm13xx_disable, + .install_timeout = wdt_npm13xx_install_timeout, + .feed = wdt_npm13xx_feed, }; -static int wdt_npm1300_init(const struct device *dev) +static int wdt_npm13xx_init(const struct device *dev) { - const struct wdt_npm1300_config *config = dev->config; + const struct wdt_npm13xx_config *config = dev->config; int ret; if (!device_is_ready(config->mfd)) { @@ -145,7 +143,7 @@ static int wdt_npm1300_init(const struct device *dev) return -ENODEV; } - ret = gpio_pin_configure_dt(&config->reset_gpios, NPM1300_GPIO_WDT_RESET_ON); + ret = gpio_pin_configure_dt(&config->reset_gpios, NPM13XX_GPIO_WDT_RESET_ON); if (ret != 0) { return ret; } @@ -154,15 +152,23 @@ static int wdt_npm1300_init(const struct device *dev) return 0; } -#define WDT_NPM1300_DEFINE(n) \ - static struct wdt_npm1300_data data##n; \ +#define WDT_NPM13XX_DEFINE(partno, n) \ + static struct wdt_npm13xx_data wdt_##partno##_data##n; \ \ - static const struct wdt_npm1300_config config##n = { \ + static const struct wdt_npm13xx_config wdt_##partno##_config##n = { \ .mfd = DEVICE_DT_GET(DT_INST_PARENT(n)), \ .reset_gpios = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {0}), \ }; \ \ - DEVICE_DT_INST_DEFINE(n, &wdt_npm1300_init, NULL, &data##n, &config##n, POST_KERNEL, \ - CONFIG_WDT_NPM1300_INIT_PRIORITY, &wdt_npm1300_api); + DEVICE_DT_INST_DEFINE(n, &wdt_npm13xx_init, NULL, &wdt_##partno##_data##n, \ + &wdt_##partno##_config##n, POST_KERNEL, \ + CONFIG_WDT_NPM13XX_INIT_PRIORITY, &wdt_npm13xx_api); +#define DT_DRV_COMPAT nordic_npm1300_wdt +#define WDT_NPM1300_DEFINE(n) WDT_NPM13XX_DEFINE(npm1300, n) DT_INST_FOREACH_STATUS_OKAY(WDT_NPM1300_DEFINE) + +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT nordic_npm1304_wdt +#define WDT_NPM1304_DEFINE(n) WDT_NPM13XX_DEFINE(npm1304, n) +DT_INST_FOREACH_STATUS_OKAY(WDT_NPM1304_DEFINE) diff --git a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi index ade3b5de5cf4..8980cce82052 100644 --- a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi +++ b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi @@ -908,4 +908,15 @@ config NRF_WIFI_RX_STBC_HT help Receive packets encoded with STBC (Space-Time Block Coding) in HT (Wi-Fi4) mode. + +config NRF_WIFI_DYNAMIC_BANDWIDTH_SIGNALLING + bool "Dynamic bandwidth signalling for Wi-Fi" + help + This option enables support for dynamic bandwidth signalling. + +config NRF_WIFI_DYNAMIC_ED + bool "Dynamic ED" + help + This option enables support for proprietary algorithm to + enhance performance in high-traffic channels. endif # WIFI_NRF70 diff --git a/dts/arm/nordic/nrf52805.dtsi b/dts/arm/nordic/nrf52805.dtsi index 45a54f97b061..2134605c9f86 100644 --- a/dts/arm/nordic/nrf52805.dtsi +++ b/dts/arm/nordic/nrf52805.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -106,12 +106,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index 217758dd1614..6e09220e78bb 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -7,7 +7,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -110,12 +110,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52811.dtsi b/dts/arm/nordic/nrf52811.dtsi index 670f569c0ace..12d0a0ea4d6f 100644 --- a/dts/arm/nordic/nrf52811.dtsi +++ b/dts/arm/nordic/nrf52811.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -122,12 +122,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52820.dtsi b/dts/arm/nordic/nrf52820.dtsi index 50c8d2ba07f0..d15fbb2ae4e3 100644 --- a/dts/arm/nordic/nrf52820.dtsi +++ b/dts/arm/nordic/nrf52820.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -124,12 +124,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK another Bluetooth controller - * is added and set as the default. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index 7bd62c707545..eef2297c43b1 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -7,7 +7,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -110,12 +110,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52833.dtsi b/dts/arm/nordic/nrf52833.dtsi index 8202ddc45431..1b3620aa01cb 100644 --- a/dts/arm/nordic/nrf52833.dtsi +++ b/dts/arm/nordic/nrf52833.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -124,12 +124,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 7c5337eed990..88b3eddd6e1a 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -7,8 +7,8 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -112,12 +112,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; @@ -572,7 +573,7 @@ reg = <0x5002a000 0x1000>, <0x5002b000 0x1000>; reg-names = "wrapper", "core"; interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; }; }; diff --git a/dts/arm/nordic/nrf5340_cpuapp.dtsi b/dts/arm/nordic/nrf5340_cpuapp.dtsi index 1b04be61248e..f6ff10597fd8 100644 --- a/dts/arm/nordic/nrf5340_cpuapp.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp.dtsi @@ -34,7 +34,7 @@ }; chosen { - zephyr,entropy = &rng_hci; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -104,7 +104,7 @@ reg = <0x50844000 0x1000>, <0x50845000 0x1000>; reg-names = "wrapper", "core"; interrupts = <68 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; }; diff --git a/dts/arm/nordic/nrf5340_cpunet.dtsi b/dts/arm/nordic/nrf5340_cpunet.dtsi index 4f9164767f1a..be0fad16d66b 100644 --- a/dts/arm/nordic/nrf5340_cpunet.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet.dtsi @@ -9,7 +9,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -102,12 +102,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf54h20_cpuapp.dtsi b/dts/arm/nordic/nrf54h20_cpuapp.dtsi index 15eac9c5d197..c56df42ddd5b 100644 --- a/dts/arm/nordic/nrf54h20_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54h20_cpuapp.dtsi @@ -59,7 +59,3 @@ wdt011: &cpuapp_wdt011 {}; &grtc { interrupts = <109 NRF_DEFAULT_IRQ_PRIORITY>; }; - -&nfct { - compatible = "nordic,nrf-nfct-v2"; -}; diff --git a/dts/arm/nordic/nrf54h20_cpurad.dtsi b/dts/arm/nordic/nrf54h20_cpurad.dtsi index 2d2fdee8d270..e8ff2dac3a4a 100644 --- a/dts/arm/nordic/nrf54h20_cpurad.dtsi +++ b/dts/arm/nordic/nrf54h20_cpurad.dtsi @@ -23,6 +23,10 @@ wdt011: &cpurad_wdt011 {}; /delete-node/ &cpuflpr; / { + chosen { + zephyr,bt-hci = &bt_hci_sdc; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&cpurad_nvic>; @@ -99,3 +103,7 @@ wdt011: &cpurad_wdt011 {}; &dppic020 { status = "okay"; }; + +&bt_hci_sdc { + status = "okay"; +}; diff --git a/dts/arm/nordic/nrf54l09_enga_cpuapp.dtsi b/dts/arm/nordic/nrf54l09_enga_cpuapp.dtsi index fc359cdb0ac9..6c7f34d3b21e 100644 --- a/dts/arm/nordic/nrf54l09_enga_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l09_enga_cpuapp.dtsi @@ -17,7 +17,8 @@ nvic: &cpuapp_nvic {}; / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &prng; }; soc { @@ -30,9 +31,14 @@ nvic: &cpuapp_nvic {}; compatible = "zephyr,psa-crypto-rng"; status = "disabled"; }; + + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; + }; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; diff --git a/dts/arm/nordic/nrf54l20_enga_cpuapp.dtsi b/dts/arm/nordic/nrf54l20_enga_cpuapp.dtsi index 2df3fc596767..5c7e5db30014 100644 --- a/dts/arm/nordic/nrf54l20_enga_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l20_enga_cpuapp.dtsi @@ -16,6 +16,10 @@ nvic: &cpuapp_nvic {}; /delete-node/ &cpuflpr_clic; / { + chosen { + zephyr,entropy = &prng; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&cpuapp_nvic>; @@ -26,6 +30,11 @@ nvic: &cpuapp_nvic {}; compatible = "zephyr,psa-crypto-rng"; status = "disabled"; }; + + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; + }; }; &cpuflpr_vpr { diff --git a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi index 3f1fe655b6e5..80875058f5fd 100644 --- a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi @@ -15,8 +15,8 @@ nvic: &cpuapp_nvic {}; / { chosen { - zephyr,bt-hci = &bt_hci_controller; - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &psa_rng; }; soc { @@ -32,11 +32,11 @@ nvic: &cpuapp_nvic {}; psa_rng: psa-rng { compatible = "zephyr,psa-crypto-rng"; - status = "disabled"; + status = "okay"; }; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; diff --git a/dts/arm/nordic/nrf91.dtsi b/dts/arm/nordic/nrf91.dtsi index 9a64ed922294..5e65519929ea 100644 --- a/dts/arm/nordic/nrf91.dtsi +++ b/dts/arm/nordic/nrf91.dtsi @@ -28,6 +28,7 @@ }; chosen { + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -51,7 +52,7 @@ reg = <0x50840000 0x1000>, <0x50841000 0x1000>; reg-names = "wrapper", "core"; interrupts = <64 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; ctrlap: ctrlap@50006000 { diff --git a/dts/bindings/clock/bflb,bclk.yaml b/dts/bindings/clock/bflb,bclk.yaml new file mode 100644 index 000000000000..343c5831ed05 --- /dev/null +++ b/dts/bindings/clock/bflb,bclk.yaml @@ -0,0 +1,19 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: | + The BCLK clock, or peripheral clock + Source Clock -> Root Clock -> / divider -> BCLK + +compatible: "bflb,bclk" + +include: [base.yaml, clock-controller.yaml] + +properties: + divider: + type: int + required: true + description: Divide root clock by this 8-bits value + + "#clock-cells": + const: 0 diff --git a/dts/bindings/clock/bflb,bl60x-clock-controller.yaml b/dts/bindings/clock/bflb,bl60x-clock-controller.yaml new file mode 100644 index 000000000000..a9c02425a9ff --- /dev/null +++ b/dts/bindings/clock/bflb,bl60x-clock-controller.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: Bouffalolab BL60x Clock Controller + +compatible: "bflb,bl60x-clock-controller" + +include: [base.yaml, clock-controller.yaml] + +properties: + "#clock-cells": + const: 1 + +clock-cells: + - id diff --git a/dts/bindings/clock/bflb,bl60x-pll.yaml b/dts/bindings/clock/bflb,bl60x-pll.yaml new file mode 100644 index 000000000000..a1c9719ea3f0 --- /dev/null +++ b/dts/bindings/clock/bflb,bl60x-pll.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: The BL60x PLL + +compatible: "bflb,bl60x-pll" + +include: [base.yaml, clock-controller.yaml] + +properties: + clocks: + type: phandle-array + required: true + description: source + + "#clock-cells": + const: 1 + +clock-cells: + - select diff --git a/dts/bindings/clock/bflb,bl60x-root-clk.yaml b/dts/bindings/clock/bflb,bl60x-root-clk.yaml new file mode 100644 index 000000000000..9e1bb7948f6a --- /dev/null +++ b/dts/bindings/clock/bflb,bl60x-root-clk.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: | + The BL60x Root Clock + +compatible: "bflb,bl60x-root-clk" + +include: [base.yaml, clock-controller.yaml] + +properties: + clocks: + type: phandle-array + required: true + description: source + + divider: + type: int + required: true + description: Divide source clock by this 8-bits value. Typically 1. + + "#clock-cells": + const: 0 diff --git a/dts/bindings/clock/bflb,clock-controller.yaml b/dts/bindings/clock/bflb,clock-controller.yaml new file mode 100644 index 000000000000..c0a63a066566 --- /dev/null +++ b/dts/bindings/clock/bflb,clock-controller.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025 MASSDRIVER EI (massdriver.space) +# SPDX-License-Identifier: Apache-2.0 + +description: Bouffalolab Clock Controller for Drivers + +compatible: "bflb,clock-controller" + +include: [base.yaml, clock-controller.yaml] diff --git a/dts/bindings/clock/nordic,nrf-auxpll.yaml b/dts/bindings/clock/nordic,nrf-auxpll.yaml index 6eec285f39eb..9555995f0b4d 100644 --- a/dts/bindings/clock/nordic,nrf-auxpll.yaml +++ b/dts/bindings/clock/nordic,nrf-auxpll.yaml @@ -43,7 +43,7 @@ properties: required: true description: | Value used to set the fractional PLL divider ratio (can be set between - divider ratios 4 to 5). Valid values range from 0 to 65535. + divider ratios 4 to 5). Valid values shown in dt-bindings/clock/nrf-auxpll.h. nordic,out-div: type: int diff --git a/dts/bindings/clock/nordic,nrf-fll16m.yaml b/dts/bindings/clock/nordic,nrf-fll16m.yaml index 8c7187965ae5..cfbbb0c40932 100644 --- a/dts/bindings/clock/nordic,nrf-fll16m.yaml +++ b/dts/bindings/clock/nordic,nrf-fll16m.yaml @@ -18,6 +18,7 @@ description: | fll16m { open-loop-accuracy-ppm = <20000>; + open-loop-startup-time-us = <400>; clocks = <&hfxo>, <&lfxo>; clock-names = "hfxo", "lfxo"; }; @@ -32,4 +33,10 @@ properties: open-loop-accuracy-ppm: type: int - description: Clock accuracy in parts per million if open-loop clock source is used. + description: Clock accuracy in parts per million + required: true + + open-loop-startup-time-us: + type: int + description: Clock startup time if open-loop clock source is used. + required: true diff --git a/dts/bindings/clock/nordic,nrf-iron-hsfll-local.yaml b/dts/bindings/clock/nordic,nrf-iron-hsfll-local.yaml new file mode 100644 index 000000000000..65769fb107f7 --- /dev/null +++ b/dts/bindings/clock/nordic,nrf-iron-hsfll-local.yaml @@ -0,0 +1,59 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Nordic nRF local HSFLL with IronSide DVFS support + + The local HSFLL mixed-mode IP generates several clock frequencies in the range + from 64 MHz to 400 MHz (in steps of 16 MHz). + + Usage example: + + hsfll: clock@deadbeef { + compatible = "nordic,nrf-hsfll-local"; + reg = <0xdeadbeef 0x1000>; + clocks = <&fll16m>; + clock-frequency = ; + nordic,ficrs = <&ficr NRF_FICR_TRIM_APPLICATION_HSFLL_TRIM_VSUP>, + <&ficr NRF_FICR_TRIM_APPLICATION_HSFLL_TRIM_COARSE_0>, + <&ficr NRF_FICR_TRIM_APPLICATION_HSFLL_TRIM_FINE_0>; + nordic,ficr-names = "vsup", "coarse", "fine"; + }; + + Required FICR entries are for VSUP, COARSE and FINE trim values. + +compatible: "nordic,nrf-iron-hsfll-local" + +include: [base.yaml, fixed-clock.yaml, nordic-nrf-ficr-client.yaml] + +properties: + reg: + required: true + + clocks: + required: true + + clock-frequency: + enum: + - 64000000 + - 80000000 + - 96000000 + - 112000000 + - 128000000 + - 144000000 + - 160000000 + - 176000000 + - 192000000 + - 208000000 + - 224000000 + - 240000000 + - 256000000 + - 272000000 + - 288000000 + - 304000000 + - 320000000 + - 336000000 + - 352000000 + - 368000000 + - 384000000 + - 400000000 diff --git a/dts/bindings/clock/nordic,nrf-lfclk.yaml b/dts/bindings/clock/nordic,nrf-lfclk.yaml index f7df4d8a435e..a0f95d6c9277 100644 --- a/dts/bindings/clock/nordic,nrf-lfclk.yaml +++ b/dts/bindings/clock/nordic,nrf-lfclk.yaml @@ -21,6 +21,8 @@ description: | lfclk { lfrc-accuracy-ppm = <500>; lflprc-accuracy-ppm = <1000>; + lfrc-startup-time-us = <400>; + lflprc-startup-time-us = <400>; clocks = <&hfxo>, <&lfxo>; clock-names = "hfxo", "lfxo"; }; @@ -40,3 +42,11 @@ properties: lflprc-accuracy-ppm: type: int description: Clock accuracy in parts per million if LFLPRC clock source is used. + + lfrc-startup-time-us: + type: int + description: Clock startup time in microseconds if LFRC clock source is used. + + lflprc-startup-time-us: + type: int + description: Clock startup time in microseconds if LFLPRC clock source is used. diff --git a/dts/bindings/firmware/nordic,ironside-call.yaml b/dts/bindings/firmware/nordic,ironside-call.yaml index 14f39cb0b74c..a2605ff22943 100644 --- a/dts/bindings/firmware/nordic,ironside-call.yaml +++ b/dts/bindings/firmware/nordic,ironside-call.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2025 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -description: IPC configuration for Nordic IRONside calls +description: IPC configuration for Nordic IronSide calls compatible: "nordic,ironside-call" diff --git a/dts/bindings/gpio/nordic,npm1304-gpio.yaml b/dts/bindings/gpio/nordic,npm1304-gpio.yaml new file mode 100644 index 000000000000..a6ff1a4656c3 --- /dev/null +++ b/dts/bindings/gpio/nordic,npm1304-gpio.yaml @@ -0,0 +1,12 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: nPM1304 GPIO Controller + +compatible: "nordic,npm1304-gpio" + +include: gpio-controller.yaml + +gpio-cells: + - pin + - flags diff --git a/dts/bindings/led/nordic,npm1300-led.yaml b/dts/bindings/led/nordic,npm1300-led.yaml index 90c420832f9d..3c240a94e35f 100644 --- a/dts/bindings/led/nordic,npm1300-led.yaml +++ b/dts/bindings/led/nordic,npm1300-led.yaml @@ -10,30 +10,4 @@ description: | compatible: "nordic,npm1300-led" -properties: - nordic,led0-mode: - type: string - required: true - enum: - - error - - charging - - host - description: LED 0 mode - - nordic,led1-mode: - type: string - required: true - enum: - - error - - charging - - host - description: LED 1 mode - - nordic,led2-mode: - type: string - required: true - enum: - - error - - charging - - host - description: LED 2 mode +include: "nordic,npm13xx-led-common.yaml" diff --git a/dts/bindings/led/nordic,npm1304-led.yaml b/dts/bindings/led/nordic,npm1304-led.yaml new file mode 100644 index 000000000000..d0e66857465e --- /dev/null +++ b/dts/bindings/led/nordic,npm1304-led.yaml @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Nordic nPM1304 LED controller + + The nPM1304 has three LED outputs. + Each LED can automatically display error or charging status, + or be controlled by software. + +compatible: "nordic,npm1304-led" + +include: "nordic,npm13xx-led-common.yaml" diff --git a/dts/bindings/led/nordic,npm13xx-led-common.yaml b/dts/bindings/led/nordic,npm13xx-led-common.yaml new file mode 100644 index 000000000000..6171258d7853 --- /dev/null +++ b/dts/bindings/led/nordic,npm13xx-led-common.yaml @@ -0,0 +1,32 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic nPM13xx LED controller common properties + +properties: + nordic,led0-mode: + type: string + required: true + enum: + - error + - charging + - host + description: LED 0 mode + + nordic,led1-mode: + type: string + required: true + enum: + - error + - charging + - host + description: LED 1 mode + + nordic,led2-mode: + type: string + required: true + enum: + - error + - charging + - host + description: LED 2 mode diff --git a/dts/bindings/mfd/nordic,npm1300.yaml b/dts/bindings/mfd/nordic,npm1300.yaml index 1fdfb42ef93b..accd7887c95c 100644 --- a/dts/bindings/mfd/nordic,npm1300.yaml +++ b/dts/bindings/mfd/nordic,npm1300.yaml @@ -5,40 +5,4 @@ description: Nordic nPM1300 compatible: "nordic,npm1300" -include: i2c-device.yaml - -properties: - reg: - required: true - - host-int-gpios: - type: phandle-array - description: Host pin for interrupt input - - pmic-int-pin: - type: int - description: Pmic pin number for interrupt output - - ship-to-active-time-ms: - type: int - description: | - Press duration required to wake from ship / hibernate in ms. - The default is the device powerup value. - enum: - - 16 - - 32 - - 64 - - 96 - - 304 - - 608 - - 1008 - - 3008 - default: 96 - - long-press-reset: - type: string - description: Long press reset configuration - enum: - - "one-button" - - "disabled" - - "two-button" +include: "nordic,npm13xx-common.yaml" diff --git a/dts/bindings/mfd/nordic,npm1304.yaml b/dts/bindings/mfd/nordic,npm1304.yaml new file mode 100644 index 000000000000..a861cd79e486 --- /dev/null +++ b/dts/bindings/mfd/nordic,npm1304.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic nPM1304 + +compatible: "nordic,npm1304" + +include: nordic,npm13xx-common.yaml diff --git a/dts/bindings/mfd/nordic,npm13xx-common.yaml b/dts/bindings/mfd/nordic,npm13xx-common.yaml new file mode 100644 index 000000000000..ed2bf7cbf684 --- /dev/null +++ b/dts/bindings/mfd/nordic,npm13xx-common.yaml @@ -0,0 +1,42 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic nPM13xx common properties + +include: i2c-device.yaml + +properties: + reg: + required: true + + host-int-gpios: + type: phandle-array + description: Host pin for interrupt input + + pmic-int-pin: + type: int + description: Pmic pin number for interrupt output + + ship-to-active-time-ms: + type: int + description: | + Press duration required to wake from ship / hibernate in ms. + The default is the device powerup value. + enum: + - 16 + - 32 + - 64 + - 96 + - 304 + - 608 + - 1008 + - 3008 + default: 96 + + long-press-reset: + type: string + description: Long press reset configuration + enum: + - "one-button" + - "disabled" + - "two-button" diff --git a/dts/bindings/misc/nordic,nrf-dppic-local.yaml b/dts/bindings/misc/nordic,nrf-dppic-local.yaml index 41029bb30621..a96b5a994c9e 100644 --- a/dts/bindings/misc/nordic,nrf-dppic-local.yaml +++ b/dts/bindings/misc/nordic,nrf-dppic-local.yaml @@ -11,3 +11,9 @@ description: | compatible: "nordic,nrf-dppic-local" include: ["nordic,nrf-dppic.yaml", "nordic,nrf-dppic-links.yaml"] + +properties: + channels: + type: int + required: true + description: Number of channels implemented by the DPPIC instance. diff --git a/dts/bindings/net/wireless/nordic,nrf-nfct-v2.yaml b/dts/bindings/net/wireless/nordic,nrf-nfct-v2.yaml index e6b34aff3ecc..f7602739114c 100644 --- a/dts/bindings/net/wireless/nordic,nrf-nfct-v2.yaml +++ b/dts/bindings/net/wireless/nordic,nrf-nfct-v2.yaml @@ -12,7 +12,8 @@ properties: type: boolean description: | When enabled this property will configure pins dedicated to NFCT - peripheral as regular GPIOs. This property must be applied in cpuapp - if NFCT pins are intended to be used as regular GPIOs by any core. + peripheral as regular GPIOs. If this property is applied in cpuapp then node + can be disabled or reserved (because NFCT is by default assigned to cpuapp). + If property is applied in cpurad CPU then node must be reserved. NFC pins in nRF54H series: P2.10 and P2.11 diff --git a/dts/bindings/regulator/nordic,npm1300-regulator.yaml b/dts/bindings/regulator/nordic,npm1300-regulator.yaml index 28b50dd34b79..e42199b68ddf 100644 --- a/dts/bindings/regulator/nordic,npm1300-regulator.yaml +++ b/dts/bindings/regulator/nordic,npm1300-regulator.yaml @@ -32,77 +32,4 @@ description: | compatible: "nordic,npm1300-regulator" -include: base.yaml - -properties: - dvs-gpios: - type: phandle-array - description: | - List of SOC GPIOs connected to PMIC GPIOs. - Set_dvs_mode will drive these pins as follows: - DVS mode 1 will enable the first pin - DVS mode 2 will enable the second pin - DVS mode 3 will drive the first and second pins - etc. - The effect of the mode change is defined by the enable-gpios - and pwm_gpios fields for each of the regulator blocks. - -child-binding: - include: - - name: regulator.yaml - property-allowlist: - - regulator-always-on - - regulator-boot-on - - regulator-boot-off - - regulator-min-microvolt - - regulator-max-microvolt - - regulator-init-microvolt - - regulator-allowed-modes - - regulator-initial-mode - - regulator-min-microamp - - regulator-max-microamp - - startup-delay-us - - off-on-delay-us - - properties: - retention-microvolt: - type: int - description: | - Retention mode voltage in microvolts. - - enable-gpio-config: - type: array - description: | - Regulator enable controlled by specified GPIO pin . - When set regulator must be enabled/disabled using set_dvs_mode. - - pwm-gpio-config: - type: array - description: | - Regulator enable controlled by specified GPIO pin . - When set regulator must be enabled/disabled using set_dvs_mode. - - retention-gpio-config: - type: array - description: | - Retention mode controlled by specified GPIO pin . - - soft-start-microamp: - type: int - enum: - - 10000 - - 20000 - - 35000 - - 50000 - description: | - Soft start current limit in microamps. - - nordic,anomaly38-disable-workaround: - type: boolean - description: | - Disable the SW workaround for nPM1300 anomaly #38. - When nPM1300 is in ULP mode, LDO is supplied from VSYS and - then LDO is enabled, it can take long time until the LDO - output has reached its target voltage. To avoid this, an i2c - read is performed shortly after an LDO is enabled. - See nPM1300 Errata manual for more details. +include: "nordic,npm13xx-regulator-common.yaml" diff --git a/dts/bindings/regulator/nordic,npm1304-regulator.yaml b/dts/bindings/regulator/nordic,npm1304-regulator.yaml new file mode 100644 index 000000000000..51ae13e675b5 --- /dev/null +++ b/dts/bindings/regulator/nordic,npm1304-regulator.yaml @@ -0,0 +1,35 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Nordic nPM1304 PMIC + + The PMIC has two buck converters and two LDOs. + The regulators need to be defined as child nodes, strictly following the + BUCK1,2 LDO1..2, node names. For + example: + + pmic@6b { + reg = <0x6b>; + ... + regulators { + compatible = "nordic,npm1304-regulator"; + + BUCK1 { + /* all properties for BUCK1 */ + }; + BUCK2 { + /* all properties for BUCK2 */ + }; + LDO1 { + /* all properties for LDO1 */ + }; + LDO2 { + /* all properties for LDO2 */ + }; + }; + }; + +compatible: "nordic,npm1304-regulator" + +include: "nordic,npm13xx-regulator-common.yaml" diff --git a/dts/bindings/regulator/nordic,npm13xx-regulator-common.yaml b/dts/bindings/regulator/nordic,npm13xx-regulator-common.yaml new file mode 100644 index 000000000000..35900c7ba373 --- /dev/null +++ b/dts/bindings/regulator/nordic,npm13xx-regulator-common.yaml @@ -0,0 +1,84 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic nPM13xx PMIC regulators common properties + +include: base.yaml + +properties: + dvs-gpios: + type: phandle-array + description: | + List of SOC GPIOs connected to PMIC GPIOs. + Set_dvs_mode will drive these pins as follows: + DVS mode 1 will enable the first pin + DVS mode 2 will enable the second pin + DVS mode 3 will drive the first and second pins + etc. + The effect of the mode change is defined by the enable-gpios + and pwm_gpios fields for each of the regulator blocks. + +child-binding: + include: + - name: regulator.yaml + property-allowlist: + - regulator-always-on + - regulator-boot-on + - regulator-boot-off + - regulator-min-microvolt + - regulator-max-microvolt + - regulator-init-microvolt + - regulator-allowed-modes + - regulator-initial-mode + - regulator-min-microamp + - regulator-max-microamp + - startup-delay-us + - off-on-delay-us + + properties: + retention-microvolt: + type: int + description: | + Retention mode voltage in microvolts. + + enable-gpio-config: + type: array + description: | + Regulator enable controlled by specified GPIO pin . + When set regulator must be enabled/disabled using set_dvs_mode. + + pwm-gpio-config: + type: array + description: | + Regulator enable controlled by specified GPIO pin . + When set regulator must be enabled/disabled using set_dvs_mode. + + retention-gpio-config: + type: array + description: | + Retention mode controlled by specified GPIO pin . + + soft-start-microamp: + type: int + enum: + - 10000 + - 20000 + - 35000 + - 50000 + description: | + Soft start current limit in microamps. + + active-discharge: + type: boolean + description: | + Enable active-discharge on the BUCK/LDO/LDSW output when disabled. + + nordic,anomaly38-disable-workaround: + type: boolean + description: | + Disable the SW workaround for nPM13xx anomaly #38. + When nPM13xx is in ULP mode, LDO is supplied from VSYS and + then LDO is enabled, it can take long time until the LDO + output has reached its target voltage. To avoid this, an i2c + read is performed shortly after an LDO is enabled. + See nPM13xx Errata manual for more details. diff --git a/dts/bindings/rng/nordic,nrf-prng.yaml b/dts/bindings/rng/nordic,nrf-prng.yaml new file mode 100644 index 000000000000..8936393a0b65 --- /dev/null +++ b/dts/bindings/rng/nordic,nrf-prng.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +description: This is a super simple PRNG + +compatible: "nordic,entropy-prng" + +include: base.yaml diff --git a/dts/bindings/sensor/nordic,npm1300-charger.yaml b/dts/bindings/sensor/nordic,npm1300-charger.yaml index 3fb83a85174a..af825cc59705 100644 --- a/dts/bindings/sensor/nordic,npm1300-charger.yaml +++ b/dts/bindings/sensor/nordic,npm1300-charger.yaml @@ -8,7 +8,7 @@ description: NPM1300 PMIC Charger compatible: "nordic,npm1300-charger" -include: [sensor-device.yaml] +include: "nordic,npm13xx-charger-common.yaml" properties: term-microvolt: @@ -31,7 +31,6 @@ properties: description: | Charge current in uA. Available range is 32 mA to 800 mA in 2mA steps. - The value specified will be rounded down to the closest implemented value. dischg-limit-microamp: type: int @@ -43,60 +42,6 @@ properties: Discharge current limit in uA. Available values are 200 mA and 1000 mA. - vbus-limit-microamp: - type: int - required: true - description: | - Vbus current limit in uA. - Available range is 100 mA to 1500 mA in 100 mA steps. - - thermistor-ohms: - type: int - required: true - enum: - - 0 - - 10000 - - 47000 - - 100000 - description: Thermistor nominal resistance type in ohms. - - thermistor-beta: - type: int - required: true - description: Beta value of selected thermistor. - - thermistor-cold-millidegrees: - type: int - description: Thermistor cold threshold in milli-degrees - - thermistor-cool-millidegrees: - type: int - description: Thermistor cool threshold in milli-degrees - - thermistor-warm-millidegrees: - type: int - description: Thermistor warm threshold in milli-degrees - - thermistor-hot-millidegrees: - type: int - description: Thermistor hot threshold in milli-degrees - - charging-enable: - type: boolean - description: | - Enable charging. - - trickle-microvolt: - type: int - enum: - - 2900000 - - 2500000 - default: 2900000 - description: | - Trickle voltage threshold in uV. - Trickle charging is enabled below this value. - If omitted the device default of 2.9V is used. - term-current-percent: type: int enum: @@ -107,25 +52,3 @@ properties: Termination current, as a percentage of current-microamp. Charge completes when the charge current falls below this value. If omitted the device default of 10% is used. - - vbatlow-charge-enable: - type: boolean - description: | - Allow charging when below the vbatlow threshold. - - disable-recharge: - type: boolean - description: | - Disable automatic recharge. - - dietemp-stop-millidegrees: - type: int - description: | - Die temperature halt threshold in milli-degrees. - When die temperature exceeds this threshold, charging will be inhibited. - - dietemp-resume-millidegrees: - type: int - description: | - Die temperature resume threshold in milli-degrees. - When die temperature falls below this threshold, charging will be permitted. diff --git a/dts/bindings/sensor/nordic,npm1304-charger.yaml b/dts/bindings/sensor/nordic,npm1304-charger.yaml new file mode 100644 index 000000000000..70a1a754b814 --- /dev/null +++ b/dts/bindings/sensor/nordic,npm1304-charger.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: nPM1304 PMIC Charger + +compatible: "nordic,npm1304-charger" + +include: "nordic,npm13xx-charger-common.yaml" + +properties: + term-microvolt: + type: int + required: true + description: | + Charge termination voltage in uV. + Available range is 3.6 V to 3.65 V and 4.0 V to 4.65 V in 50 mV steps. + + term-warm-microvolt: + type: int + description: | + Charge termination voltage when warm in uV. + Available range is 3.6 V to 3.65 V and 4.0 V to 4.65 V in 50 mV steps. + If omitted, the term-microvolt value will be used. + + current-microamp: + type: int + required: true + description: | + Charge current in uA. + Available range is 4 mA to 100 mA in 0.5 mA steps. + + dischg-limit-microamp: + type: int + const: 125000 + default: 125000 + description: | + Discharge current limit in uA. Fixed to 125 mA on nPM1304. + + term-current-percent: + type: int + enum: + - 10 + - 5 + default: 10 + description: | + Termination current, as a percentage of current-microamp. + Charge completes when the charge current falls below this value. + If omitted the device default of 10% is used. diff --git a/dts/bindings/sensor/nordic,npm13xx-charger-common.yaml b/dts/bindings/sensor/nordic,npm13xx-charger-common.yaml new file mode 100644 index 000000000000..c24f279c7b22 --- /dev/null +++ b/dts/bindings/sensor/nordic,npm13xx-charger-common.yaml @@ -0,0 +1,83 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: nPM13xx PMIC Charger common properties + +include: sensor-device.yaml + +properties: + vbus-limit-microamp: + type: int + required: true + description: | + Vbus current limit in uA. + Available range is 100 mA to 1500 mA in 100 mA steps. + + thermistor-ohms: + type: int + required: true + enum: + - 0 + - 10000 + - 47000 + - 100000 + description: Thermistor nominal resistance type in ohms. + + thermistor-beta: + type: int + required: true + description: Beta value of selected thermistor. + + thermistor-cold-millidegrees: + type: int + description: Thermistor cold threshold in milli-degrees + + thermistor-cool-millidegrees: + type: int + description: Thermistor cool threshold in milli-degrees + + thermistor-warm-millidegrees: + type: int + description: Thermistor warm threshold in milli-degrees + + thermistor-hot-millidegrees: + type: int + description: Thermistor hot threshold in milli-degrees + + charging-enable: + type: boolean + description: | + Enable charging. + + trickle-microvolt: + type: int + enum: + - 2900000 + - 2500000 + default: 2900000 + description: | + Trickle voltage threshold in uV. + Trickle charging is enabled below this value. + If omitted the device default of 2.9V is used. + + vbatlow-charge-enable: + type: boolean + description: | + Allow charging when below the vbatlow threshold. + + disable-recharge: + type: boolean + description: | + Disable automatic recharge. + + dietemp-stop-millidegrees: + type: int + description: | + Die temperature halt threshold in milli-degrees. + When die temperature exceeds this threshold, charging will be inhibited. + + dietemp-resume-millidegrees: + type: int + description: | + Die temperature resume threshold in milli-degrees. + When die temperature falls below this threshold, charging will be permitted. diff --git a/dts/bindings/spi/nordic,nrf-exmif-spi.yaml b/dts/bindings/spi/nordic,nrf-exmif-spi.yaml new file mode 100644 index 000000000000..d988b4146878 --- /dev/null +++ b/dts/bindings/spi/nordic,nrf-exmif-spi.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic External Memory Interface (EXMIF) used in SPI mode only + +compatible: "nordic,nrf-exmif-spi" + +include: snps,designware-spi.yaml diff --git a/dts/bindings/usb/zephyr,hid-device.yaml b/dts/bindings/usb/zephyr,hid-device.yaml index 2d20b450986b..1b055cf18d2a 100644 --- a/dts/bindings/usb/zephyr,hid-device.yaml +++ b/dts/bindings/usb/zephyr,hid-device.yaml @@ -8,11 +8,10 @@ compatible: "zephyr,hid-device" include: base.yaml properties: - interface-name: - type: string + label: description: | - HID device name. When this property is present, a USB device will use it - as the string descriptor of the interface. + The string defined by the label property is also used for the USB device + interface string descriptor. protocol-code: type: string diff --git a/dts/bindings/watchdog/nordic,npm1304-wdt.yaml b/dts/bindings/watchdog/nordic,npm1304-wdt.yaml new file mode 100644 index 000000000000..0fc81437199c --- /dev/null +++ b/dts/bindings/watchdog/nordic,npm1304-wdt.yaml @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: nPM1304 Watchdog + +compatible: "nordic,npm1304-wdt" + +include: base.yaml + +properties: + reset-gpios: + type: phandle-array + description: nPM1304 pin used as NRESETOUT diff --git a/dts/vendor/nordic/nrf54h20.dtsi b/dts/vendor/nordic/nrf54h20.dtsi index 32f126dddfdd..7b12fbb482e5 100644 --- a/dts/vendor/nordic/nrf54h20.dtsi +++ b/dts/vendor/nordic/nrf54h20.dtsi @@ -9,11 +9,11 @@ #include #include +#include #include #include #include #include -#include #include /delete-node/ &sw_pwm; @@ -151,10 +151,6 @@ reserved-memory { #address-cells = <1>; #size-cells = <1>; - - suit_storage_partition: memory@e1ed000 { - reg = <0xe1ed000 DT_SIZE_K(20)>; - }; }; clocks { @@ -177,6 +173,7 @@ #clock-cells = <0>; clock-frequency = ; open-loop-accuracy-ppm = <20000>; + open-loop-startup-time-us = <200>; /* To be measured */ clocks = <&hfxo>, <&lfxo>; clock-names = "hfxo", "lfxo"; }; @@ -199,6 +196,8 @@ status = "okay"; lfrc-accuracy-ppm = <500>; lflprc-accuracy-ppm = <1000>; + lfrc-startup-time-us = <200>; /* To be measured */ + lflprc-startup-time-us = <200>; /* To be measured */ clocks = <&hfxo>, <&lfxo>; clock-names = "hfxo", "lfxo"; }; @@ -227,13 +226,12 @@ write-block-size = <16>; }; - cpuapp_uicr: uicr@fff8000 { - compatible = "nordic,nrf-uicr-v2"; + uicr: uicr@fff8000 { + compatible = "nordic,nrf-uicr"; reg = <0xfff8000 DT_SIZE_K(2)>; #address-cells = <1>; #size-cells = <1>; ranges = <0x0 0xfff8000 DT_SIZE_K(2)>; - domain = <2>; bicr: bicr@7b0 { compatible = "nordic,nrf-bicr"; @@ -241,12 +239,6 @@ }; }; - cpurad_uicr: uicr@fffa000 { - compatible = "nordic,nrf-uicr-v2"; - reg = <0xfffa000 DT_SIZE_K(2)>; - domain = <3>; - }; - ficr: ficr@fffe000 { compatible = "nordic,nrf-ficr"; reg = <0xfffe000 DT_SIZE_K(2)>; @@ -276,7 +268,7 @@ ranges = <0x0 0x52000000 0x1000000>; cpuapp_hsfll: clock@d000 { - compatible = "nordic,nrf-hsfll-local"; + compatible = "nordic,nrf-iron-hsfll-local"; #clock-cells = <0>; reg = <0xd000 0x1000>; clocks = <&fll16m>; @@ -333,6 +325,7 @@ compatible = "nordic,nrf-hsfll-local"; #clock-cells = <0>; reg = <0xd000 0x1000>; + status = "disabled"; clocks = <&fll16m>; clock-frequency = ; nordic,ficrs = @@ -366,6 +359,7 @@ dppic020: dppic@22000 { compatible = "nordic,nrf-dppic-local"; reg = <0x22000 0x1000>; + channels = <32>; status = "disabled"; }; @@ -445,6 +439,15 @@ compatible = "nordic,nrf-ieee802154"; status = "disabled"; }; + + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + bt_hci_controller: bt_hci_controller { + compatible = "zephyr,bt-hci-ll-sw-split"; + status = "disabled"; + }; }; ccm030: ccm@3a000 { @@ -557,7 +560,7 @@ clocks = <&hfxo>; #clock-cells = <0>; nordic,ficrs = <&ficr NRF_FICR_TRIM_GLOBAL_CANPLL_TRIM_CTUNE>; - nordic,frequency = <0>; + nordic,frequency = ; nordic,out-div = <2>; nordic,out-drive = <0>; nordic,current-tune = <6>; @@ -917,7 +920,7 @@ }; nfct: nfct@985000 { - compatible = "nordic,nrf-nfct"; + compatible = "nordic,nrf-nfct-v2"; reg = <0x985000 0x1000>; status = "disabled"; interrupts = <389 NRF_DEFAULT_IRQ_PRIORITY>; diff --git a/dts/vendor/nordic/nrf54l09.dtsi b/dts/vendor/nordic/nrf54l09.dtsi index 3dc17dabd9ba..90ecc49b877c 100644 --- a/dts/vendor/nordic/nrf54l09.dtsi +++ b/dts/vendor/nordic/nrf54l09.dtsi @@ -221,9 +221,11 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; status = "disabled"; diff --git a/dts/vendor/nordic/nrf54l20.dtsi b/dts/vendor/nordic/nrf54l20.dtsi index 4a4e90e75b4e..f3b63d1ed445 100644 --- a/dts/vendor/nordic/nrf54l20.dtsi +++ b/dts/vendor/nordic/nrf54l20.dtsi @@ -261,9 +261,10 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; status = "disabled"; diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index 336d642afedf..be367ee81d89 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -250,9 +250,11 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; status = "disabled"; diff --git a/dts/vendor/nordic/nrf9280.dtsi b/dts/vendor/nordic/nrf9280.dtsi index d7c20e855c16..06e0a3a15145 100644 --- a/dts/vendor/nordic/nrf9280.dtsi +++ b/dts/vendor/nordic/nrf9280.dtsi @@ -250,6 +250,7 @@ dppic020: dppic@22000 { compatible = "nordic,nrf-dppic-local"; reg = <0x22000 0x1000>; + channels = <32>; status = "disabled"; }; diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 278620dfaf02..ae4fbcaeddac 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,6 +34,39 @@ #define ROMSTART_REGION ROMABLE_REGION #endif +#if USE_PARTITION_MANAGER + +#include + +#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) +/* We are linking against S1, create symbol containing the flash ID of S0. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S0_ID; + +#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ + +#ifdef PM_S1_ID +/* We are linking against S0, create symbol containing the flash ID of S1. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S1_ID; +#endif /* PM_S1_ID */ + +#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ + +#define ROM_ADDR PM_ADDRESS +#define ROM_SIZE PM_SIZE + +#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) +#define RAM_SIZE CONFIG_PM_SRAM_SIZE +#else +#define RAM_SIZE PM_SRAM_SIZE +#endif +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) #define ROM_ADDR RAM_ADDR #else @@ -55,6 +88,23 @@ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#endif /* USE_PARTITION_MANAGER */ + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) +#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) +#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) +#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) +#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) +#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) +#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) +#endif + #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/bluetooth/bluetooth.h b/include/zephyr/bluetooth/bluetooth.h index c68327647599..7f287f1c3448 100644 --- a/include/zephyr/bluetooth/bluetooth.h +++ b/include/zephyr/bluetooth/bluetooth.h @@ -1489,6 +1489,10 @@ struct bt_le_per_adv_param { * This error code is only guaranteed when using Zephyr * controller, for other controllers code returned in * this case may be -EIO. + * @return -EPERM When @kconfig{CONFIG_BT_PRIVACY} and + * @kconfig{CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS} are enabled and connectable + * advertising is requested, and the given local identity has a conflicting + * key with another local identity for which advertising is already started. */ int bt_le_adv_start(const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, @@ -1616,6 +1620,12 @@ struct bt_le_ext_adv_start_param { * * @param adv Advertising set object. * @param param Advertise start parameters. + * + * @return Zero on success or (negative) error code otherwise. + * @return -EPERM When @kconfig{CONFIG_BT_PRIVACY} and + * @kconfig{CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS} are enabled and connectable + * advertising is requested, and the given local identity has a conflicting + * key with another local identity for which advertising is already started. */ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, const struct bt_le_ext_adv_start_param *param); diff --git a/include/zephyr/drivers/clock_control/nrf_clock_control.h b/include/zephyr/drivers/clock_control/nrf_clock_control.h index bbc581f96c49..f407be61d4db 100644 --- a/include/zephyr/drivers/clock_control/nrf_clock_control.h +++ b/include/zephyr/drivers/clock_control/nrf_clock_control.h @@ -171,9 +171,6 @@ uint32_t z_nrf_clock_bt_ctlr_hf_get_startup_time_us(void); #endif /* defined(CONFIG_CLOCK_CONTROL_NRF) */ - -#if defined(CONFIG_CLOCK_CONTROL_NRF2) - /* Specifies to use the maximum available frequency for a given clock. */ #define NRF_CLOCK_CONTROL_FREQUENCY_MAX UINT32_MAX @@ -204,6 +201,12 @@ __subsystem struct nrf_clock_control_driver_api { int (*cancel_or_release)(const struct device *dev, const struct nrf_clock_spec *spec, struct onoff_client *cli); + int (*resolve)(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec); + int (*get_startup_time)(const struct device *dev, + const struct nrf_clock_spec *spec, + uint32_t *startup_time_us); }; /** @@ -324,6 +327,54 @@ int nrf_clock_control_cancel_or_release(const struct device *dev, return api->cancel_or_release(dev, spec, cli); } +/** + * @brief Resolve a requested clock spec to resulting spec. + * + * @param dev Device structure. + * @param req_spec The requested clock specification. + * @param res_spec Destination for the resulting clock specification. + * + * @retval Successful if successful. + * @retval -errno code if failure + */ +static inline int nrf_clock_control_resolve(const struct device *dev, + const struct nrf_clock_spec *req_spec, + struct nrf_clock_spec *res_spec) +{ + const struct nrf_clock_control_driver_api *api = + (const struct nrf_clock_control_driver_api *)dev->api; + + if (api->resolve == NULL) { + return -ENOSYS; + } + + return api->resolve(dev, req_spec, res_spec); +} + +/** + * @brief Get the startup time of a clock. + * + * @param dev Device structure. + * @param spec Clock specification to get startup time for. + * @param startup_time_us Destination for startup time in microseconds. + * + * @retval Successful if successful. + * @retval -errno code if failure. + */ +static inline int nrf_clock_control_get_startup_time(const struct device *dev, + const struct nrf_clock_spec *spec, + uint32_t *startup_time_us) +{ + const struct nrf_clock_control_driver_api *api = + (const struct nrf_clock_control_driver_api *)dev->api; + + if (api->get_startup_time == NULL) { + return -ENOSYS; + } + + return api->get_startup_time(dev, spec, startup_time_us); +} + /** @brief Request the HFXO from Zero Latency Interrupt context. * * Function is optimized for use in Zero Latency Interrupt context. @@ -348,8 +399,6 @@ void nrf_clock_control_hfxo_request(void); */ void nrf_clock_control_hfxo_release(void); -#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */ - #ifdef __cplusplus } #endif diff --git a/include/zephyr/drivers/firmware/nrf_ironside/boot_report.h b/include/zephyr/drivers/firmware/nrf_ironside/boot_report.h index 8a209b8788da..509c05babcbf 100644 --- a/include/zephyr/drivers/firmware/nrf_ironside/boot_report.h +++ b/include/zephyr/drivers/firmware/nrf_ironside/boot_report.h @@ -9,14 +9,14 @@ #include #include -/** Constant used to check if an Nordic IRONside SE boot report has been written. */ +/** Constant used to check if an Nordic IronSide SE boot report has been written. */ #define IRONSIDE_BOOT_REPORT_MAGIC (0x4d69546fUL) /** Length of the local domain context buffer in bytes. */ #define IRONSIDE_BOOT_REPORT_LOCAL_DOMAIN_CONTEXT_SIZE (16UL) /** Length of the random data buffer in bytes. */ #define IRONSIDE_BOOT_REPORT_RANDOM_DATA_SIZE (32UL) -/** @brief IRONside version structure. */ +/** @brief IronSide version structure. */ struct ironside_version { /** Wrapping sequence number ranging from 1-126, incremented for each release. */ uint8_t seqnum; @@ -43,13 +43,13 @@ struct ironside_boot_report_uicr_error { } description; }; -/** @brief IRONside boot report. */ +/** @brief IronSide boot report. */ struct ironside_boot_report { /** Magic value used to identify valid boot report */ uint32_t magic; - /** Firmware version of IRONside SE. */ + /** Firmware version of IronSide SE. */ struct ironside_version ironside_se_version; - /** Firmware version of IRONside SE recovery firmware. */ + /** Firmware version of IronSide SE recovery firmware. */ struct ironside_version ironside_se_recovery_version; /** Copy of SICR.UROT.UPDATE.STATUS.*/ uint32_t ironside_update_status; @@ -64,9 +64,9 @@ struct ironside_boot_report { }; /** - * @brief Get a pointer to the IRONside boot report. + * @brief Get a pointer to the IronSide boot report. * - * @param[out] report Will be set to point to the IRONside boot report. + * @param[out] report Will be set to point to the IronSide boot report. * * @retval 0 if successful. * @retval -EFAULT if the magic field in the report is incorrect. diff --git a/include/zephyr/drivers/firmware/nrf_ironside/call.h b/include/zephyr/drivers/firmware/nrf_ironside/call.h index 178b9371cdb7..d67e97622025 100644 --- a/include/zephyr/drivers/firmware/nrf_ironside/call.h +++ b/include/zephyr/drivers/firmware/nrf_ironside/call.h @@ -8,7 +8,7 @@ #include -/** @brief Maximum number of arguments to an IRONside call. +/** @brief Maximum number of arguments to an IronSide call. * * This is chosen so that the containing message buffer size is minimal but * cache line aligned. @@ -50,7 +50,7 @@ struct ironside_call_buf { */ /** - * @brief Allocate memory for an IRONside call. + * @brief Allocate memory for an IronSide call. * * This function will block when no buffers are available, until one is * released by another thread on the client side. @@ -60,7 +60,7 @@ struct ironside_call_buf { struct ironside_call_buf *ironside_call_alloc(void); /** - * @brief Dispatch an IRONside call. + * @brief Dispatch an IronSide call. * * This function will block until a response is received from the server. * @@ -71,7 +71,7 @@ struct ironside_call_buf *ironside_call_alloc(void); void ironside_call_dispatch(struct ironside_call_buf *buf); /** - * @brief Release an IRONside call buffer. + * @brief Release an IronSide call buffer. * * This function must be called after processing the response. * diff --git a/include/zephyr/drivers/firmware/nrf_ironside/cpuconf.h b/include/zephyr/drivers/firmware/nrf_ironside/cpuconf.h index e6f2150b6e22..bed8932868fe 100644 --- a/include/zephyr/drivers/firmware/nrf_ironside/cpuconf.h +++ b/include/zephyr/drivers/firmware/nrf_ironside/cpuconf.h @@ -53,7 +53,7 @@ BUILD_ASSERT(IRONSIDE_CPUCONF_NUM_ARGS <= NRF_IRONSIDE_CALL_NUM_ARGS); * @param cpu The CPU to be booted * @param vector_table Pointer to the vector table used to boot the CPU. * @param cpu_wait When this is true, the CPU will WAIT even if the CPU has clock. - * @param msg A message that can be placed in radiocore's boot report. + * @param msg A message that can be placed in cpu's boot report. * @param msg_size Size of the message in bytes. * * @note cpu_wait is only intended to be enabled for debug purposes @@ -63,7 +63,7 @@ BUILD_ASSERT(IRONSIDE_CPUCONF_NUM_ARGS <= NRF_IRONSIDE_CALL_NUM_ARGS); * If the given msg_size is less than that, the remaining bytes are set to zero. * * @retval 0 on success or if the CPU has already booted. - * @retval Positive non-0 error status if reported by IRONside call. + * @retval Positive non-0 error status if reported by IronSide call. * @retval -IRONSIDE_CPUCONF_ERROR_WRONG_CPU if cpu is unrecognized * @retval -IRONSIDE_CPUCONF_ERROR_MESSAGE_TOO_LARGE if msg_size is greater than * IRONSIDE_CPUCONF_SERVICE_MSG_MAX_SIZE. diff --git a/include/zephyr/drivers/firmware/nrf_ironside/dvfs.h b/include/zephyr/drivers/firmware/nrf_ironside/dvfs.h new file mode 100644 index 000000000000..5a80f062bd76 --- /dev/null +++ b/include/zephyr/drivers/firmware/nrf_ironside/dvfs.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_DVFS_H_ +#define ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_DVFS_H_ + +#include +#include +#include +#include + +enum ironside_dvfs_oppoint { + IRONSIDE_DVFS_OPP_HIGH = 0, + IRONSIDE_DVFS_OPP_MEDLOW = 1, + IRONSIDE_DVFS_OPP_LOW = 2 +}; + +/** + * @brief Number of DVFS oppoints supported by IronSide. + * + * This is the number of different DVFS oppoints that can be set on IronSide. + * The oppoints are defined in the `ironside_dvfs_oppoint` enum. + */ +#define IRONSIDE_DVFS_OPPOINT_COUNT (3) + +/** + * @name IronSide DVFS service error codes. + * @{ + */ + +/** The requested DVFS oppoint is not allowed. */ +#define IRONSIDE_DVFS_ERROR_WRONG_OPPOINT (1) +/** Waiting for mutex lock timed out, or hardware is busy. */ +#define IRONSIDE_DVFS_ERROR_BUSY (2) +/** There is configuration error in the DVFS service. */ +#define IRONSIDE_DVFS_ERROR_OPPOINT_DATA (3) +/** The caller does not have permission to change the DVFS oppoint. */ +#define IRONSIDE_DVFS_ERROR_PERMISSION (4) +/** The requested DVFS oppoint is already set, no change needed. */ +#define IRONSIDE_DVFS_ERROR_NO_CHANGE_NEEDED (5) +/** The operation timed out, possibly due to a hardware issue. */ +#define IRONSIDE_DVFS_ERROR_TIMEOUT (6) +/** The DVFS oppoint change operation is not allowed in the ISR context. */ +#define IRONSIDE_DVFS_ERROR_ISR_NOT_ALLOWED (7) + +/** + * @} + */ + +/* IronSide call identifiers with implicit versions. + * + * With the initial "version 0", the service ABI is allowed to break until the + * first production release of IronSide SE. + */ +#define IRONSIDE_CALL_ID_DVFS_SERVICE_V0 3 + +/* Index of the DVFS oppoint within the service buffer. */ +#define IRONSIDE_DVFS_SERVICE_OPPOINT_IDX (0) +/* Index of the return code within the service buffer. */ +#define IRONSIDE_DVFS_SERVICE_RETCODE_IDX (0) + +/** + * @brief Change the current DVFS oppoint. + * + * This function will request a change of the current DVFS oppoint to the + * specified value. It will block until the change is applied. + * + * @param dvfs_oppoint The new DVFS oppoint to set. + * @return int 0 on success, negative error code on failure. + */ +int ironside_dvfs_change_oppoint(enum ironside_dvfs_oppoint dvfs_oppoint); + +/** + * @brief Check if the given oppoint is valid. + * + * @param dvfs_oppoint The oppoint to check. + * @return true if the oppoint is valid, false otherwise. + */ +static inline bool ironside_dvfs_is_oppoint_valid(enum ironside_dvfs_oppoint dvfs_oppoint) +{ + if (dvfs_oppoint != IRONSIDE_DVFS_OPP_HIGH && + dvfs_oppoint != IRONSIDE_DVFS_OPP_MEDLOW && + dvfs_oppoint != IRONSIDE_DVFS_OPP_LOW) { + return false; + } + + return true; +} + +#endif /* ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_DVFS_H_ */ diff --git a/include/zephyr/drivers/firmware/nrf_ironside/tdd.h b/include/zephyr/drivers/firmware/nrf_ironside/tdd.h new file mode 100644 index 000000000000..d588f6be66db --- /dev/null +++ b/include/zephyr/drivers/firmware/nrf_ironside/tdd.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_TDD_H_ +#define ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_TDD_H_ + +#include + +#include + +#define IRONSIDE_SE_TDD_SERVICE_ERROR_INVALID_CONFIG (1) + +#define IRONSIDE_SE_CALL_ID_TDD_V0 4 + +#define IRONSIDE_SE_TDD_SERVICE_REQ_CONFIG_IDX 0 +#define IRONSIDE_SE_TDD_SERVICE_RSP_RETCODE_IDX 0 + +enum ironside_se_tdd_config { + RESERVED0 = 0, /* Reserved */ + /** Turn off the TDD */ + IRONSIDE_SE_TDD_CONFIG_OFF = 1, + /** Turn on the TDD with default configuration */ + IRONSIDE_SE_TDD_CONFIG_ON_DEFAULT = 2, +}; + +/** + * @brief Control the Trace and Debug Domain (TDD). + * + * @param config The configuration to be applied. + * + * @retval 0 on success. + * @retval -IRONSIDE_SE_TDD_ERROR_EINVAL on invalid argument. + */ +int ironside_se_tdd_configure(const enum ironside_se_tdd_config config); + +#endif /* ZEPHYR_INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_NRF_IRONSIDE_TDD_H_ */ diff --git a/include/zephyr/drivers/firmware/nrf_ironside/update.h b/include/zephyr/drivers/firmware/nrf_ironside/update.h index 62191b3285b3..5da02c97e6dd 100644 --- a/include/zephyr/drivers/firmware/nrf_ironside/update.h +++ b/include/zephyr/drivers/firmware/nrf_ironside/update.h @@ -30,10 +30,10 @@ /** Length of the update signature in bytes. */ #define IRONSIDE_UPDATE_SIGNATURE_LENGTH (64) -/* IRONside call identifiers with implicit versions. +/* IronSide call identifiers with implicit versions. * * With the initial "version 0", the service ABI is allowed to break until the - * first production release of IRONside SE. + * first production release of IronSide SE. */ #define IRONSIDE_CALL_ID_UPDATE_SERVICE_V0 1 @@ -43,7 +43,7 @@ #define IRONSIDE_UPDATE_SERVICE_RETCODE_IDX (0) /** - * @brief IRONside update blob. + * @brief IronSide update blob. */ struct ironside_update_blob { uint8_t manifest[IRONSIDE_UPDATE_MANIFEST_LENGTH]; @@ -53,9 +53,9 @@ struct ironside_update_blob { }; /** - * @brief Request a firmware upgrade of the IRONside SE. + * @brief Request a firmware upgrade of the IronSide SE. * - * This invokes the IRONside SE update service. The device must be restarted for the update + * This invokes the IronSide SE update service. The device must be restarted for the update * to be installed. Check the update status in the application boot report to see if the update * was successfully installed. * @@ -63,7 +63,7 @@ struct ironside_update_blob { * * @retval -IRONSIDE_UPDATE_ERROR_NOT_PERMITTED if missing access to the update candidate. * @retval -IRONSIDE_UPDATE_ERROR_SICR_WRITE_FAILED if writing update parameters to SICR failed. - * @returns Positive non-0 error status if reported by IRONside call. + * @returns Positive non-0 error status if reported by IronSide call. * @returns 0 on a successful request (although the update itself may still fail). * */ diff --git a/include/zephyr/drivers/i2c.h b/include/zephyr/drivers/i2c.h index 09640e3275d3..c1972782660c 100644 --- a/include/zephyr/drivers/i2c.h +++ b/include/zephyr/drivers/i2c.h @@ -635,7 +635,7 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs /** @endcond */ /** - * @brief Like DEVICE_DT_DEFINE() with I2C specifics. + * @brief Like DEVICE_DT_DEINIT_DEFINE() with I2C specifics. * * @details Defines a device which implements the I2C API. May * generate a custom device_state container struct and init_fn @@ -645,6 +645,8 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs * * @param init_fn Name of the init function of the driver. Can be `NULL`. * + * @param deinit_fn Name of the deinit function of the driver. Can be `NULL`. + * * @param pm PM device resources reference (NULL if device does not use PM). * * @param data Pointer to the device's private data. @@ -661,14 +663,14 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs * @param api Provides an initial pointer to the API function struct * used by the driver. Can be NULL. */ -#define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \ - prio, api, ...) \ +#define I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, \ + data, config, level, prio, api, ...)\ Z_I2C_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \ Z_I2C_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \ Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \ DEVICE_DT_NAME(node_id), \ &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \ - NULL, Z_DEVICE_DT_FLAGS(node_id), pm, data, \ + deinit_fn, Z_DEVICE_DT_FLAGS(node_id), pm, data,\ config, level, prio, api, \ &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \ __VA_ARGS__) @@ -683,12 +685,32 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs ARG_UNUSED(num_msgs); } +#define I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, \ + data, config, level, prio, api, ...)\ + DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, data, \ + config, level, prio, api, __VA_ARGS__) + +#endif /* CONFIG_I2C_STATS */ + +/** + * @brief Like I2C_DEVICE_DT_DEINIT_DEFINE() but without deinit_fn + */ #define I2C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \ prio, api, ...) \ - DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \ - prio, api, __VA_ARGS__) + I2C_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, \ + config, level, prio, api, \ + __VA_ARGS__) -#endif /* CONFIG_I2C_STATS */ +/** + * @brief Like I2C_DEVICE_DT_DEINIT_DEFINE() for an instance of a DT_DRV_COMPAT compatible + * + * @param inst instance number. This is replaced by + * DT_DRV_COMPAT(inst) in the call to I2C_DEVICE_DT_DEINIT_DEFINE(). + * + * @param ... other parameters as expected by I2C_DEVICE_DT_DEINIT_DEFINE(). + */ +#define I2C_DEVICE_DT_INST_DEINIT_DEFINE(inst, ...) \ + I2C_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) /** * @brief Like I2C_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible @@ -701,7 +723,6 @@ static inline void i2c_xfer_stats(const struct device *dev, struct i2c_msg *msgs #define I2C_DEVICE_DT_INST_DEFINE(inst, ...) \ I2C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) - /** * @brief Configure operation of a host controller. * diff --git a/include/zephyr/drivers/mfd/npm1300.h b/include/zephyr/drivers/mfd/npm13xx.h similarity index 58% rename from include/zephyr/drivers/mfd/npm1300.h rename to include/zephyr/drivers/mfd/npm13xx.h index 4dd03fa2ec31..b9e6d5120f67 100644 --- a/include/zephyr/drivers/mfd/npm1300.h +++ b/include/zephyr/drivers/mfd/npm13xx.h @@ -3,15 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_NPM1300_H_ -#define ZEPHYR_INCLUDE_DRIVERS_MFD_NPM1300_H_ +#ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_ +#define ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_ #ifdef __cplusplus extern "C" { #endif /** - * @defgroup mdf_interface_npm1300 MFD NPM1300 Interface + * @defgroup mfd_interface_npm13xx MFD NPM13XX Interface * @ingroup mfd_interfaces * @{ */ @@ -22,28 +22,28 @@ extern "C" { #include #include -enum mfd_npm1300_event_t { - NPM1300_EVENT_CHG_COMPLETED, - NPM1300_EVENT_CHG_ERROR, - NPM1300_EVENT_BATTERY_DETECTED, - NPM1300_EVENT_BATTERY_REMOVED, - NPM1300_EVENT_SHIPHOLD_PRESS, - NPM1300_EVENT_SHIPHOLD_RELEASE, - NPM1300_EVENT_WATCHDOG_WARN, - NPM1300_EVENT_VBUS_DETECTED, - NPM1300_EVENT_VBUS_REMOVED, - NPM1300_EVENT_GPIO0_EDGE, - NPM1300_EVENT_GPIO1_EDGE, - NPM1300_EVENT_GPIO2_EDGE, - NPM1300_EVENT_GPIO3_EDGE, - NPM1300_EVENT_GPIO4_EDGE, - NPM1300_EVENT_MAX +enum mfd_npm13xx_event_t { + NPM13XX_EVENT_CHG_COMPLETED, + NPM13XX_EVENT_CHG_ERROR, + NPM13XX_EVENT_BATTERY_DETECTED, + NPM13XX_EVENT_BATTERY_REMOVED, + NPM13XX_EVENT_SHIPHOLD_PRESS, + NPM13XX_EVENT_SHIPHOLD_RELEASE, + NPM13XX_EVENT_WATCHDOG_WARN, + NPM13XX_EVENT_VBUS_DETECTED, + NPM13XX_EVENT_VBUS_REMOVED, + NPM13XX_EVENT_GPIO0_EDGE, + NPM13XX_EVENT_GPIO1_EDGE, + NPM13XX_EVENT_GPIO2_EDGE, + NPM13XX_EVENT_GPIO3_EDGE, + NPM13XX_EVENT_GPIO4_EDGE, + NPM13XX_EVENT_MAX }; /** - * @brief Read multiple registers from npm1300 + * @brief Read multiple registers from npm13xx * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param base Register base address (bits 15..8 of 16-bit address) * @param offset Register offset address (bits 7..0 of 16-bit address) * @param data Pointer to buffer for received data @@ -51,37 +51,37 @@ enum mfd_npm1300_event_t { * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_read_dt()) */ -int mfd_npm1300_reg_read_burst(const struct device *dev, uint8_t base, uint8_t offset, void *data, +int mfd_npm13xx_reg_read_burst(const struct device *dev, uint8_t base, uint8_t offset, void *data, size_t len); /** - * @brief Read single register from npm1300 + * @brief Read single register from npm13xx * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param base Register base address (bits 15..8 of 16-bit address) * @param offset Register offset address (bits 7..0 of 16-bit address) * @param data Pointer to buffer for received data * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_read_dt()) */ -int mfd_npm1300_reg_read(const struct device *dev, uint8_t base, uint8_t offset, uint8_t *data); +int mfd_npm13xx_reg_read(const struct device *dev, uint8_t base, uint8_t offset, uint8_t *data); /** - * @brief Write single register to npm1300 + * @brief Write single register to npm13xx * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param base Register base address (bits 15..8 of 16-bit address) * @param offset Register offset address (bits 7..0 of 16-bit address) * @param data data to write * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_dt()) */ -int mfd_npm1300_reg_write(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data); +int mfd_npm13xx_reg_write(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data); /** - * @brief Write two registers to npm1300 + * @brief Write two registers to npm13xx * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param base Register base address (bits 15..8 of 16-bit address) * @param offset Register offset address (bits 7..0 of 16-bit address) * @param data1 first byte of data to write @@ -89,13 +89,13 @@ int mfd_npm1300_reg_write(const struct device *dev, uint8_t base, uint8_t offset * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_dt()) */ -int mfd_npm1300_reg_write2(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data1, +int mfd_npm13xx_reg_write2(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data1, uint8_t data2); /** - * @brief Update selected bits in npm1300 register + * @brief Update selected bits in npm13xx register * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param base Register base address (bits 15..8 of 16-bit address) * @param offset Register offset address (bits 7..0 of 16-bit address) * @param data data to write @@ -103,59 +103,59 @@ int mfd_npm1300_reg_write2(const struct device *dev, uint8_t base, uint8_t offse * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_read_dt(), i2c_write_dt()) */ -int mfd_npm1300_reg_update(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data, +int mfd_npm13xx_reg_update(const struct device *dev, uint8_t base, uint8_t offset, uint8_t data, uint8_t mask); /** - * @brief Write npm1300 timer register + * @brief Write npm13xx timer register * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param time_ms timer value in ms * @retval 0 If successful * @retval -EINVAL if time value is too large * @retval -errno In case of any bus error (see i2c_write_dt()) */ -int mfd_npm1300_set_timer(const struct device *dev, uint32_t time_ms); +int mfd_npm13xx_set_timer(const struct device *dev, uint32_t time_ms); /** - * @brief npm1300 full power reset + * @brief npm13xx full power reset * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @retval 0 If successful * @retval -errno In case of any bus error (see i2c_write_dt()) */ -int mfd_npm1300_reset(const struct device *dev); +int mfd_npm13xx_reset(const struct device *dev); /** - * @brief npm1300 hibernate + * @brief npm13xx hibernate * * Enters low power state, and wakes after specified time * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param time_ms timer value in ms * @retval 0 If successful * @retval -EINVAL if time value is too large * @retval -errno In case of any bus error (see i2c_write_dt()) */ -int mfd_npm1300_hibernate(const struct device *dev, uint32_t time_ms); +int mfd_npm13xx_hibernate(const struct device *dev, uint32_t time_ms); /** - * @brief Add npm1300 event callback + * @brief Add npm13xx event callback * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param callback callback * @return 0 on success, -errno on failure */ -int mfd_npm1300_add_callback(const struct device *dev, struct gpio_callback *callback); +int mfd_npm13xx_add_callback(const struct device *dev, struct gpio_callback *callback); /** - * @brief Remove npm1300 event callback + * @brief Remove npm13xx event callback * - * @param dev npm1300 mfd device + * @param dev npm13xx mfd device * @param callback callback * @return 0 on success, -errno on failure */ -int mfd_npm1300_remove_callback(const struct device *dev, struct gpio_callback *callback); +int mfd_npm13xx_remove_callback(const struct device *dev, struct gpio_callback *callback); /** @} */ @@ -163,4 +163,4 @@ int mfd_npm1300_remove_callback(const struct device *dev, struct gpio_callback * } #endif -#endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_NPM1300_H_ */ +#endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_NPM13XX_H_ */ diff --git a/include/zephyr/drivers/sensor/npm1300_charger.h b/include/zephyr/drivers/sensor/npm1300_charger.h deleted file mode 100644 index d2a166340d15..000000000000 --- a/include/zephyr/drivers/sensor/npm1300_charger.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_NPM1300_CHARGER_H_ -#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_NPM1300_CHARGER_H_ - -#include - -/* NPM1300 charger specific channels */ -enum sensor_channel_npm1300_charger { - SENSOR_CHAN_NPM1300_CHARGER_STATUS = SENSOR_CHAN_PRIV_START, - SENSOR_CHAN_NPM1300_CHARGER_ERROR, - SENSOR_CHAN_NPM1300_CHARGER_VBUS_STATUS, -}; - -/* NPM1300 charger specific attributes */ -enum sensor_attribute_npm1300_charger { - SENSOR_ATTR_NPM1300_CHARGER_VBUS_PRESENT = SENSOR_ATTR_PRIV_START, - SENSOR_ATTR_NPM1300_CHARGER_VBUS_CUR_LIMIT, - SENSOR_ATTR_NPM1300_CHARGER_VBUS_OVERVLT_PROT, - SENSOR_ATTR_NPM1300_CHARGER_VBUS_UNDERVLT, - SENSOR_ATTR_NPM1300_CHARGER_VBUS_SUSPENDED, - SENSOR_ATTR_NPM1300_CHARGER_VBUS_BUSOUT, -}; - -#endif diff --git a/include/zephyr/drivers/sensor/npm13xx_charger.h b/include/zephyr/drivers/sensor/npm13xx_charger.h new file mode 100644 index 000000000000..b3319096dd19 --- /dev/null +++ b/include/zephyr/drivers/sensor/npm13xx_charger.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_NPM13XX_CHARGER_H_ +#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_NPM13XX_CHARGER_H_ + +#include + +/* NPM13XX charger specific channels */ +enum sensor_channel_npm13xx_charger { + SENSOR_CHAN_NPM13XX_CHARGER_STATUS = SENSOR_CHAN_PRIV_START, + SENSOR_CHAN_NPM13XX_CHARGER_ERROR, + SENSOR_CHAN_NPM13XX_CHARGER_VBUS_STATUS, +}; + +/* NPM13XX charger specific attributes */ +enum sensor_attribute_npm13xx_charger { + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_PRESENT = SENSOR_ATTR_PRIV_START, + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_CUR_LIMIT, + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_OVERVLT_PROT, + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_UNDERVLT, + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_SUSPENDED, + SENSOR_ATTR_NPM13XX_CHARGER_VBUS_BUSOUT, +}; + +#endif diff --git a/include/zephyr/drivers/spi.h b/include/zephyr/drivers/spi.h index 8e8cdb5a9941..08a3f03137bc 100644 --- a/include/zephyr/drivers/spi.h +++ b/include/zephyr/drivers/spi.h @@ -657,16 +657,16 @@ struct spi_device_state { } /** @endcond */ -#define SPI_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \ - data_ptr, cfg_ptr, level, prio, \ - api_ptr, ...) \ +#define SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, \ + pm_device, data_ptr, cfg_ptr, \ + level, prio, api_ptr, ...) \ Z_SPI_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \ Z_SPI_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \ Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \ DEVICE_DT_NAME(node_id), \ &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \ - NULL, Z_DEVICE_DT_FLAGS(node_id), pm_device, \ - data_ptr, cfg_ptr, level, prio, \ + deinit_fn, Z_DEVICE_DT_FLAGS(node_id), \ + pm_device, data_ptr, cfg_ptr, level, prio, \ api_ptr, \ &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \ __VA_ARGS__) @@ -700,8 +700,9 @@ static inline void spi_transceive_stats(const struct device *dev, int error, * @name SPI DT Device Macros * @{ */ + /** - * @brief Like DEVICE_DT_DEFINE() with SPI specifics. + * @brief Like DEVICE_DT_DEINIT_DEFINE() with SPI specifics. * * @details Defines a device which implements the SPI API. May * generate a custom device_state container struct and init_fn @@ -709,6 +710,7 @@ static inline void spi_transceive_stats(const struct device *dev, int error, * * @param node_id The devicetree node identifier. * @param init_fn Name of the init function of the driver. + * @param deinit_fn Name of the deinit function of the driver. * @param pm PM device resources reference (NULL if device does not use PM). * @param data Pointer to the device's private data. * @param config The address to the structure containing the configuration @@ -719,16 +721,16 @@ static inline void spi_transceive_stats(const struct device *dev, int error, * @param api Provides an initial pointer to the API function struct used by * the driver. Can be NULL. */ -#define SPI_DEVICE_DT_DEFINE(node_id, init_fn, pm, \ - data, config, level, prio, \ - api, ...) \ +#define SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, data, \ + config, level, prio, api, ...) \ Z_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \ Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \ - DEVICE_DT_NAME(node_id), init_fn, NULL, \ + DEVICE_DT_NAME(node_id), init_fn, deinit_fn, \ Z_DEVICE_DT_FLAGS(node_id), pm, data, config, \ level, prio, api, \ &Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)), \ __VA_ARGS__) + /** @} */ #define SPI_STATS_RX_BYTES_INC(dev_) @@ -739,6 +741,40 @@ static inline void spi_transceive_stats(const struct device *dev, int error, #endif /*CONFIG_SPI_STATS*/ +/** + * @brief Like DEVICE_DT_DEINIT_DEFINE() without deinit function. + * + * @details Defines a device which implements the SPI API. May + * generate a custom device_state container struct and init_fn + * wrapper when needed depending on SPI @kconfig{CONFIG_SPI_STATS}. + * + * @param node_id The devicetree node identifier. + * @param init_fn Name of the init function of the driver. + * @param pm PM device resources reference (NULL if device does not use PM). + * @param data Pointer to the device's private data. + * @param config The address to the structure containing the configuration + * information for this instance of the driver. + * @param level The initialization level. See SYS_INIT() for details. + * @param prio Priority within the selected initialization level. See SYS_INIT() + * for details. + * @param api Provides an initial pointer to the API function struct used by + * the driver. Can be NULL. + */ +#define SPI_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, prio, \ + api, ...) \ + SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, config, \ + level, prio, api, __VA_ARGS__) + +/** + * @brief Like SPI_DEVICE_DT_DEINIT_DEFINE(), but uses an instance of a `DT_DRV_COMPAT` + * compatible instead of a node identifier. + * + * @param inst Instance number. The `node_id` argument to SPI_DEVICE_DT_DEINIT_DEFINE() is + * set to `DT_DRV_INST(inst)`. + * @param ... Other parameters as expected by SPI_DEVICE_DT_DEFINE(). + */ +#define SPI_DEVICE_DT_INST_DEINIT_DEFINE(inst, ...) \ + SPI_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) /** * @brief Like SPI_DEVICE_DT_DEFINE(), but uses an instance of a `DT_DRV_COMPAT` diff --git a/include/zephyr/drivers/timer/nrf_grtc_timer.h b/include/zephyr/drivers/timer/nrf_grtc_timer.h index f8b69d7ddf02..5a51df217442 100644 --- a/include/zephyr/drivers/timer/nrf_grtc_timer.h +++ b/include/zephyr/drivers/timer/nrf_grtc_timer.h @@ -189,6 +189,17 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time); */ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us); +/** @brief Get the GRTC counter value latched at startup. + * + * @note The GRTC timer is not cleared by software at startup, + * while the system tick starts counting from zero. + * In some cases, it may be necessary to compare the system tick + * with the GRTC value — in such situations, this offset can be useful. + * + * @return GRTC value latched during system clock initialization. + */ +uint64_t z_nrf_grtc_timer_startup_value_get(void); + /** * @brief Initialize the GRTC clock timer driver from an application- * defined function. diff --git a/include/zephyr/dt-bindings/clock/bflb_bl60x_clock.h b/include/zephyr/dt-bindings/clock/bflb_bl60x_clock.h new file mode 100644 index 000000000000..a08db84b082d --- /dev/null +++ b/include/zephyr/dt-bindings/clock/bflb_bl60x_clock.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_BL60X_CLOCK_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_BL60X_CLOCK_H_ + +#include "bflb_clock_common.h" + +#define BL60X_CLKID_CLK_ROOT BFLB_CLKID_CLK_ROOT +#define BL60X_CLKID_CLK_RC32M BFLB_CLKID_CLK_RC32M +#define BL60X_CLKID_CLK_CRYSTAL BFLB_CLKID_CLK_CRYSTAL +#define BL60X_CLKID_CLK_BCLK BFLB_CLKID_CLK_BCLK +#define BL60X_CLKID_CLK_PLL 4 + +#define BL60X_PLL_48MHz 0 +#define BL60X_PLL_120MHz 1 +#define BL60X_PLL_160MHz 2 +#define BL60X_PLL_192MHz 3 + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_BL60X_CLOCK_H_ */ diff --git a/include/zephyr/dt-bindings/clock/bflb_clock_common.h b/include/zephyr/dt-bindings/clock/bflb_clock_common.h new file mode 100644 index 000000000000..203bac3d434a --- /dev/null +++ b/include/zephyr/dt-bindings/clock/bflb_clock_common.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 MASSDRIVER EI (massdriver.space) + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_CLOCK_COMMON_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_CLOCK_COMMON_H_ + +#define BFLB_CLKID_CLK_ROOT 0 +#define BFLB_CLKID_CLK_RC32M 1 +#define BFLB_CLKID_CLK_CRYSTAL 2 +#define BFLB_CLKID_CLK_BCLK 3 + +#define BFLB_FORCE_ROOT_RC32M 10 +#define BFLB_FORCE_ROOT_CRYSTAL 11 +#define BFLB_FORCE_ROOT_PLL 12 + +#define BFLB_RC32M_FREQUENCY 32000000 + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_BFLB_CLOCK_COMMON_H_ */ diff --git a/include/zephyr/dt-bindings/clock/nrf-auxpll.h b/include/zephyr/dt-bindings/clock/nrf-auxpll.h new file mode 100644 index 000000000000..a07c96997597 --- /dev/null +++ b/include/zephyr/dt-bindings/clock/nrf-auxpll.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + + +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NRF_AUXPLL_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NRF_AUXPLL_H_ + +#define NRF_AUXPLL_FREQ_DIV_MIN 0 +#define NRF_AUXPLL_FREQ_DIV_AUDIO_44K1 15309 +#define NRF_AUXPLL_FREQ_DIV_USB24M 32768 +#define NRF_AUXPLL_FREQ_DIV_AUDIO_48K 39845 +#define NRF_AUXPLL_FREQ_DIV_MAX 65535 + +#endif /* #define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NRF_AUXPLL_H_ */ diff --git a/include/zephyr/dt-bindings/gpio/nordic-npm1300-gpio.h b/include/zephyr/dt-bindings/gpio/nordic-npm1300-gpio.h deleted file mode 100644 index fed166e651a2..000000000000 --- a/include/zephyr/dt-bindings/gpio/nordic-npm1300-gpio.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM1300_GPIO_H_ -#define ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM1300_GPIO_H_ - -/** - * @brief nPM1300-specific GPIO Flags - * @defgroup gpio_interface_npm1300 nPM1300-specific GPIO Flags - * - * The drive flags are encoded in the 8 upper bits of @ref gpio_dt_flags_t as - * follows: - * - * - Bit 8: Drive strength (0=1mA, 1=6mA) - * - Bit 9: Debounce (0=OFF, 1=ON) - * - Bit 10: Watchdog reset (0=OFF, 1=ON) - * - Bit 11: Power loss warning (0=OFF, 1=ON) - * - * @ingroup gpio_interface - * @{ - */ - -/** - * @name nPM1300 GPIO drive strength flags - * @brief nPM1300 GPIO drive strength flags - * @{ - */ - -/** @cond INTERNAL_HIDDEN */ -/** Drive mode field mask */ -#define NPM1300_GPIO_DRIVE_MSK 0x0100U -/** @endcond */ - -/** 1mA drive */ -#define NPM1300_GPIO_DRIVE_1MA (0U << 8U) -/** 6mA drive */ -#define NPM1300_GPIO_DRIVE_6MA (1U << 8U) - -/** @} */ - -/** - * @name nPM1300 GPIO debounce flags - * @brief nPM1300 GPIO debounce flags - * @{ - */ - -/** @cond INTERNAL_HIDDEN */ -/** Debounce field mask */ -#define NPM1300_GPIO_DEBOUNCE_MSK 0x0200U -/** @endcond */ - -/** Normal drive */ -#define NPM1300_GPIO_DEBOUNCE_OFF (0U << 9U) -/** High drive */ -#define NPM1300_GPIO_DEBOUNCE_ON (1U << 9U) - -/** @} */ - -/** - * @name nPM1300 GPIO watchdog reset flags - * @brief nPM1300 GPIO watchdog reset flags - * @{ - */ - -/** @cond INTERNAL_HIDDEN */ -/** watchdog reset field mask */ -#define NPM1300_GPIO_WDT_RESET_MSK 0x0400U -/** @endcond */ - -/** Off */ -#define NPM1300_GPIO_WDT_RESET_OFF (0U << 10U) -/** On */ -#define NPM1300_GPIO_WDT_RESET_ON (1U << 10U) - -/** @} */ - -/** - * @name nPM1300 GPIO power loss warning flags - * @brief nPM1300 GPIO power loss warning flags - * @{ - */ - -/** @cond INTERNAL_HIDDEN */ -/** power loss warning field mask */ -#define NPM1300_GPIO_PWRLOSSWARN_MSK 0x0800U -/** @endcond */ - -/** Off */ -#define NPM1300_GPIO_PWRLOSSWARN_OFF (0U << 11U) -/** On */ -#define NPM1300_GPIO_PWRLOSSWARN_ON (1U << 11U) - -/** @} */ - -/** @} */ - -#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM1300_GPIO_H_ */ diff --git a/include/zephyr/dt-bindings/gpio/nordic-npm13xx-gpio.h b/include/zephyr/dt-bindings/gpio/nordic-npm13xx-gpio.h new file mode 100644 index 000000000000..41097b741b26 --- /dev/null +++ b/include/zephyr/dt-bindings/gpio/nordic-npm13xx-gpio.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM13XX_GPIO_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM13XX_GPIO_H_ + +/** + * @brief nPM13xx-specific GPIO Flags + * @defgroup gpio_interface_npm13xx nPM13xx-specific GPIO Flags + * + * The drive flags are encoded in the 8 upper bits of @ref gpio_dt_flags_t as + * follows: + * + * - Bit 8: Drive strength (0=1mA, 1=6mA) + * - Bit 9: Debounce (0=OFF, 1=ON) + * - Bit 10: Watchdog reset (0=OFF, 1=ON) + * - Bit 11: Power loss warning (0=OFF, 1=ON) + * + * @ingroup gpio_interface + * @{ + */ + +/** + * @name nPM13xx GPIO drive strength flags + * @brief nPM13xx GPIO drive strength flags + * @{ + */ + +/** @cond INTERNAL_HIDDEN */ +/** Drive mode field mask */ +#define NPM13XX_GPIO_DRIVE_MSK 0x0100U +/** @endcond */ + +/** 1mA drive */ +#define NPM13XX_GPIO_DRIVE_1MA (0U << 8U) +/** 6mA drive */ +#define NPM13XX_GPIO_DRIVE_6MA (1U << 8U) + +/** @} */ + +/** + * @name nPM13xx GPIO debounce flags + * @brief nPM13xx GPIO debounce flags + * @{ + */ + +/** @cond INTERNAL_HIDDEN */ +/** Debounce field mask */ +#define NPM13XX_GPIO_DEBOUNCE_MSK 0x0200U +/** @endcond */ + +/** Normal drive */ +#define NPM13XX_GPIO_DEBOUNCE_OFF (0U << 9U) +/** High drive */ +#define NPM13XX_GPIO_DEBOUNCE_ON (1U << 9U) + +/** @} */ + +/** + * @name nPM13xx GPIO watchdog reset flags + * @brief nPM13xx GPIO watchdog reset flags + * @{ + */ + +/** @cond INTERNAL_HIDDEN */ +/** watchdog reset field mask */ +#define NPM13XX_GPIO_WDT_RESET_MSK 0x0400U +/** @endcond */ + +/** Off */ +#define NPM13XX_GPIO_WDT_RESET_OFF (0U << 10U) +/** On */ +#define NPM13XX_GPIO_WDT_RESET_ON (1U << 10U) + +/** @} */ + +/** + * @name nPM13xx GPIO power loss warning flags + * @brief nPM13xx GPIO power loss warning flags + * @{ + */ + +/** @cond INTERNAL_HIDDEN */ +/** power loss warning field mask */ +#define NPM13XX_GPIO_PWRLOSSWARN_MSK 0x0800U +/** @endcond */ + +/** Off */ +#define NPM13XX_GPIO_PWRLOSSWARN_OFF (0U << 11U) +/** On */ +#define NPM13XX_GPIO_PWRLOSSWARN_ON (1U << 11U) + +/** @} */ + +/** @} */ + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_NORDIC_NPM13XX_GPIO_H_ */ diff --git a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h index 9de74061e8da..088cfce648bb 100644 --- a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h @@ -172,6 +172,62 @@ #define NRF_FUN_GRTC_CLKOUT_FAST 55U /** GRTC slow clock output */ #define NRF_FUN_GRTC_CLKOUT_32K 56U +/** SDP_MSPI clock pin */ +#define NRF_FUN_SDP_MSPI_SCK 57U +/** SDP_MSPI data pin 0 */ +#define NRF_FUN_SDP_MSPI_DQ0 58U +/** SDP_MSPI data pin 1 */ +#define NRF_FUN_SDP_MSPI_DQ1 59U +/** SDP_MSPI data pin 2 */ +#define NRF_FUN_SDP_MSPI_DQ2 60U +/** SDP_MSPI data pin 3 */ +#define NRF_FUN_SDP_MSPI_DQ3 61U +/** SDP_MSPI data pin 4 */ +#define NRF_FUN_SDP_MSPI_DQ4 62U +/** SDP_MSPI data pin 5 */ +#define NRF_FUN_SDP_MSPI_DQ5 63U +/** SDP_MSPI data pin 6 */ +#define NRF_FUN_SDP_MSPI_DQ6 64U +/** SDP_MSPI data pin 7 */ +#define NRF_FUN_SDP_MSPI_DQ7 65U +/** SDP_MSPI chip select 0 */ +#define NRF_FUN_SDP_MSPI_CS0 66U +/** SDP_MSPI chip select 1 */ +#define NRF_FUN_SDP_MSPI_CS1 67U +/** SDP_MSPI chip select 2 */ +#define NRF_FUN_SDP_MSPI_CS2 68U +/** SDP_MSPI chip select 3 */ +#define NRF_FUN_SDP_MSPI_CS3 69U +/** SDP_MSPI chip select 4 */ +#define NRF_FUN_SDP_MSPI_CS4 70U +/** High-Performance Framework MSPI clock pin */ +#define NRF_FUN_HPF_MSPI_SCK NRF_FUN_SDP_MSPI_SCK +/** High-Performance Framework MSPI data pin 0 */ +#define NRF_FUN_HPF_MSPI_DQ0 NRF_FUN_SDP_MSPI_DQ0 +/** High-Performance Framework MSPI data pin 1 */ +#define NRF_FUN_HPF_MSPI_DQ1 NRF_FUN_SDP_MSPI_DQ1 +/** High-Performance Framework MSPI data pin 2 */ +#define NRF_FUN_HPF_MSPI_DQ2 NRF_FUN_SDP_MSPI_DQ2 +/** High-Performance Framework MSPI data pin 3 */ +#define NRF_FUN_HPF_MSPI_DQ3 NRF_FUN_SDP_MSPI_DQ3 +/** High-Performance Framework MSPI data pin 4 */ +#define NRF_FUN_HPF_MSPI_DQ4 NRF_FUN_SDP_MSPI_DQ4 +/** High-Performance Framework MSPI data pin 5 */ +#define NRF_FUN_HPF_MSPI_DQ5 NRF_FUN_SDP_MSPI_DQ5 +/** High-Performance Framework MSPI data pin 6 */ +#define NRF_FUN_HPF_MSPI_DQ6 NRF_FUN_SDP_MSPI_DQ6 +/** High-Performance Framework MSPI data pin 7 */ +#define NRF_FUN_HPF_MSPI_DQ7 NRF_FUN_SDP_MSPI_DQ7 +/** High-Performance Framework MSPI chip select pin 0 */ +#define NRF_FUN_HPF_MSPI_CS0 NRF_FUN_SDP_MSPI_CS0 +/** High-Performance Framework MSPI chip select pin 1 */ +#define NRF_FUN_HPF_MSPI_CS1 NRF_FUN_SDP_MSPI_CS1 +/** High-Performance Framework MSPI chip select pin 2 */ +#define NRF_FUN_HPF_MSPI_CS2 NRF_FUN_SDP_MSPI_CS2 +/** High-Performance Framework MSPI chip select pin 3 */ +#define NRF_FUN_HPF_MSPI_CS3 NRF_FUN_SDP_MSPI_CS3 +/** High-Performance Framework MSPI chip select pin 4 */ +#define NRF_FUN_HPF_MSPI_CS4 NRF_FUN_SDP_MSPI_CS4 /** TDM SCK in master mode */ #define NRF_FUN_TDM_SCK_M 71U /** TDM SCK in slave mode */ diff --git a/include/zephyr/dt-bindings/regulator/npm1300.h b/include/zephyr/dt-bindings/regulator/npm1300.h deleted file mode 100644 index bf3f8cfa3ee9..000000000000 --- a/include/zephyr/dt-bindings/regulator/npm1300.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM1300_H_ -#define ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM1300_H_ - -/** - * @defgroup regulator_npm1300 NPM1300 Devicetree helpers. - * @ingroup regulator_interface - * @{ - */ - -/** - * @name NPM1300 Regulator modes - * @{ - */ -/* Buck modes */ -#define NPM1300_BUCK_MODE_AUTO 0x00U -#define NPM1300_BUCK_MODE_PWM 0x01U -#define NPM1300_BUCK_MODE_PFM 0x04U - -/* LDSW / LDO modes */ -#define NPM1300_LDSW_MODE_LDO 0x02U -#define NPM1300_LDSW_MODE_LDSW 0x03U - -/* GPIO control configuration */ -#define NPM1300_GPIO_CHAN_NONE 0x00U -#define NPM1300_GPIO_CHAN_0 0x01U -#define NPM1300_GPIO_CHAN_1 0x02U -#define NPM1300_GPIO_CHAN_2 0x03U -#define NPM1300_GPIO_CHAN_3 0x04U -#define NPM1300_GPIO_CHAN_4 0x05U - -/** @} */ - -/** @} */ - -#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM1300_H_*/ diff --git a/include/zephyr/dt-bindings/regulator/npm13xx.h b/include/zephyr/dt-bindings/regulator/npm13xx.h new file mode 100644 index 000000000000..19890261b8a8 --- /dev/null +++ b/include/zephyr/dt-bindings/regulator/npm13xx.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM13XX_H_ +#define ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM13XX_H_ + +/** + * @defgroup regulator_npm13xx nPM13xx Devicetree helpers. + * @ingroup regulator_interface + * @{ + */ + +/** + * @name nPM13xx Regulator modes + * @{ + */ +/* Buck modes */ +#define NPM13XX_BUCK_MODE_AUTO 0x00U +#define NPM13XX_BUCK_MODE_PWM 0x01U +#define NPM13XX_BUCK_MODE_PFM 0x04U + +/* LDSW / LDO modes */ +#define NPM13XX_LDSW_MODE_LDO 0x02U +#define NPM13XX_LDSW_MODE_LDSW 0x03U + +/* GPIO control configuration */ +#define NPM13XX_GPIO_CHAN_NONE 0x00U +#define NPM13XX_GPIO_CHAN_0 0x01U +#define NPM13XX_GPIO_CHAN_1 0x02U +#define NPM13XX_GPIO_CHAN_2 0x03U +#define NPM13XX_GPIO_CHAN_3 0x04U +#define NPM13XX_GPIO_CHAN_4 0x05U + +/** @} */ + +/** @} */ + +#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_REGULATOR_NPM13XX_H_*/ diff --git a/include/zephyr/net/mqtt.h b/include/zephyr/net/mqtt.h index d5dce240230a..797f8f339d7f 100644 --- a/include/zephyr/net/mqtt.h +++ b/include/zephyr/net/mqtt.h @@ -763,6 +763,9 @@ struct mqtt_sec_config { uint32_t alpn_protocol_name_count; #endif + /** Indicates the preference for enabling TLS session caching. */ + int session_cache; + /** Peer hostname for ceritificate verification. * May be NULL to skip hostname verification. */ @@ -770,6 +773,9 @@ struct mqtt_sec_config { /** Indicates the preference for copying certificates to the heap. */ int cert_nocopy; + + /** Set socket to native TLS */ + bool set_native_tls; }; /** @brief MQTT transport type. */ @@ -809,6 +815,11 @@ struct mqtt_transport { */ enum mqtt_transport_type type; + /** Name of the interface that the MQTT client instance should be bound to. + * Leave as NULL if not specified. + */ + const char *if_name; + /** Use either unsecured TCP or secured TLS transport */ union { /** TCP socket transport for MQTT */ diff --git a/include/zephyr/net/net_stats.h b/include/zephyr/net/net_stats.h index 1a5531a1a271..de95b35fbb72 100644 --- a/include/zephyr/net/net_stats.h +++ b/include/zephyr/net/net_stats.h @@ -49,9 +49,9 @@ typedef uint32_t net_stats_t; */ struct net_stats_bytes { /** Number of bytes sent */ - net_stats_t sent; + uint64_t sent; /** Number of bytes received */ - net_stats_t received; + uint64_t received; }; /** @@ -319,6 +319,8 @@ struct net_stats_rx_time { struct net_stats_tc { /** TX statistics for each traffic class */ struct { + /** Number of bytes sent for this traffic class */ + uint64_t bytes; /** Helper for calculating average TX time statistics */ struct net_stats_tx_time tx_time; #if defined(CONFIG_NET_PKT_TXTIME_STATS_DETAIL) @@ -330,14 +332,14 @@ struct net_stats_tc { net_stats_t pkts; /** Number of packets dropped for this traffic class */ net_stats_t dropped; - /** Number of bytes sent for this traffic class */ - net_stats_t bytes; /** Priority of this traffic class */ uint8_t priority; } sent[NET_TC_TX_STATS_COUNT]; /** RX statistics for each traffic class */ struct { + /** Number of bytes received for this traffic class */ + uint64_t bytes; /** Helper for calculating average RX time statistics */ struct net_stats_rx_time rx_time; #if defined(CONFIG_NET_PKT_RXTIME_STATS_DETAIL) @@ -349,8 +351,6 @@ struct net_stats_tc { net_stats_t pkts; /** Number of packets dropped for this traffic class */ net_stats_t dropped; - /** Number of bytes received for this traffic class */ - net_stats_t bytes; /** Priority of this traffic class */ uint8_t priority; } recv[NET_TC_RX_STATS_COUNT]; @@ -404,15 +404,15 @@ struct net_stats_pkt_filter { * @brief All network statistics in one struct. */ struct net_stats { - /** Count of malformed packets or packets we do not have handler for */ - net_stats_t processing_error; - /** * This calculates amount of data transferred through all the * network interfaces. */ struct net_stats_bytes bytes; + /** Count of malformed packets or packets we do not have handler for */ + net_stats_t processing_error; + /** IP layer errors */ struct net_stats_ip_errors ip_errors; diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index ae398bb61177..4a0823bc069f 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef __cplusplus diff --git a/include/zephyr/net/socket_ncs.h b/include/zephyr/net/socket_ncs.h new file mode 100644 index 000000000000..92a8447c47fb --- /dev/null +++ b/include/zephyr/net/socket_ncs.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ +#define ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ + +/** + * @file + * @brief NCS specific additions to the BSD sockets API definitions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* When CONFIG_NET_SOCKETS_OFFLOAD is enabled, offloaded sockets take precedence + * when creating a new socket. Combine this flag with a socket type when + * creating a socket, to enforce native socket creation (e. g. SOCK_STREAM | SOCK_NATIVE). + * If it's desired to create a native TLS socket, but still offload the + * underlying TCP/UDP socket, use e. g. SOCK_STREAM | SOCK_NATIVE_TLS. + */ +#define SOCK_NATIVE 0x80000000 +#define SOCK_NATIVE_TLS 0x40000000 + +/** Define a base for NCS specific socket options to prevent overlaps with Zephyr's socket options. + */ +#define NET_SOCKET_NCS_BASE 1000 + +/* NCS specific TLS level socket options */ + +/** Socket option to set DTLS handshake timeout, specifically for nRF sockets. + * The option accepts an integer, indicating the total handshake timeout, + * including retransmissions, in seconds. + * Accepted values for the option are: 1, 3, 7, 15, 31, 63, 123. + */ +#define TLS_DTLS_HANDSHAKE_TIMEO (NET_SOCKET_NCS_BASE + 18) + +/** Socket option to save DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_SAVE (NET_SOCKET_NCS_BASE + 19) + +/** Socket option to load DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_LOAD (NET_SOCKET_NCS_BASE + 20) + +/** Socket option to get result of latest TLS/DTLS completed handshakes end status, + * specifically for nRF sockets. + * The option accepts an integer, indicating the setting. + * Accepted vaules for the option are: 0 and 1. + */ +#define TLS_DTLS_HANDSHAKE_STATUS (NET_SOCKET_NCS_BASE + 21) + +/* Valid values for TLS_DTLS_HANDSHAKE_TIMEO option */ +#define TLS_DTLS_HANDSHAKE_TIMEO_NONE 0 /**< No timeout */ +#define TLS_DTLS_HANDSHAKE_TIMEO_1S 1 /**< 1 second */ +#define TLS_DTLS_HANDSHAKE_TIMEO_3S 3 /**< 1s + 2s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_7S 7 /**< 1s + 2s + 4s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_15S 15 /**< 1s + 2s + 4s + 8s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_31S 31 /**< 1s + 2s + 4s + 8s + 16s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_63S 63 /**< 1s + 2s + 4s + 8s + 16s + 32s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_123S 123 /**< 1s + 2s + 4s + 8s + 16s + 32s + 60s */ + +/* Valid values for TLS_DTLS_HANDSHAKE_STATUS option */ +#define TLS_DTLS_HANDSHAKE_STATUS_FULL 0 +#define TLS_DTLS_HANDSHAKE_STATUS_CACHED 1 + +/* NCS specific socket options */ + +/** sockopt: enable sending data as part of exceptional events */ +#define SO_EXCEPTIONAL_DATA (NET_SOCKET_NCS_BASE + 33) +/** sockopt: Keep socket open when its PDN connection is lost + * or the device is put into flight mode. + */ +#define SO_KEEPOPEN (NET_SOCKET_NCS_BASE + 34) +/** sockopt: bind to PDN */ +#define SO_BINDTOPDN (NET_SOCKET_NCS_BASE + 40) + +/** sockopt: Release assistance indication (RAI). + * The option accepts an integer, indicating the type of RAI. + * Accepted values for the option are: @ref RAI_NO_DATA, @ref RAI_LAST, @ref RAI_ONE_RESP, + * @ref RAI_ONGOING, @ref RAI_WAIT_MORE. + */ +#define SO_RAI (NET_SOCKET_NCS_BASE + 61) + +/** Release assistance indication (RAI). + * Indicate that the application does not intend to send more data. + * This applies immediately and lets the modem exit connected mode more + * quickly. + * + * @note This requires the socket to be connected. + */ +#define RAI_NO_DATA 1 +/** Release assistance indication (RAI). + * Indicate that the application does not intend to send more data + * after the next call to send() or sendto(). + * This lets the modem exit connected mode more quickly after sending the data. + */ +#define RAI_LAST 2 +/** Release assistance indication (RAI). + * Indicate that the application is expecting to receive just one data packet + * after the next call to send() or sendto(). + * This lets the modem exit connected mode more quickly after having received the data. + */ +#define RAI_ONE_RESP 3 +/** Release assistance indication (RAI). + * Indicate that the socket is in active use by a client application. + * This lets the modem stay in connected mode longer. + */ +#define RAI_ONGOING 4 +/** Release assistance indication (RAI). + * Indicate that the socket is in active use by a server application. + * This lets the modem stay in connected mode longer. + */ +#define RAI_WAIT_MORE 5 + +/* NCS specific IPPROTO_ALL level socket options */ + +/** IPv4 and IPv6 protocol level (pseudo-val) for nRF sockets. */ +#define IPPROTO_ALL 512 +/** sockopt: disable all replies to unexpected traffics */ +#define SO_SILENCE_ALL (NET_SOCKET_NCS_BASE + 30) + +/* NCS specific IPPROTO_IP level socket options */ + +/** sockopt: enable IPv4 ICMP replies */ +#define SO_IP_ECHO_REPLY (NET_SOCKET_NCS_BASE + 31) + +/* NCS specific IPPROTO_IPV6 level socket options */ + +/** sockopt: enable IPv6 ICMP replies */ +#define SO_IPV6_ECHO_REPLY (NET_SOCKET_NCS_BASE + 32) + +/** sockopt: Delay IPv6 address refresh during power saving mode */ +#define SO_IPV6_DELAYED_ADDR_REFRESH (NET_SOCKET_NCS_BASE + 62) + +/* NCS specific TCP level socket options */ + +/** sockopt: Configurable TCP server session timeout in minutes. + * Range is 0 to 135. 0 is no timeout and 135 is 2 h 15 min. Default is 0 (no timeout). + */ +#define SO_TCP_SRV_SESSTIMEO (NET_SOCKET_NCS_BASE + 55) + +/* NCS specific gettaddrinfo() flags */ + +/** Assume `service` contains a Packet Data Network (PDN) ID. + * When specified together with the AI_NUMERICSERV flag, + * `service` shall be formatted as follows: "port:pdn_id" + * where "port" is the port number and "pdn_id" is the PDN ID. + * Example: "8080:1", port 8080 PDN ID 1. + * Example: "42:0", port 42 PDN ID 0. + */ +#define AI_PDNSERV 0x1000 + +/* NCS specific send() and sendto() flags */ + +/** Request a blocking send operation until the request is acknowledged. + * When used in send() or sendto(), the request will not return until the + * send operation is completed by lower layers, or until the timeout, given by the SO_SNDTIMEO + * socket option, is reached. Valid timeout values are 1 to 600 seconds. + */ +#define MSG_WAITACK 0x200 + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ */ diff --git a/include/zephyr/net/socket_offload.h b/include/zephyr/net/socket_offload.h index 988d0fb686b3..ad86de887f3d 100644 --- a/include/zephyr/net/socket_offload.h +++ b/include/zephyr/net/socket_offload.h @@ -41,6 +41,36 @@ struct socket_dns_offload { */ void socket_offload_dns_register(const struct socket_dns_offload *ops); +/** + * @brief Deregister an offloaded socket DNS API interface. + * + * @param ops A pointer to the offloaded socket DNS API interface. + * + * @retval 0 On success + * @retval -EINVAL Offloaded DNS API was not regsitered. + */ +int socket_offload_dns_deregister(const struct socket_dns_offload *ops); + +/** + * @brief Enable/disable DNS offloading at runtime. + * + * @param enable Whether to enable or disable the DNS offloading. + */ +void socket_offload_dns_enable(bool enable); + +/** + * @brief Check if DNS offloading is enabled. + * + * @retval true DNS offloaded API is registered and enabled. + * @retval false DNS offloading is disabled. + */ +#if defined(CONFIG_NET_SOCKETS_OFFLOAD) +bool socket_offload_dns_is_enabled(void); +#else +#define socket_offload_dns_is_enabled() false +#endif /* defined(CONFIG_NET_SOCKETS_OFFLOAD) */ + + /** @cond INTERNAL_HIDDEN */ int socket_offload_getaddrinfo(const char *node, const char *service, diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index d8ba414abd3d..f62f1c217185 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -348,6 +348,10 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); +#if USE_PARTITION_MANAGER +#include +#else + /** * Returns non-0 value if fixed-partition of given DTS node label exists. * @@ -469,6 +473,8 @@ DT_FOREACH_STATUS_OKAY(fixed_partitions, FOR_EACH_PARTITION_TABLE) #undef FOR_EACH_PARTITION_TABLE /** @endcond */ +#endif /* USE_PARTITION_MANAGER */ + #ifdef __cplusplus } #endif diff --git a/include/zephyr/sys_clock.h b/include/zephyr/sys_clock.h index 6c3589a51028..5f31d585ff13 100644 --- a/include/zephyr/sys_clock.h +++ b/include/zephyr/sys_clock.h @@ -162,10 +162,11 @@ typedef struct { /** @endcond */ #ifndef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME -#if defined(CONFIG_SYS_CLOCK_EXISTS) && \ - (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0) +#if defined(CONFIG_SYS_CLOCK_EXISTS) +#if CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0 #error "SYS_CLOCK_HW_CYCLES_PER_SEC must be non-zero!" -#endif +#endif /* CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0 */ +#endif /* CONFIG_SYS_CLOCK_EXISTS */ #endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */ /* kernel clocks */ diff --git a/include/zephyr/toolchain/gcc.h b/include/zephyr/toolchain/gcc.h index 58aa13e0a3ef..4d3d85858d3d 100644 --- a/include/zephyr/toolchain/gcc.h +++ b/include/zephyr/toolchain/gcc.h @@ -334,11 +334,13 @@ do { \ #define __WARN1(s) _Pragma(#s) /* Generic message */ -#ifndef __DEPRECATED_MACRO +#ifndef CONFIG_DEPRECATION_TEST #define __DEPRECATED_MACRO __WARN("Macro is deprecated") /* When adding this, remember to follow the instructions in * https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html#deprecated */ +#else +#define __DEPRECATED_MACRO #endif /* These macros allow having ARM asm functions callable from thumb */ diff --git a/include/zephyr/toolchain/iar/iccarm.h b/include/zephyr/toolchain/iar/iccarm.h index 746554d2e129..e6a3cb96d3b2 100644 --- a/include/zephyr/toolchain/iar/iccarm.h +++ b/include/zephyr/toolchain/iar/iccarm.h @@ -243,10 +243,14 @@ do { \ #define __WARN1(s) __PRAGMA(message = #s) /* Generic message */ -#ifndef __DEPRECATED_MACRO +#ifndef CONFIG_DEPRECATION_TEST #define __DEPRECATED_MACRO __WARN("Macro is deprecated") +#else +#define __DEPRECATED_MACRO #endif + + /* These macros allow having ARM asm functions callable from thumb */ #if defined(_ASMLANGUAGE) diff --git a/kernel/Kconfig b/kernel/Kconfig index 6e7058ffc431..1e9155cf241a 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -457,6 +457,7 @@ config SKIP_BSS_CLEAR config BOOT_BANNER bool "Boot banner" default y + depends on !NCS_BOOT_BANNER select PRINTK select EARLY_CONSOLE help @@ -828,6 +829,7 @@ config SYS_CLOCK_TICKS_PER_SEC config SYS_CLOCK_HW_CYCLES_PER_SEC int "System clock's h/w timer frequency" default 0 if TIMER_READS_ITS_FREQUENCY_AT_RUNTIME + depends on SYS_CLOCK_EXISTS help This option specifies the frequency of the hardware timer used for the system clock (in Hz). This option is set by the SOC's or board's Kconfig file diff --git a/kernel/banner.c b/kernel/banner.c index 5cadda0a5e98..a16784cb975c 100644 --- a/kernel/banner.c +++ b/kernel/banner.c @@ -24,7 +24,7 @@ #endif /* BUILD_VERSION */ #endif /* !BANNER_VERSION */ -void boot_banner(void) +__weak void boot_banner(void) { #if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) #ifdef CONFIG_BOOT_BANNER diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 0d97da3e340b..9a39ab8ad73b 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -81,7 +81,7 @@ config HEAP_LISTENER choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) + default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) && !PARTITION_MANAGER_ENABLED default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 2b01e152f009..2821ae8173ac 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,6 +25,20 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); +#if USE_PARTITION_MANAGER + +#include + +#define RAM_SIZE PM_SRAM_SIZE +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + +#define RAM_SIZE (KB((size_t) CONFIG_SRAM_SIZE)) +#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS + +#endif /* USE_PARTITION_MANAGER */ + #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -106,8 +120,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ - ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((RAM_SIZE - \ + ((size_t) HEAP_BASE - (size_t) RAM_ADDR)), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/lib/libc/minimal/CMakeLists.txt b/lib/libc/minimal/CMakeLists.txt index 10610b855c84..29f2db74367b 100644 --- a/lib/libc/minimal/CMakeLists.txt +++ b/lib/libc/minimal/CMakeLists.txt @@ -12,6 +12,7 @@ set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated) set(STRERROR_TABLE_H ${GEN_DIR}/libc/minimal/strerror_table.h) zephyr_library_compile_options($) +zephyr_library_compile_options($) zephyr_library_sources( source/stdlib/atoi.c diff --git a/lib/os/zvfs/Kconfig b/lib/os/zvfs/Kconfig index 101e2cce0864..b22d2b1f1721 100644 --- a/lib/os/zvfs/Kconfig +++ b/lib/os/zvfs/Kconfig @@ -6,7 +6,6 @@ menuconfig ZVFS bool "Zephyr virtual filesystem (ZVFS) support [EXPERIMENTAL]" select FDTABLE - select EXPERIMENTAL help ZVFS is a central, Zephyr-native library that provides a common interoperable API for all types of file descriptors such as those from the non-virtual FS, sockets, eventfds, FILE *'s diff --git a/modules/Kconfig.mcuboot b/modules/Kconfig.mcuboot index 2c4dbfa930de..694f4069b90f 100644 --- a/modules/Kconfig.mcuboot +++ b/modules/Kconfig.mcuboot @@ -227,6 +227,7 @@ config MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP config MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT bool "MCUboot has been configured for DirectXIP with revert" + select MCUBOOT_BOOTUTIL_LIB select MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP select MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE select MCUBOOT_BOOTLOADER_NO_DOWNGRADE @@ -287,6 +288,11 @@ config MCUBOOT_BOOTLOADER_NO_DOWNGRADE MCUBOOT_DOWNGRADE_PREVENTION option enabled. endif +config MCUBOOT_BOOTLOADER_USES_SHA512 + bool "MCUboot uses SHA512 for image hash" + help + MCUboot has been compiled to verify images using SHA512. + config MCUBOOT_APPLICATION_FIRMWARE_UPDATER bool "Application is firmware updater image" depends on MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER diff --git a/modules/hal_nordic/CMakeLists.txt b/modules/hal_nordic/CMakeLists.txt index 11c28246828b..f4242b2d67bf 100644 --- a/modules/hal_nordic/CMakeLists.txt +++ b/modules/hal_nordic/CMakeLists.txt @@ -13,6 +13,7 @@ if(CONFIG_NRF_REGTOOL_GENERATE_UICR) endif() if(DEFINED nrf_regtool_components) find_package(nrf-regtool 9.1.0 + REQUIRED COMPONENTS ${nrf_regtool_components} PATHS ${CMAKE_CURRENT_LIST_DIR}/nrf-regtool NO_CMAKE_PATH diff --git a/modules/hal_nordic/Kconfig b/modules/hal_nordic/Kconfig index 8053017170e6..665fe2cc95b0 100644 --- a/modules/hal_nordic/Kconfig +++ b/modules/hal_nordic/Kconfig @@ -163,12 +163,12 @@ config NRF_802154_CCA_MODE_CARRIER_OR_ED endchoice -config NRF_802154_CCA_ED_THRESHOLD - int "nRF IEEE 802.15.4 CCA Energy Detection threshold" - default 45 +config NRF_802154_CCA_ED_THRESHOLD_DBM + int "nRF IEEE 802.15.4 CCA Energy Detection threshold in dBm" + default -75 help If energy detected in a given channel is above the value then the - channel is deemed busy. The unit is defined as per 802.15.4-2006 spec. + channel is deemed busy. The unit is dBm. config NRF_802154_CCA_CORR_THRESHOLD int "nRF IEEE 802.15.4 CCA Correlator threshold" diff --git a/modules/hal_nordic/Kconfig.nrf_regtool b/modules/hal_nordic/Kconfig.nrf_regtool index 396ec2050a05..12f7a53f471c 100644 --- a/modules/hal_nordic/Kconfig.nrf_regtool +++ b/modules/hal_nordic/Kconfig.nrf_regtool @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 menu "nrf-regtool options" - depends on SOC_SERIES_NRF54HX || SOC_SERIES_NRF92X + depends on SOC_SERIES_NRF92X config NRF_REGTOOL_GENERATE_UICR bool "Generate UICR" diff --git a/modules/hal_nordic/nrf_802154/CMakeLists.txt b/modules/hal_nordic/nrf_802154/CMakeLists.txt index 1fc5c85ec0b1..957019ff1e67 100644 --- a/modules/hal_nordic/nrf_802154/CMakeLists.txt +++ b/modules/hal_nordic/nrf_802154/CMakeLists.txt @@ -52,7 +52,7 @@ target_compile_definitions(zephyr-802154-interface # CCA mode options NRF_802154_CCA_CORR_LIMIT_DEFAULT=${CONFIG_NRF_802154_CCA_CORR_LIMIT} NRF_802154_CCA_CORR_THRESHOLD_DEFAULT=${CONFIG_NRF_802154_CCA_CORR_THRESHOLD} - NRF_802154_CCA_ED_THRESHOLD_DEFAULT=${CONFIG_NRF_802154_CCA_ED_THRESHOLD} + NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT=${CONFIG_NRF_802154_CCA_ED_THRESHOLD_DBM} # Key storage size NRF_802154_SECURITY_KEY_STORAGE_SIZE=${CONFIG_NRF_802154_SECURITY_KEY_STORAGE_SIZE} diff --git a/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c b/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c index 87aa85261e98..1dcf724b0e52 100644 --- a/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c +++ b/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c @@ -18,7 +18,11 @@ static bool hfclk_is_running; void nrf_802154_clock_init(void) { - /* Intentionally empty. */ +#ifdef NRF54L_SERIES + uint32_t clock_latency_us = z_nrf_clock_bt_ctlr_hf_get_startup_time_us(); + + nrf_802154_clock_hfclk_latency_set(clock_latency_us); +#endif } void nrf_802154_clock_deinit(void) @@ -84,7 +88,8 @@ void nrf_802154_clock_hfclk_stop(void) hfclk_is_running = false; } -#elif defined(CONFIG_CLOCK_CONTROL_NRF2) +#elif DT_NODE_HAS_STATUS(DT_NODELABEL(hfxo), okay) && \ + DT_NODE_HAS_COMPAT(DT_NODELABEL(hfxo), nordic_nrf54h_hfxo) void nrf_802154_clock_hfclk_start(void) { diff --git a/modules/hal_nordic/nrfs/CMakeLists.txt b/modules/hal_nordic/nrfs/CMakeLists.txt index d94c2da32a82..dcc7c340ed3e 100644 --- a/modules/hal_nordic/nrfs/CMakeLists.txt +++ b/modules/hal_nordic/nrfs/CMakeLists.txt @@ -14,12 +14,12 @@ if(CONFIG_NRFS) zephyr_include_directories(${INC_DIR}) zephyr_include_directories(${INC_DIR}/services) - zephyr_include_directories(${HELPERS_DIR}) + zephyr_include_directories_ifdef(CONFIG_NRFS_HAS_DVFS_SERVICE ${HELPERS_DIR}) zephyr_include_directories(.) zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/backends) zephyr_include_directories_ifdef(CONFIG_NRFS_DVFS_LOCAL_DOMAIN ${CMAKE_CURRENT_SOURCE_DIR}/dvfs) - zephyr_library_sources(${HELPERS_DIR}/dvfs_oppoint.c) + zephyr_library_sources_ifdef(CONFIG_NRFS_HAS_DVFS_SERVICE ${HELPERS_DIR}/dvfs_oppoint.c) if(CONFIG_NRFS_LOCAL_DOMAIN) zephyr_library_sources_ifdef(CONFIG_NRFS_AUDIOPLL_SERVICE_ENABLED ${SRC_DIR}/services/nrfs_audiopll.c) diff --git a/modules/hal_nordic/nrfx/CMakeLists.txt b/modules/hal_nordic/nrfx/CMakeLists.txt index d1972356fccf..5d7b4d942b3b 100644 --- a/modules/hal_nordic/nrfx/CMakeLists.txt +++ b/modules/hal_nordic/nrfx/CMakeLists.txt @@ -197,6 +197,7 @@ endif() zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_SKIP_CLOCK_CONFIG NRF_SKIP_CLOCK_CONFIGURATION) zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_DISABLE_FICR_TRIMCNF NRF_DISABLE_FICR_TRIMCNF) zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF54LX_SKIP_GLITCHDETECTOR_DISABLE NRF_SKIP_GLITCHDETECTOR_DISABLE) +zephyr_compile_definitions_ifndef(CONFIG_SOC_NRF54L_ANOMALY_56_WORKAROUND NRF54L_CONFIGURATION_56_ENABLE=0) # Inject code to skip TAMPC setup for nRF54L20 and nRF54L09. It is not supported for now. # It needs to be removed when support is provided. diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index ceccf25997ca..2b2b288cc344 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -562,6 +562,16 @@ config NRFX_SPIM22 depends on $(dt_nodelabel_exists,spi22) select NRFX_SPIM +config NRFX_SPIM23 + bool "SPIM23 driver instance" + depends on $(dt_nodelabel_exists,spi23) + select NRFX_SPIM + +config NRFX_SPIM24 + bool "SPIM24 driver instance" + depends on $(dt_nodelabel_exists,spi24) + select NRFX_SPIM + config NRFX_SPIM30 bool "SPIM30 driver instance" depends on $(dt_nodelabel_exists,spi30) @@ -660,6 +670,16 @@ config NRFX_SPIS22 depends on $(dt_nodelabel_exists,spi22) select NRFX_SPIS +config NRFX_SPIS23 + bool "SPIS23 driver instance" + depends on $(dt_nodelabel_exists,spi23) + select NRFX_SPIS + +config NRFX_SPIS24 + bool "SPIS24 driver instance" + depends on $(dt_nodelabel_exists,spi24) + select NRFX_SPIS + config NRFX_SPIS30 bool "SPIS30 driver instance" depends on $(dt_nodelabel_exists,spi30) @@ -901,6 +921,16 @@ config NRFX_TWIM22 depends on $(dt_nodelabel_exists,i2c22) select NRFX_TWIM +config NRFX_TWIM23 + bool "TWIM23 driver instance" + depends on $(dt_nodelabel_exists,i2c23) + select NRFX_TWIM + +config NRFX_TWIM24 + bool "TWIM24 driver instance" + depends on $(dt_nodelabel_exists,i2c24) + select NRFX_TWIM + config NRFX_TWIM30 bool "TWIM30 driver instance" depends on $(dt_nodelabel_exists,i2c30) @@ -989,6 +1019,16 @@ config NRFX_TWIS22 depends on $(dt_nodelabel_exists,i2c22) select NRFX_TWIS +config NRFX_TWIS23 + bool "TWIS23 driver instance" + depends on $(dt_nodelabel_exists,i2c23) + select NRFX_TWIS + +config NRFX_TWIS24 + bool "TWIS24 driver instance" + depends on $(dt_nodelabel_exists,i2c24) + select NRFX_TWIS + config NRFX_TWIS30 bool "TWIS30 driver instance" depends on $(dt_nodelabel_exists,i2c30) @@ -1085,6 +1125,16 @@ config NRFX_UARTE22 depends on $(dt_nodelabel_exists,uart22) select NRFX_UARTE +config NRFX_UARTE23 + bool "UARTE23 driver instance" + depends on $(dt_nodelabel_exists,uart23) + select NRFX_UARTE + +config NRFX_UARTE24 + bool "UARTE24 driver instance" + depends on $(dt_nodelabel_exists,uart24) + select NRFX_UARTE + config NRFX_UARTE30 bool "UARTE30 driver instance" depends on $(dt_nodelabel_exists,uart30) @@ -1236,6 +1286,6 @@ endmenu config NRFX_RESERVED_RESOURCES_HEADER string - default "nrfx_reserved_resources.h" + default "nrfx_config_reserved_resources_ncs.h" endmenu # "nrfx drivers" diff --git a/modules/hal_nordic/nrfx/nrfx_config_reserved_resources_ncs.h b/modules/hal_nordic/nrfx/nrfx_config_reserved_resources_ncs.h new file mode 100644 index 000000000000..1678b2e4171e --- /dev/null +++ b/modules/hal_nordic/nrfx/nrfx_config_reserved_resources_ncs.h @@ -0,0 +1,948 @@ +/* + * Copyright (c) 2024, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef NRFX_CONFIG_RESERVED_RESOURCES_H__ +#define NRFX_CONFIG_RESERVED_RESOURCES_H__ + +/** @brief Bitmask that defines GPIOTE130 channels reserved for use outside + * of the nrfx library. + */ +#define NRFX_GPIOTE130_CHANNELS_USED \ + (~NRFX_CONFIG_MASK_DT(DT_NODELABEL(gpiote130), owned_channels) | \ + NRFX_CONFIG_MASK_DT(DT_NODELABEL(gpiote130), child_owned_channels)) + +/** @brief Bitmask that defines GPIOTE131 channels reserved for use outside + * of the nrfx library. + */ +#define NRFX_GPIOTE131_CHANNELS_USED \ + (~NRFX_CONFIG_MASK_DT(DT_NODELABEL(gpiote131), owned_channels) | \ + NRFX_CONFIG_MASK_DT(DT_NODELABEL(gpiote131), child_owned_channels)) + +/** @brief Bitmask that defines EGU instances that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_EGUS_USED 0 + +/** @brief Bitmask that defines TIMER instances that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_TIMERS_USED 0 + +/* If the GRTC system timer driver is to be used, prepare definitions required + * by the nrfx_grtc driver (NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK and + * NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS) based on information from devicetree. + */ +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc) +#define NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK \ + (NRFX_CONFIG_MASK_DT(DT_INST(0, nordic_nrf_grtc), owned_channels) & \ + ~NRFX_CONFIG_MASK_DT(DT_INST(0, nordic_nrf_grtc), child_owned_channels)) +#define NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS \ + (DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), owned_channels, 0) - \ + DT_PROP_LEN_OR(DT_INST(0, nordic_nrf_grtc), child_owned_channels, 0)) +#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc) */ + +/* + * The enabled Bluetooth controller subsystem is responsible for providing + * definitions of the BT_CTLR_USED_* symbols used below in a file named + * bt_ctlr_used_resources.h and for adding its location to global include + * paths so that the file can be included here for all Zephyr libraries that + * are to be built. + */ +#if defined(CONFIG_BT_LL_SW_SPLIT) +#include +#if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_CHANNELS +#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_GROUPS +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_CHANNELS +#define NRFX_DPPI0_GROUPS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_GROUPS +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#define NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_CHANNELS +#define NRFX_DPPI10_GROUPS_USED_BY_BT_CTLR BT_CTLR_USED_PPI_GROUPS +#endif +#endif /* defined(CONFIG_BT_LL_SW_SPLIT) */ + +#if defined(CONFIG_BT_LL_SOFTDEVICE) +/* Define auxiliary symbols needed for SDC device dispatch. */ +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRF52_SERIES +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRF53_SERIES +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#define NRF54L_SERIES +#elif defined(CONFIG_SOC_SERIES_NRF71X) +#define NRF71_SERIES +#elif defined(CONFIG_SOC_SERIES_NRF54HX) +#define NRF54H_SERIES +#endif +#include +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR SDC_PPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR SDC_DPPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) || defined(CONFIG_SOC_SERIES_NRF71X) +#define NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC10_CHANNELS_USED_MASK +#define NRFX_DPPI00_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC00_CHANNELS_USED_MASK +#define NRFX_PPIB_00_10_CHANNELS_USED_BY_BT_CTLR \ + (SDC_PPIB00_CHANNELS_USED_MASK | SDC_PPIB10_CHANNELS_USED_MASK) +#elif defined(CONFIG_SOC_SERIES_NRF54HX) +#define NRFX_DPPI020_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC020_CHANNELS_USED_MASK +#define NRFX_DPPI030_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC030_CHANNELS_USED_MASK +#define NRFX_PPIB_020_030_CHANNELS_USED_BY_BT_CTLR \ + (SDC_PPIB020_CHANNELS_USED_MASK | SDC_PPIB030_CHANNELS_USED_MASK) +#else +#error Unsupported chip family +#endif +#endif /* defined(CONFIG_BT_LL_SOFTDEVICE) */ + +#if defined(CONFIG_NRF_802154_RADIO_DRIVER) +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#include <../src/nrf_802154_peripherals_nrf52.h> +#define NRFX_PPI_CHANNELS_USED_BY_802154_DRV NRF_802154_PPI_CHANNELS_USED_MASK +#define NRFX_PPI_GROUPS_USED_BY_802154_DRV NRF_802154_PPI_GROUPS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#include <../src/nrf_802154_peripherals_nrf53.h> +#define NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV NRF_802154_DPPI_CHANNELS_USED_MASK +#define NRFX_DPPI0_GROUPS_USED_BY_802154_DRV NRF_802154_DPPI_GROUPS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) +#include <../src/nrf_802154_peripherals_nrf54l.h> +#define NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV NRF_802154_DPPI_CHANNELS_USED_MASK +#define NRFX_DPPI10_GROUPS_USED_BY_802154_DRV NRF_802154_DPPI_GROUPS_USED_MASK +#elif defined(CONFIG_SOC_SERIES_NRF54HX) +#include <../src/nrf_802154_peripherals_nrf54h.h> +#define NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV NRF_802154_DPPI_CHANNELS_USED_MASK +#define NRFX_DPPI020_GROUPS_USED_BY_802154_DRV NRF_802154_DPPI_GROUPS_USED_MASK +#else +#error Unsupported chip family +#endif +#endif /* CONFIG_NRF_802154_RADIO_DRIVER */ + +#if defined(CONFIG_MPSL) +#include +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRFX_PPI_CHANNELS_USED_BY_MPSL MPSL_PPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRFX_DPPI0_CHANNELS_USED_BY_MPSL MPSL_DPPIC_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) || defined(CONFIG_SOC_SERIES_NRF71X) +#define NRFX_DPPI10_CHANNELS_USED_BY_MPSL MPSL_DPPIC10_CHANNELS_USED_MASK +#define NRFX_DPPI20_CHANNELS_USED_BY_MPSL MPSL_DPPIC20_CHANNELS_USED_MASK +#define NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL \ + (MPSL_PPIB11_CHANNELS_USED_MASK | MPSL_PPIB21_CHANNELS_USED_MASK) +#elif defined(CONFIG_SOC_SERIES_NRF54HX) +#define NRFX_DPPI020_CHANNELS_USED_BY_MPSL MPSL_DPPIC020_CHANNELS_USED_MASK +#else +#error Unsupported chip family +#endif +#endif + +#ifndef NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI0_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI0_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI0_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI0_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI0_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI0_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI0_GROUPS_USED_BY_MPSL +#define NRFX_DPPI0_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI00_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI00_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI00_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI00_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI00_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI00_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI00_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI00_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI00_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI00_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI00_GROUPS_USED_BY_MPSL +#define NRFX_DPPI00_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI10_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI10_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI10_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI10_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI10_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI10_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI10_GROUPS_USED_BY_MPSL +#define NRFX_DPPI10_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI20_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI20_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI20_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI20_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI20_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI20_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI20_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI20_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI20_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI20_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI20_GROUPS_USED_BY_MPSL +#define NRFX_DPPI20_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI30_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI30_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI30_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI30_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI30_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI30_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI30_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI30_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI30_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI30_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI30_GROUPS_USED_BY_MPSL +#define NRFX_DPPI30_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI020_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI020_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI020_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI020_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI020_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI020_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI020_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI020_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI020_GROUPS_USED_BY_MPSL +#define NRFX_DPPI020_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI030_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI030_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI030_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI030_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI030_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI030_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI030_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI030_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI030_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI030_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI030_GROUPS_USED_BY_MPSL +#define NRFX_DPPI030_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI120_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI120_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI120_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI120_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI120_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI120_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI120_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI120_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI120_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI120_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI120_GROUPS_USED_BY_MPSL +#define NRFX_DPPI120_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI130_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI130_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI130_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI130_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI130_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI130_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI130_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI130_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI130_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI130_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI130_GROUPS_USED_BY_MPSL +#define NRFX_DPPI130_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI131_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI131_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI131_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI131_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI131_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI131_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI131_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI131_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI131_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI131_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI131_GROUPS_USED_BY_MPSL +#define NRFX_DPPI131_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI132_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI132_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI132_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI132_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI132_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI132_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI132_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI132_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI132_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI132_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI132_GROUPS_USED_BY_MPSL +#define NRFX_DPPI132_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI133_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI133_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI133_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI133_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI133_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI133_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI133_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI133_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI133_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI133_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI133_GROUPS_USED_BY_MPSL +#define NRFX_DPPI133_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI134_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI134_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI134_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI134_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI134_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI134_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI134_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI134_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI134_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI134_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI134_GROUPS_USED_BY_MPSL +#define NRFX_DPPI134_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI135_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI135_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI135_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI135_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI135_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI135_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI135_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI135_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI135_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI135_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI135_GROUPS_USED_BY_MPSL +#define NRFX_DPPI135_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_DPPI136_CHANNELS_USED_BY_BT_CTLR +#define NRFX_DPPI136_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI136_GROUPS_USED_BY_BT_CTLR +#define NRFX_DPPI136_GROUPS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_DPPI136_CHANNELS_USED_BY_802154_DRV +#define NRFX_DPPI136_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI136_GROUPS_USED_BY_802154_DRV +#define NRFX_DPPI136_GROUPS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_DPPI136_CHANNELS_USED_BY_MPSL +#define NRFX_DPPI136_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_DPPI136_GROUPS_USED_BY_MPSL +#define NRFX_DPPI136_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPI_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPI_GROUPS_USED_BY_BT_CTLR +#define NRFX_PPI_GROUPS_USED_BY_BT_CTLR 0 +#endif + +#ifndef NRFX_PPI_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPI_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPI_GROUPS_USED_BY_802154_DRV +#define NRFX_PPI_GROUPS_USED_BY_802154_DRV 0 +#endif + +#ifndef NRFX_PPI_CHANNELS_USED_BY_MPSL +#define NRFX_PPI_CHANNELS_USED_BY_MPSL 0 +#endif +#ifndef NRFX_PPI_GROUPS_USED_BY_MPSL +#define NRFX_PPI_GROUPS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_00_10_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_00_10_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_00_10_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_00_10_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_00_10_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_00_10_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_01_20_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_01_20_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_01_20_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_01_20_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_01_20_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_01_20_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_11_21_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_11_21_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_11_21_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_11_21_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_22_30_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_22_30_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_22_30_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_22_30_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_22_30_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_22_30_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_02_03_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_02_03_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_02_03_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_02_03_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_02_03_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_02_03_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_04_12_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_04_12_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_04_12_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_04_12_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_04_12_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_04_12_CHANNELS_USED_BY_MPSL 0 +#endif + +#ifndef NRFX_PPIB_020_030_CHANNELS_USED_BY_BT_CTLR +#define NRFX_PPIB_020_030_CHANNELS_USED_BY_BT_CTLR 0 +#endif +#ifndef NRFX_PPIB_020_030_CHANNELS_USED_BY_802154_DRV +#define NRFX_PPIB_020_030_CHANNELS_USED_BY_802154_DRV 0 +#endif +#ifndef NRFX_PPIB_020_030_CHANNELS_USED_BY_MPSL +#define NRFX_PPIB_020_030_CHANNELS_USED_BY_MPSL 0 +#endif + +#if defined(NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL) + +BUILD_ASSERT((NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI0_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI0_GROUPS_USED_BY_802154_DRV & NRFX_DPPI0_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI00_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI00_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI00_GROUPS_USED_BY_802154_DRV & NRFX_DPPI00_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI10_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI10_GROUPS_USED_BY_802154_DRV & NRFX_DPPI10_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI20_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI20_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI20_GROUPS_USED_BY_802154_DRV & NRFX_DPPI20_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI30_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI30_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI30_GROUPS_USED_BY_802154_DRV & NRFX_DPPI30_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI020_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI020_GROUPS_USED_BY_802154_DRV & NRFX_DPPI020_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI030_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI030_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI030_GROUPS_USED_BY_802154_DRV & NRFX_DPPI030_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI120_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI120_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI120_GROUPS_USED_BY_802154_DRV & NRFX_DPPI120_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI130_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI130_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI130_GROUPS_USED_BY_802154_DRV & NRFX_DPPI130_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI131_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI131_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI131_GROUPS_USED_BY_802154_DRV & NRFX_DPPI131_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI132_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI132_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI132_GROUPS_USED_BY_802154_DRV & NRFX_DPPI132_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI133_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI133_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI133_GROUPS_USED_BY_802154_DRV & NRFX_DPPI133_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI134_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI134_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI134_GROUPS_USED_BY_802154_DRV & NRFX_DPPI134_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI135_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI135_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI135_GROUPS_USED_BY_802154_DRV & NRFX_DPPI135_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI136_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI136_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI136_GROUPS_USED_BY_802154_DRV & NRFX_DPPI136_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPI_CHANNELS_USED_BY_802154_DRV & NRFX_PPI_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPI_GROUPS_USED_BY_802154_DRV & NRFX_PPI_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_00_10_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_00_10_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_01_20_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_01_20_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_11_21_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_22_30_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_22_30_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_02_03_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_02_03_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_04_12_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_04_12_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_020_030_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_020_030_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +#endif /* NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL */ + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI0_CHANNELS_USED \ + (NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI0_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI0_GROUPS_USED \ + (NRFX_DPPI0_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI0_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI0_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI00_CHANNELS_USED \ + (NRFX_DPPI00_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI00_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI00_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI00_GROUPS_USED \ + (NRFX_DPPI00_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI00_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI00_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI10_CHANNELS_USED \ + (NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI10_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI10_GROUPS_USED \ + (NRFX_DPPI10_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI10_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI10_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI20_CHANNELS_USED \ + (NRFX_DPPI20_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI20_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI20_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI20_GROUPS_USED \ + (NRFX_DPPI20_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI20_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI20_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI30_CHANNELS_USED \ + (NRFX_DPPI30_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI30_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI30_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI30_GROUPS_USED \ + (NRFX_DPPI30_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI30_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI30_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI020_CHANNELS_USED \ + (NRFX_DPPI020_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI020_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI020_GROUPS_USED \ + (NRFX_DPPI020_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI020_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI020_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI030_CHANNELS_USED \ + (NRFX_DPPI030_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI030_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI030_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI030_GROUPS_USED \ + (NRFX_DPPI030_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI030_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI030_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI120_CHANNELS_USED \ + (NRFX_DPPI120_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI120_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI120_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI120_GROUPS_USED \ + (NRFX_DPPI120_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI120_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI120_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI130_CHANNELS_USED \ + (NRFX_DPPI130_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI130_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI130_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI130_GROUPS_USED \ + (NRFX_DPPI130_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI130_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI130_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI131_CHANNELS_USED \ + (NRFX_DPPI131_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI131_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI131_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI131_GROUPS_USED \ + (NRFX_DPPI131_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI131_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI131_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI132_CHANNELS_USED \ + (NRFX_DPPI132_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI132_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI132_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI132_GROUPS_USED \ + (NRFX_DPPI132_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI132_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI132_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI133_CHANNELS_USED \ + (NRFX_DPPI133_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI133_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI133_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI133_GROUPS_USED \ + (NRFX_DPPI133_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI133_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI133_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI134_CHANNELS_USED \ + (NRFX_DPPI134_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI134_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI134_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI134_GROUPS_USED \ + (NRFX_DPPI134_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI134_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI134_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI135_CHANNELS_USED \ + (NRFX_DPPI135_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI135_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI135_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI135_GROUPS_USED \ + (NRFX_DPPI135_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI135_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI135_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI136_CHANNELS_USED \ + (NRFX_DPPI136_CHANNELS_USED_BY_BT_CTLR | NRFX_DPPI136_CHANNELS_USED_BY_802154_DRV | \ + NRFX_DPPI136_CHANNELS_USED_BY_MPSL) + +/** @brief Bitmask that defines DPPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_DPPI136_GROUPS_USED \ + (NRFX_DPPI136_GROUPS_USED_BY_BT_CTLR | NRFX_DPPI136_GROUPS_USED_BY_802154_DRV | \ + NRFX_DPPI136_GROUPS_USED_BY_MPSL) + +/** @brief Bitmask that defines PPI channels that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_PPI_CHANNELS_USED \ + (NRFX_PPI_CHANNELS_USED_BY_BT_CTLR | NRFX_PPI_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPI_CHANNELS_USED_BY_MPSL | NRFX_PPI_CHANNELS_USED_BY_SD) + +#define NRFX_DPPI_CHANNELS_USED NRFX_DPPI0_CHANNELS_USED +#define NRFX_DPPI_GROUPS_USED NRFX_DPPI0_GROUPS_USED + +/** @brief Bitmask that defines PPI groups that are reserved for use outside + * of the nrfx library. + */ +#define NRFX_PPI_GROUPS_USED \ + (NRFX_PPI_GROUPS_USED_BY_BT_CTLR | NRFX_PPI_GROUPS_USED_BY_802154_DRV | \ + NRFX_PPI_GROUPS_USED_BY_MPSL | NRFX_PPI_GROUPS_USED_BY_SD) + +#define NRFX_PPIB_INTERCONNECT_00_10_CHANNELS_USED \ + (NRFX_PPIB_00_10_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_00_10_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_00_10_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_01_20_CHANNELS_USED \ + (NRFX_PPIB_01_20_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_01_20_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_01_20_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_11_21_CHANNELS_USED \ + (NRFX_PPIB_11_21_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_11_21_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_22_30_CHANNELS_USED \ + (NRFX_PPIB_22_30_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_22_30_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_22_30_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_02_03_CHANNELS_USED \ + (NRFX_PPIB_02_03_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_02_03_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_02_03_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_04_12_CHANNELS_USED \ + (NRFX_PPIB_04_12_CHANNELS_USED_BY_BT_CTLR | NRFX_PPIB_04_12_CHANNELS_USED_BY_802154_DRV | \ + NRFX_PPIB_04_12_CHANNELS_USED_BY_MPSL) + +#define NRFX_PPIB_INTERCONNECT_020_030_CHANNELS_USED \ + (NRFX_PPIB_020_030_CHANNELS_USED_BY_BT_CTLR | \ + NRFX_PPIB_020_030_CHANNELS_USED_BY_802154_DRV | NRFX_PPIB_020_030_CHANNELS_USED_BY_MPSL) + +#if defined(CONFIG_SOFTDEVICE) +#include +#define NRFX_PPI_CHANNELS_USED_BY_SD SD_PPI_CHANNELS_USED +#define NRFX_PPI_GROUPS_USED_BY_SD SD_PPI_GROUPS_USED +#else +#define NRFX_PPI_CHANNELS_USED_BY_SD 0 +#define NRFX_PPI_GROUPS_USED_BY_SD 0 +#endif + +#endif /* NRFX_CONFIG_RESERVED_RESOURCES_H__ */ diff --git a/modules/hal_nordic/nrfx/nrfx_kconfig.h b/modules/hal_nordic/nrfx/nrfx_kconfig.h index 73a26272d4da..191855b3ff0e 100644 --- a/modules/hal_nordic/nrfx/nrfx_kconfig.h +++ b/modules/hal_nordic/nrfx/nrfx_kconfig.h @@ -512,6 +512,12 @@ #ifdef CONFIG_NRFX_SPIM22 #define NRFX_SPIM22_ENABLED 1 #endif +#ifdef CONFIG_NRFX_SPIM23 +#define NRFX_SPIM23_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_SPIM24 +#define NRFX_SPIM24_ENABLED 1 +#endif #ifdef CONFIG_NRFX_SPIM30 #define NRFX_SPIM30_ENABLED 1 #endif @@ -576,6 +582,12 @@ #ifdef CONFIG_NRFX_SPIS22 #define NRFX_SPIS22_ENABLED 1 #endif +#ifdef CONFIG_NRFX_SPIS23 +#define NRFX_SPIS23_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_SPIS24 +#define NRFX_SPIS24_ENABLED 1 +#endif #ifdef CONFIG_NRFX_SPIS30 #define NRFX_SPIS30_ENABLED 1 #endif @@ -747,6 +759,12 @@ #ifdef CONFIG_NRFX_TWIM22 #define NRFX_TWIM22_ENABLED 1 #endif +#ifdef CONFIG_NRFX_TWIM23 +#define NRFX_TWIM23_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIM24 +#define NRFX_TWIM24_ENABLED 1 +#endif #ifdef CONFIG_NRFX_TWIM30 #define NRFX_TWIM30_ENABLED 1 #endif @@ -811,6 +829,12 @@ #ifdef CONFIG_NRFX_TWIS22 #define NRFX_TWIS22_ENABLED 1 #endif +#ifdef CONFIG_NRFX_TWIS23 +#define NRFX_TWIS23_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS24 +#define NRFX_TWIS24_ENABLED 1 +#endif #ifdef CONFIG_NRFX_TWIS30 #define NRFX_TWIS30_ENABLED 1 #endif @@ -879,6 +903,12 @@ #ifdef CONFIG_NRFX_UARTE22 #define NRFX_UARTE22_ENABLED 1 #endif +#ifdef CONFIG_NRFX_UARTE23 +#define NRFX_UARTE23_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_UARTE24 +#define NRFX_UARTE24_ENABLED 1 +#endif #ifdef CONFIG_NRFX_UARTE30 #define NRFX_UARTE30_ENABLED 1 #endif diff --git a/modules/hal_nordic/nrfx/nrfx_zephyr_utils.h b/modules/hal_nordic/nrfx/nrfx_zephyr_utils.h index e1fa4d4c321a..a7f05ca372d8 100644 --- a/modules/hal_nordic/nrfx/nrfx_zephyr_utils.h +++ b/modules/hal_nordic/nrfx/nrfx_zephyr_utils.h @@ -34,7 +34,7 @@ * definitions required by the interconnect/apb layer: * - NRFX_DPPI_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) * - NRFX_DPPI_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) - * - NRFX_DPPI_PUB_OR_SUB_MASK(inst_num) + * - NRFX_DPPI_OWNED_MASK(inst_num) * - NRFX_DPPI_CHANNELS_SINGLE_VAR_NAME_BY_INST_NUM(inst_num) * - NRFX_INTERCONNECT_APB_GLOBAL_DPPI_DEFINE * - NRFX_INTERCONNECT_APB_LOCAL_DPPI_DEFINE @@ -42,6 +42,14 @@ */ #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_dppic_global) || \ DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_dppic_local) + +/* Channels masks generation. */ +#define NRFX_CONFIG_DPPI_MASK_DT(node_id) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, owned_channels), \ + (NRFX_CONFIG_MASK_DT(node_id, owned_channels)), \ + (COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, nordic_nrf_dppic_local), \ + (BIT64_MASK(DT_PROP(node_id, channels))), (0)))) + /* Source (publish) channels masks generation. */ #define NRFX_DPPI_PUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \ NRFX_CONFIG_MASK_DT(DT_NODELABEL(_CONCAT(dppic, inst_num)), source_channels) @@ -50,9 +58,9 @@ #define NRFX_DPPI_SUB_CONFIG_ALLOWED_CHANNELS_MASK_BY_INST_NUM(inst_num) \ NRFX_CONFIG_MASK_DT(DT_NODELABEL(_CONCAT(dppic, inst_num)), sink_channels) -#define NRFX_DPPI_PUB_OR_SUB_MASK(inst_num) \ - UTIL_OR(DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), source_channels), \ - DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), sink_channels)) +#define NRFX_DPPI_OWNED_MASK(inst_num) \ + UTIL_OR(DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), owned_channels), \ + DT_NODE_HAS_PROP(DT_NODELABEL(_CONCAT(dppic, inst_num)), channels)) /* Variables names generation. */ #define NRFX_CONFIG_DPPI_CHANNELS_ENTRY_NAME(node_id) _CONCAT(_CONCAT(m_, node_id), _channels) @@ -62,9 +70,7 @@ /* Variables entries generation. */ #define NRFX_CONFIG_DPPI_CHANNELS_ENTRY(node_id) \ static nrfx_atomic_t NRFX_CONFIG_DPPI_CHANNELS_ENTRY_NAME(node_id) \ - __attribute__((used)) = \ - NRFX_CONFIG_MASK_DT(node_id, source_channels) | \ - NRFX_CONFIG_MASK_DT(node_id, sink_channels); + __attribute__((used)) = (uint32_t)NRFX_CONFIG_DPPI_MASK_DT(node_id); #define NRFX_INTERCONNECT_APB_GLOBAL_DPPI_DEFINE \ DT_FOREACH_STATUS_OKAY(nordic_nrf_dppic_global, NRFX_CONFIG_DPPI_CHANNELS_ENTRY) #define NRFX_INTERCONNECT_APB_LOCAL_DPPI_DEFINE \ diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig index 95dd2531503e..0c08b6c01b03 100644 --- a/modules/hostap/Kconfig +++ b/modules/hostap/Kconfig @@ -25,7 +25,7 @@ if WIFI_NM_WPA_SUPPLICANT config HEAP_MEM_POOL_ADD_SIZE_HOSTAP def_int 66560 if WIFI_NM_HOSTAPD_AP - def_int 48000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE def_int 41808 if WIFI_NM_WPA_SUPPLICANT_AP # 30K is mandatory, but might need more for long duration use cases def_int 30000 diff --git a/modules/mbedtls/CMakeLists.txt b/modules/mbedtls/CMakeLists.txt index 61c7400017da..8801e1ecdf17 100644 --- a/modules/mbedtls/CMakeLists.txt +++ b/modules/mbedtls/CMakeLists.txt @@ -40,6 +40,8 @@ zephyr_interface_library_named(mbedTLS) # Add regular includes target_include_directories(mbedTLS INTERFACE ${ZEPHYR_CURRENT_MODULE_DIR}/include + ${ZEPHYR_CURRENT_MODULE_DIR}/include/library + ${ZEPHYR_CURRENT_MODULE_DIR}/library configs include ) diff --git a/modules/mbedtls/Kconfig b/modules/mbedtls/Kconfig index bf165473f17f..aa8c479e89f7 100644 --- a/modules/mbedtls/Kconfig +++ b/modules/mbedtls/Kconfig @@ -29,6 +29,7 @@ choice MBEDTLS_IMPLEMENTATION config MBEDTLS_BUILTIN bool "Use Zephyr in-tree mbedTLS version" + depends on ! DISABLE_MBEDTLS_BUILTIN help Link with mbedTLS sources included with Zephyr distribution. Included mbedTLS version is well integrated with and supported @@ -42,6 +43,12 @@ config MBEDTLS_LIBRARY endchoice +config DISABLE_MBEDTLS_BUILTIN + bool + help + Subsystems cannot deselect MBEDTLS_BUILTIN, but they can select + DISABLE_MBEDTLS_BUILTIN. + config CUSTOM_MBEDTLS_CFG_FILE bool "Custom mbed TLS configuration file" help diff --git a/modules/mbedtls/Kconfig.mbedtls b/modules/mbedtls/Kconfig.mbedtls index e534ba0c10a8..2d8f260b5d13 100644 --- a/modules/mbedtls/Kconfig.mbedtls +++ b/modules/mbedtls/Kconfig.mbedtls @@ -7,6 +7,8 @@ menu "Mbed TLS configuration" depends on MBEDTLS_BUILTIN && MBEDTLS_CFG_FILE = "config-mbedtls.h" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + menu "TLS" config MBEDTLS_TLS_VERSION_1_2 @@ -40,6 +42,8 @@ endif # MBEDTLS_TLS_VERSION_1_2 || MBEDTLS_TLS_VERSION_1_3 endmenu # TLS +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + menu "Ciphersuite configuration" comment "Supported key exchange modes" @@ -60,6 +64,8 @@ config MBEDTLS_GENPRIME_ENABLED endif # MBEDTLS_RSA_C +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_KEY_EXCHANGE_ALL_ENABLED bool "All available ciphersuite modes" select MBEDTLS_MD @@ -92,6 +98,8 @@ config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED bool "RSA-PSK based ciphersuite modes" depends on MBEDTLS_PKCS1_V15 || MBEDTLS_PKCS1_V21 +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_PSK_MAX_LEN int "Max size of TLS pre-shared keys" default 32 @@ -99,6 +107,8 @@ config MBEDTLS_PSK_MAX_LEN Max size of TLS pre-shared keys, in bytes. It has no effect if no PSK key exchange is used. +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED bool "RSA-only based ciphersuite modes" depends on MBEDTLS_MD @@ -107,6 +117,7 @@ config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED select PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT if PSA_CRYPTO_CLIENT select PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT if PSA_CRYPTO_CLIENT select PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE if PSA_CRYPTO_CLIENT + select PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE if PSA_CRYPTO_CLIENT config MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED bool "DHE-RSA based ciphersuite modes" @@ -236,8 +247,12 @@ config MBEDTLS_ECP_NIST_OPTIM endif +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + comment "Supported ciphers and cipher modes" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_CIPHER_ALL_ENABLED bool "All available ciphers and modes" select MBEDTLS_CIPHER_AES_ENABLED @@ -268,7 +283,6 @@ config MBEDTLS_SOME_CIPHER_ENABLED config MBEDTLS_CIPHER_AES_ENABLED bool "AES block cipher" - default y if PSA_WANT_KEY_TYPE_AES && MBEDTLS_PSA_CRYPTO_C if MBEDTLS_CIPHER_AES_ENABLED @@ -328,8 +342,12 @@ config MBEDTLS_CMAC bool "CMAC (Cipher-based Message Authentication Code) mode for block ciphers." depends on MBEDTLS_CIPHER_AES_ENABLED || MBEDTLS_CIPHER_DES_ENABLED +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + comment "Supported hash algorithms" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_HASH_ALL_ENABLED bool "All available MAC methods" select MBEDTLS_MD5 @@ -370,10 +388,14 @@ config MBEDTLS_SHA512 config MBEDTLS_POLY1305 bool "Poly1305 hash family" +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + endmenu comment "Random number generators" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_CTR_DRBG_ENABLED bool "CTR_DRBG AES-256-based random generator" depends on MBEDTLS_CIPHER_AES_ENABLED @@ -383,15 +405,21 @@ config MBEDTLS_HMAC_DRBG_ENABLED bool "HMAC_DRBG random generator" select MBEDTLS_MD +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + comment "Other configurations" config MBEDTLS_CIPHER bool "generic cipher layer." default y if PSA_WANT_ALG_CMAC +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_MD bool "generic message digest layer." +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_ASN1_PARSE_C bool "Support for ASN1 parser functions" @@ -431,6 +459,8 @@ config MBEDTLS_HAVE_ASM of asymmetric cryptography, however this might have an impact on the code size. +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_ENTROPY_C bool "Mbed TLS entropy accumulator" depends on MBEDTLS_SHA256 || MBEDTLS_SHA384 || MBEDTLS_SHA512 @@ -439,6 +469,8 @@ config MBEDTLS_ENTROPY_C mostly used in conjunction with CTR_DRBG or HMAC_DRBG to create a deterministic random number generator. +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_ENTROPY_POLL_ZEPHYR bool "Provide entropy data to Mbed TLS through entropy driver or random generator" default y diff --git a/modules/mbedtls/Kconfig.psa.auto b/modules/mbedtls/Kconfig.psa.auto index 08b1bbc02410..b235c30380fb 100644 --- a/modules/mbedtls/Kconfig.psa.auto +++ b/modules/mbedtls/Kconfig.psa.auto @@ -36,10 +36,6 @@ config PSA_WANT_ALG_CMAC bool "PSA_WANT_ALG_CMAC" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_ALG_CFB - bool "PSA_WANT_ALG_CFB" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_ALG_CHACHA20_POLY1305 bool "PSA_WANT_ALG_CHACHA20_POLY1305" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -60,10 +56,6 @@ config PSA_WANT_ALG_ECDH bool "PSA_WANT_ALG_ECDH" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_ALG_FFDH - bool "PSA_WANT_ALG_FFDH" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_ALG_ECDSA bool "PSA_WANT_ALG_ECDSA" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -79,6 +71,7 @@ config PSA_WANT_ALG_GCM config PSA_WANT_ALG_HKDF bool "PSA_WANT_ALG_HKDF" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_HKDF_EXTRACT bool "PSA_WANT_ALG_HKDF_EXTRACT" if !MBEDTLS_PROMPTLESS @@ -95,22 +88,19 @@ config PSA_WANT_ALG_HMAC config PSA_WANT_ALG_MD5 bool "PSA_WANT_ALG_MD5" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_ALG_OFB - bool "PSA_WANT_ALG_OFB" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL + help + Warning: The MD5 hash is weak and deprecated and is only recommended + for use in legacy protocols. config PSA_WANT_ALG_PBKDF2_HMAC bool "PSA_WANT_ALG_PBKDF2_HMAC" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 bool "PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_ALG_RIPEMD160 - bool "PSA_WANT_ALG_RIPEMD160" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_CMAC config PSA_WANT_ALG_RSA_OAEP bool "PSA_WANT_ALG_RSA_OAEP" if !MBEDTLS_PROMPTLESS @@ -131,6 +121,9 @@ config PSA_WANT_ALG_RSA_PSS config PSA_WANT_ALG_SHA_1 bool "PSA_WANT_ALG_SHA_1" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + help + Warning: The SHA-1 hash is weak and deprecated and is only recommended + for use in legacy protocols. config PSA_WANT_ALG_SHA_224 bool "PSA_WANT_ALG_SHA_224" if !MBEDTLS_PROMPTLESS @@ -167,18 +160,22 @@ config PSA_WANT_ALG_SHA3_512 config PSA_WANT_ALG_STREAM_CIPHER bool "PSA_WANT_ALG_STREAM_CIPHER" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + select PSA_WANT_KEY_TYPE_CHACHA20 config PSA_WANT_ALG_TLS12_PRF bool "PSA_WANT_ALG_TLS12_PRF" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_TLS12_PSK_TO_MS bool "PSA_WANT_ALG_TLS12_PSK_TO_MS" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS bool "PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_SHA_256 config PSA_WANT_ECC_BRAINPOOL_P_R1_256 bool "PSA_WANT_ECC_BRAINPOOL_P_R1_256" if !MBEDTLS_PROMPTLESS @@ -228,26 +225,6 @@ config PSA_WANT_ECC_SECP_R1_521 bool "PSA_WANT_ECC_SECP_R1_521" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_DH_RFC7919_2048 - bool "PSA_WANT_DH_RFC7919_2048" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_3072 - bool "PSA_WANT_DH_RFC7919_3072" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_4096 - bool "PSA_WANT_DH_RFC7919_4096" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_6144 - bool "PSA_WANT_DH_RFC7919_6144" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_8192 - bool "PSA_WANT_DH_RFC7919_8192" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_DERIVE bool "PSA_WANT_KEY_TYPE_DERIVE" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -268,30 +245,16 @@ config PSA_WANT_KEY_TYPE_AES bool "PSA_WANT_KEY_TYPE_AES" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_ARIA - bool "PSA_WANT_KEY_TYPE_ARIA" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_CAMELLIA - bool "PSA_WANT_KEY_TYPE_CAMELLIA" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_CHACHA20 bool "PSA_WANT_KEY_TYPE_CHACHA20" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_DES - bool "PSA_WANT_KEY_TYPE_DES" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_CHACHA20_POLY1305 || \ + PSA_WANT_ALG_STREAM_CIPHER config PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY bool "PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY - bool "PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_RAW_DATA bool "PSA_WANT_KEY_TYPE_RAW_DATA" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -302,42 +265,42 @@ config PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT bool "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT bool "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE bool "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE bool "PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT bool "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT bool "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE bool "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE" if !MBEDTLS_PROMPTLESS +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE + bool "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE" if !MBEDTLS_PROMPTLESS + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY default y if PSA_CRYPTO_ENABLE_ALL endif # PSA_CRYPTO_CLIENT diff --git a/modules/mbedtls/Kconfig.psa.logic b/modules/mbedtls/Kconfig.psa.logic index dcea9e354052..2de81163dc1f 100644 --- a/modules/mbedtls/Kconfig.psa.logic +++ b/modules/mbedtls/Kconfig.psa.logic @@ -18,10 +18,3 @@ config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC depends on PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT || \ PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT || \ PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE - -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC - bool - default y - depends on PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT || \ - PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT || \ - PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE diff --git a/modules/openthread/platform/diag.c b/modules/openthread/platform/diag.c index 74781cad4a1d..afa09c7e68d5 100644 --- a/modules/openthread/platform/diag.c +++ b/modules/openthread/platform/diag.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "platform-zephyr.h" diff --git a/modules/trusted-firmware-a/CMakeLists.txt b/modules/trusted-firmware-a/CMakeLists.txt index 72c1ea5c75af..0c0230174f09 100644 --- a/modules/trusted-firmware-a/CMakeLists.txt +++ b/modules/trusted-firmware-a/CMakeLists.txt @@ -8,6 +8,9 @@ if (CONFIG_BUILD_WITH_TFA) include(ExternalProject) + set(tfa_image_info MAP "name: tfa, source-dir: ${ZEPHYR_TRUSTED_FIRMWARE_A_MODULE_DIR}") + build_info(images VALUE ${tfa_image_info}) + ExternalProject_Add( tfa SOURCE_DIR ${ZEPHYR_TRUSTED_FIRMWARE_A_MODULE_DIR} diff --git a/modules/trusted-firmware-m/CMakeLists.txt b/modules/trusted-firmware-m/CMakeLists.txt index 9130f9629789..c76812198a32 100644 --- a/modules/trusted-firmware-m/CMakeLists.txt +++ b/modules/trusted-firmware-m/CMakeLists.txt @@ -315,6 +315,9 @@ if (CONFIG_BUILD_WITH_TFM) # threads. Which is num_cores+2 on Ninja and MAKEFLAGS with Make. endif() + set(tfm_image_info MAP "name: tfm, source-dir: ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}") + build_info(images VALUE ${tfm_image_info}) + ExternalProject_Add( tfm SOURCE_DIR ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR} diff --git a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules b/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules index 1d70a2c44d29..9604319ca012 100644 --- a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules +++ b/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules @@ -10,6 +10,7 @@ if TFM_PARTITION_CRYPTO config TFM_CRYPTO_RNG_MODULE_ENABLED bool "Random number generator crypto module" default y + depends on PSA_WANT_GENERATE_RANDOM && NRF_SECURITY help Enables the random number generator module within the crypto partition. Unset this option if 'psa_generate_random' is not used. @@ -17,6 +18,7 @@ config TFM_CRYPTO_RNG_MODULE_ENABLED config TFM_CRYPTO_KEY_MODULE_ENABLED bool "KEY crypto module" default y + depends on PSA_HAS_KEY_SUPPORT && NRF_SECURITY help Enables the KEY crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_key_management.c' @@ -25,6 +27,7 @@ config TFM_CRYPTO_KEY_MODULE_ENABLED config TFM_CRYPTO_AEAD_MODULE_ENABLED bool "AEAD crypto module" default y + depends on PSA_HAS_AEAD_SUPPORT && NRF_SECURITY help Enables the AEAD crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_aead.c' @@ -33,6 +36,7 @@ config TFM_CRYPTO_AEAD_MODULE_ENABLED config TFM_CRYPTO_MAC_MODULE_ENABLED bool "MAC crypto module" default y + depends on PSA_HAS_MAC_SUPPORT && NRF_SECURITY help Enables the MAC crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_mac.c' @@ -41,6 +45,7 @@ config TFM_CRYPTO_MAC_MODULE_ENABLED config TFM_CRYPTO_HASH_MODULE_ENABLED bool "HASH crypto module" default y + depends on PSA_HAS_HASH_SUPPORT && NRF_SECURITY help Enables the HASH crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_hash.c' @@ -49,6 +54,7 @@ config TFM_CRYPTO_HASH_MODULE_ENABLED config TFM_CRYPTO_CIPHER_MODULE_ENABLED bool "CIPHER crypto module" default y + depends on PSA_HAS_CIPHER_SUPPORT && NRF_SECURITY help Enables the CIPHER crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_cipher.c' @@ -57,6 +63,7 @@ config TFM_CRYPTO_CIPHER_MODULE_ENABLED config TFM_CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED bool "ASYM ENCRYPT crypto module" default y + depends on PSA_HAS_ASYM_ENCRYPT_SUPPORT && NRF_SECURITY help Enables the ASYM ENCRYPT crypto module within the crypto partition. Unset this option if the encrypt functionality provided by 'crypto_asymmetric.c' @@ -65,6 +72,7 @@ config TFM_CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED config TFM_CRYPTO_ASYM_SIGN_MODULE_ENABLED bool "ASYM SIGN crypto module" default y + depends on PSA_HAS_ASYM_SIGN_SUPPORT && NRF_SECURITY help Enables the ASYM SIGN crypto module within the crypto partition. Unset this option if the sign functionality provided by 'crypto_asymmetric.c' @@ -73,10 +81,23 @@ config TFM_CRYPTO_ASYM_SIGN_MODULE_ENABLED config TFM_CRYPTO_KEY_DERIVATION_MODULE_ENABLED bool "KEY DERIVATION crypto module" default y + depends on (PSA_HAS_KEY_DERIVATION || PSA_HAS_KEY_AGREEMENT) && NRF_SECURITY help Enables the KEY_DERIVATION crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_key_derivation.c' is not used. + Note that key agreement is under key derivation in the current implementation. + +config TFM_CRYPTO_PAKE_MODULE_ENABLED + bool "PAKE crypto module" + default y + depends on PSA_HAS_PAKE_SUPPORT + depends on NRF_SECURITY + depends on PSA_CRYPTO_DRIVER_OBERON || PSA_CRYPTO_DRIVER_CRACEN + help + Enables the PAKE crypto module within the crypto partition. + Unset this option if the functionality provided by 'crypto_pake.c' + is not used. endif # TFM_PARTITION_CRYPTO diff --git a/samples/application_development/code_relocation_nocopy/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/application_development/code_relocation_nocopy/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index ab53f12725d7..98d67e2ad082 100644 --- a/samples/application_development/code_relocation_nocopy/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/samples/application_development/code_relocation_nocopy/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -1,10 +1,5 @@ -&cpuapp_ram0x_region { - nordic,access = ; -}; - &xip_region { status = "okay"; - nordic,access = ; }; &mx25uw63 { diff --git a/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay b/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay new file mode 100644 index 000000000000..bd1ceb2f8945 --- /dev/null +++ b/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&led0 { + gpios = <&hpf_gpio 9 GPIO_ACTIVE_HIGH>; +}; diff --git a/samples/bluetooth/bap_broadcast_assistant/src/main.c b/samples/bluetooth/bap_broadcast_assistant/src/main.c index a0471f2ee6f0..6458bfe60fe3 100644 --- a/samples/bluetooth/bap_broadcast_assistant/src/main.c +++ b/samples/bluetooth/bap_broadcast_assistant/src/main.c @@ -1,11 +1,12 @@ /* * Copyright (c) 2024 Demant A/S - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2024-2025 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +35,8 @@ #define PA_SYNC_SKIP 5 #define PA_SYNC_INTERVAL_TO_TIMEOUT_RATIO 20 /* Set the timeout relative to interval */ /* Broadcast IDs are 24bit, so this is out of valid range */ +/* Default semaphore timeout when waiting for an action */ +#define SEM_TIMEOUT K_SECONDS(10) static void scan_for_broadcast_sink(void); @@ -68,6 +72,7 @@ static K_SEM_DEFINE(sem_sink_disconnected, 0, 1); static K_SEM_DEFINE(sem_security_updated, 0, 1); static K_SEM_DEFINE(sem_bass_discovered, 0, 1); static K_SEM_DEFINE(sem_pa_synced, 0, 1); +static K_SEM_DEFINE(sem_pa_sync_terminted, 0, 1); static K_SEM_DEFINE(sem_received_base_subgroups, 0, 1); static bool device_found(struct bt_data *data, void *user_data) @@ -147,6 +152,7 @@ static bool base_store(struct bt_data *data, void *user_data) const struct bt_bap_base *base = bt_bap_base_get_base_from_ad(data); int base_size; int base_subgroup_count; + int err; /* Base is NULL if the data does not contain a valid BASE */ if (base == NULL) { @@ -168,13 +174,19 @@ static bool base_store(struct bt_data *data, void *user_data) } /* Compare BASE and copy if different */ - k_mutex_lock(&base_store_mutex, K_FOREVER); + err = k_mutex_lock(&base_store_mutex, K_MSEC(100)); + if (err != 0) { + /* Could not get BASE mutex, wait for new to avoid blocking */ + return false; + } + if ((size_t)base_size != received_base_size || memcmp(base, received_base, (size_t)base_size) != 0) { (void)memcpy(received_base, base, base_size); received_base_size = (size_t)base_size; } - k_mutex_unlock(&base_store_mutex); + err = k_mutex_unlock(&base_store_mutex); + __ASSERT_NO_MSG(err == 0); /* Stop parsing */ k_sem_give(&sem_received_base_subgroups); @@ -419,9 +431,7 @@ static void scan_for_broadcast_source(void) printk("Scanning for Broadcast Source successfully started\n"); err = k_sem_take(&sem_source_discovered, K_FOREVER); - if (err != 0) { - printk("Failed to take sem_source_discovered (err %d)\n", err); - } + __ASSERT_NO_MSG(err == 0); } static void scan_for_broadcast_sink(void) @@ -439,9 +449,7 @@ static void scan_for_broadcast_sink(void) printk("Scanning for Broadcast Sink successfully started\n"); err = k_sem_take(&sem_sink_discovered, K_FOREVER); - if (err != 0) { - printk("Failed to take sem_sink_discovered (err %d)\n", err); - } + __ASSERT_NO_MSG(err == 0); } static void connected(struct bt_conn *conn, uint8_t err) @@ -528,6 +536,16 @@ static void pa_sync_synced_cb(struct bt_le_per_adv_sync *sync, k_sem_give(&sem_pa_synced); } } +static void pa_sync_term_cb(struct bt_le_per_adv_sync *sync, + const struct bt_le_per_adv_sync_term_info *info) +{ + if (sync == pa_sync) { + printk("PA sync %p terminated with reason %u\n", sync, info->reason); + + k_sem_give(&sem_pa_sync_terminted); + pa_sync = NULL; + } +} static struct bt_bap_broadcast_assistant_cb ba_cbs = { .discover = bap_broadcast_assistant_discover_cb, @@ -536,14 +554,49 @@ static struct bt_bap_broadcast_assistant_cb ba_cbs = { static struct bt_le_per_adv_sync_cb pa_synced_cb = { .synced = pa_sync_synced_cb, + .term = pa_sync_term_cb, .recv = pa_recv, }; static void reset(void) { - printk("\n\nReset...\n\n"); + int err; + + printk("\n\nResetting...\n\n"); + + if (broadcast_sink_conn != NULL) { + err = bt_conn_disconnect(broadcast_sink_conn, BT_HCI_ERR_LOCALHOST_TERM_CONN); + + if (err != 0) { + printk("bt_conn_disconnect failed with %d\n", err); + } else { + if (k_sem_take(&sem_sink_disconnected, SEM_TIMEOUT) != 0) { + /* This should not happen */ + + __ASSERT_NO_MSG(false); + } + } + __ASSERT_NO_MSG(err == 0); + } + + /* Ignore return value as scanning may already be stopped */ + (void)bt_le_scan_stop(); + + if (pa_sync != NULL) { + err = bt_le_per_adv_sync_delete(pa_sync); + + if (err != 0) { + printk("bt_le_per_adv_sync_delete failed with %d\n", err); + } else { + if (k_sem_take(&sem_pa_sync_terminted, SEM_TIMEOUT) != 0) { + /* This should not happen */ + + __ASSERT_NO_MSG(false); + } + } + __ASSERT_NO_MSG(err == 0); + } - broadcast_sink_conn = NULL; selected_broadcast_id = BT_BAP_INVALID_BROADCAST_ID; selected_sid = 0; selected_pa_interval = 0; @@ -568,7 +621,6 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { int main(void) { int err; - struct bt_bap_broadcast_assistant_add_src_param param = { 0 }; err = bt_enable(NULL); if (err) { @@ -585,45 +637,33 @@ int main(void) k_mutex_init(&base_store_mutex); while (true) { + struct bt_bap_broadcast_assistant_add_src_param param = {0}; + + reset(); + scan_for_broadcast_sink(); - err = k_sem_take(&sem_sink_connected, K_FOREVER); + err = k_sem_take(&sem_sink_connected, SEM_TIMEOUT); if (err != 0) { printk("Failed to take sem_sink_connected (err %d)\n", err); + continue; } err = bt_bap_broadcast_assistant_discover(broadcast_sink_conn); if (err != 0) { printk("Failed to discover BASS on the sink (err %d)\n", err); + continue; } - err = k_sem_take(&sem_security_updated, K_SECONDS(10)); + err = k_sem_take(&sem_security_updated, SEM_TIMEOUT); if (err != 0) { - printk("Failed to take sem_security_updated (err %d), resetting\n", err); - bt_conn_disconnect(broadcast_sink_conn, BT_HCI_ERR_AUTH_FAIL); - - if (k_sem_take(&sem_sink_disconnected, K_SECONDS(10)) != 0) { - /* This should not happen */ - return -ETIMEDOUT; - } - - reset(); + printk("Failed to take sem_security_updated (err %d)\n", err); continue; } - err = k_sem_take(&sem_bass_discovered, K_SECONDS(10)); + err = k_sem_take(&sem_bass_discovered, SEM_TIMEOUT); if (err != 0) { - if (err == -EAGAIN) { - printk("Failed to take sem_bass_discovered (err %d)\n", err); - } - bt_conn_disconnect(broadcast_sink_conn, BT_HCI_ERR_UNSUPP_REMOTE_FEATURE); - - if (k_sem_take(&sem_sink_disconnected, K_SECONDS(10)) != 0) { - /* This should not happen */ - return -ETIMEDOUT; - } - - reset(); + printk("Failed to take sem_bass_discovered (err %d)\n", err); continue; } @@ -636,19 +676,19 @@ int main(void) scan_for_broadcast_source(); - printk("Scan stopped, attempting to PA sync to the broadcaster with id 0x%06X\n", + printk("Attempting to PA sync to the broadcaster with id 0x%06X\n", selected_broadcast_id); err = pa_sync_create(); if (err != 0) { - printk("Could not create Broadcast PA sync: %d, resetting\n", err); - return -ETIMEDOUT; + printk("Could not create Broadcast PA sync: %d\n", err); + continue; } printk("Waiting for PA synced\n"); - err = k_sem_take(&sem_pa_synced, K_FOREVER); + err = k_sem_take(&sem_pa_synced, SEM_TIMEOUT); if (err != 0) { - printk("sem_pa_synced timed out, resetting\n"); - return err; + printk("Failed to take sem_pa_synced (err %d)\n", err); + continue; } memset(bass_subgroups, 0, sizeof(bass_subgroups)); @@ -661,42 +701,29 @@ int main(void) /* Wait to receive subgroups */ err = k_sem_take(&sem_received_base_subgroups, K_FOREVER); - if (err != 0) { - printk("Failed to take sem_received_base_subgroups (err %d)\n", err); - return err; - } + __ASSERT_NO_MSG(err == 0); - k_mutex_lock(&base_store_mutex, K_FOREVER); + err = k_mutex_lock(&base_store_mutex, K_FOREVER); + __ASSERT_NO_MSG(err == 0); err = bt_bap_base_foreach_subgroup((const struct bt_bap_base *)received_base, add_pa_sync_base_subgroup_cb, ¶m); - k_mutex_unlock(&base_store_mutex); + err = k_mutex_unlock(&base_store_mutex); + __ASSERT_NO_MSG(err == 0); - if (err < 0) { + if (err != 0) { printk("Could not add BASE to params %d\n", err); continue; } err = bt_bap_broadcast_assistant_add_src(broadcast_sink_conn, ¶m); - if (err) { + if (err != 0) { printk("Failed to add source: %d\n", err); - bt_conn_disconnect(broadcast_sink_conn, BT_HCI_ERR_UNSUPP_REMOTE_FEATURE); - - if (k_sem_take(&sem_sink_disconnected, K_SECONDS(10)) != 0) { - /* This should not happen */ - return -ETIMEDOUT; - } - - reset(); continue; } /* Reset if the sink disconnects */ err = k_sem_take(&sem_sink_disconnected, K_FOREVER); - if (err != 0) { - printk("Failed to take sem_sink_disconnected (err %d)\n", err); - } - - reset(); + __ASSERT_NO_MSG(err == 0); } return 0; diff --git a/samples/bluetooth/bap_broadcast_sink/sample.yaml b/samples/bluetooth/bap_broadcast_sink/sample.yaml index 5d06dee0bf89..148b8b641697 100644 --- a/samples/bluetooth/bap_broadcast_sink/sample.yaml +++ b/samples/bluetooth/bap_broadcast_sink/sample.yaml @@ -24,5 +24,7 @@ tests: - nrf52_bsim - nrf52833dk/nrf52833 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake b/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake +++ b/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_broadcast_source/sample.yaml b/samples/bluetooth/bap_broadcast_source/sample.yaml index 5e5b01d942d0..5f745cd08950 100644 --- a/samples/bluetooth/bap_broadcast_source/sample.yaml +++ b/samples/bluetooth/bap_broadcast_source/sample.yaml @@ -36,5 +36,7 @@ tests: - nrf52_bsim - nrf52833dk/nrf52833 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_broadcast_source/sysbuild.cmake b/samples/bluetooth/bap_broadcast_source/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/bap_broadcast_source/sysbuild.cmake +++ b/samples/bluetooth/bap_broadcast_source/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_unicast_client/sample.yaml b/samples/bluetooth/bap_unicast_client/sample.yaml index 7283090b8781..44f32934ce99 100644 --- a/samples/bluetooth/bap_unicast_client/sample.yaml +++ b/samples/bluetooth/bap_unicast_client/sample.yaml @@ -22,5 +22,7 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52dk/nrf52832 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_unicast_client/sysbuild.cmake b/samples/bluetooth/bap_unicast_client/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/bap_unicast_client/sysbuild.cmake +++ b/samples/bluetooth/bap_unicast_client/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_unicast_server/sample.yaml b/samples/bluetooth/bap_unicast_server/sample.yaml index 068f752b626b..266ced73f66d 100644 --- a/samples/bluetooth/bap_unicast_server/sample.yaml +++ b/samples/bluetooth/bap_unicast_server/sample.yaml @@ -22,5 +22,7 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52dk/nrf52832 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_unicast_server/sysbuild.cmake b/samples/bluetooth/bap_unicast_server/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/bap_unicast_server/sysbuild.cmake +++ b/samples/bluetooth/bap_unicast_server/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/beacon/sample.yaml b/samples/bluetooth/beacon/sample.yaml index f6f08790092f..819ac3d30024 100644 --- a/samples/bluetooth/beacon/sample.yaml +++ b/samples/bluetooth/beacon/sample.yaml @@ -18,7 +18,9 @@ tests: - nrf54l15dk/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuapp sample.bluetooth.beacon-coex: - extra_args: CONF_FILE="prj-coex.conf" + extra_args: + - CONF_FILE="prj-coex.conf" + - SNIPPET="bt-ll-sw-split" harness: bluetooth platform_allow: - nrf52840dk/nrf52840 diff --git a/samples/bluetooth/cap_acceptor/sample.yaml b/samples/bluetooth/cap_acceptor/sample.yaml index 824e744eecaf..9061f44679fb 100644 --- a/samples/bluetooth/cap_acceptor/sample.yaml +++ b/samples/bluetooth/cap_acceptor/sample.yaml @@ -26,5 +26,7 @@ tests: - nrf52833dk/nrf52833 - nrf52840dk/nrf52840 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/cap_acceptor/sysbuild.cmake b/samples/bluetooth/cap_acceptor/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/cap_acceptor/sysbuild.cmake +++ b/samples/bluetooth/cap_acceptor/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/cap_initiator/sample.yaml b/samples/bluetooth/cap_initiator/sample.yaml index b4f593c99129..e3e557f48301 100644 --- a/samples/bluetooth/cap_initiator/sample.yaml +++ b/samples/bluetooth/cap_initiator/sample.yaml @@ -26,5 +26,7 @@ tests: - nrf52833dk/nrf52833 - nrf52840dk/nrf52840 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/cap_initiator/sysbuild.cmake b/samples/bluetooth/cap_initiator/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/cap_initiator/sysbuild.cmake +++ b/samples/bluetooth/cap_initiator/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/direction_finding_central/sample.yaml b/samples/bluetooth/direction_finding_central/sample.yaml index b7a118e6cdc8..ffdf634c6e3e 100644 --- a/samples/bluetooth/direction_finding_central/sample.yaml +++ b/samples/bluetooth/direction_finding_central/sample.yaml @@ -14,15 +14,24 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding.central.aod: + sample.bluetooth.direction_finding.central.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aod.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aod.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp tags: bluetooth integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding.central.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aod.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + tags: bluetooth + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml b/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml index 8e6097de58ae..c500cc80dcec 100644 --- a/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml +++ b/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml @@ -12,14 +12,22 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding_connectionless_rx.aod: + sample.bluetooth.direction_finding_connectionless_rx.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aod.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aod.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding_connectionless_rx.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aod.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml b/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml index 78d21b2c95f5..2a4fa93d19d5 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml +++ b/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml @@ -12,14 +12,22 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding_connectionless.aoa: + sample.bluetooth.direction_finding_connectionless.aoa_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aoa.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aoa.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding_connectionless.aoa_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aoa.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_peripheral/sample.yaml b/samples/bluetooth/direction_finding_peripheral/sample.yaml index f300cb415cc5..01f612ad08a0 100644 --- a/samples/bluetooth/direction_finding_peripheral/sample.yaml +++ b/samples/bluetooth/direction_finding_peripheral/sample.yaml @@ -14,15 +14,24 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding.peripheral.aod: + sample.bluetooth.direction_finding.peripheral.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aoa.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aoa.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp tags: bluetooth integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding.peripheral.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aoa.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + tags: bluetooth + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf b/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..296e68366389 --- /dev/null +++ b/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1,2 @@ +# Increase stack size for Cracen driver. +CONFIG_MAIN_STACK_SIZE=1024 diff --git a/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf b/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf new file mode 100644 index 000000000000..1f7748e5cd7d --- /dev/null +++ b/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf @@ -0,0 +1,33 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_ISR_STACK_SIZE=1024 +CONFIG_IDLE_STACK_SIZE=256 +CONFIG_MAIN_STACK_SIZE=512 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 +CONFIG_IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE=512 +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y + +CONFIG_BT_BUF_EVT_RX_COUNT=16 +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_CMD_TX_SIZE=255 + +# Host +CONFIG_BT_BROADCASTER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_OBSERVER=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_EXT_ADV=y +CONFIG_BT_PER_ADV=y +CONFIG_BT_PER_ADV_SYNC=y + +# Controller +CONFIG_BT_LL_SW_SPLIT=n +CONFIG_BT_LL_SOFTDEVICE=y +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 diff --git a/samples/bluetooth/hci_ipc/sample.yaml b/samples/bluetooth/hci_ipc/sample.yaml index b758b2547688..3763478b6b33 100644 --- a/samples/bluetooth/hci_ipc/sample.yaml +++ b/samples/bluetooth/hci_ipc/sample.yaml @@ -15,7 +15,9 @@ tests: sample.bluetooth.hci_ipc.iso_broadcast.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -25,7 +27,9 @@ tests: sample.bluetooth.hci_ipc.iso_receive.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -35,7 +39,9 @@ tests: sample.bluetooth.hci_ipc.bis.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_bis-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_bis-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -45,7 +51,9 @@ tests: sample.bluetooth.hci_ipc.iso_central.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_central-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_central-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -55,7 +63,9 @@ tests: sample.bluetooth.hci_ipc.iso_peripheral.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -65,7 +75,9 @@ tests: sample.bluetooth.hci_ipc.cis.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_cis-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_cis-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -75,7 +87,9 @@ tests: sample.bluetooth.hci_ipc.iso.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -99,6 +113,7 @@ tests: extra_args: - CONF_FILE="nrf5340_cpunet_df-bt_ll_sw_split.conf" - DTC_OVERLAY_FILE="nrf5340_cpunet_df-bt_ll_sw_split.overlay" + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet @@ -109,13 +124,16 @@ tests: - CONF_FILE="nrf5340_cpunet_df-bt_ll_sw_split.conf" - DTC_OVERLAY_FILE="nrf5340_cpunet_df-bt_ll_sw_split.overlay" - CONFIG_BT_CTLR_PHY_CODED=n + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet sample.bluetooth.hci_ipc.mesh.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet diff --git a/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf b/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf new file mode 100644 index 000000000000..e6749ae63990 --- /dev/null +++ b/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf @@ -0,0 +1 @@ +CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y diff --git a/samples/bluetooth/hci_uart/sample.yaml b/samples/bluetooth/hci_uart/sample.yaml index b555a74ac5bc..97ad6c561b2e 100644 --- a/samples/bluetooth/hci_uart/sample.yaml +++ b/samples/bluetooth/hci_uart/sample.yaml @@ -20,7 +20,9 @@ tests: platform_allow: nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y tags: @@ -29,7 +31,9 @@ tests: sample.bluetooth.hci_uart.nrf5340_netcore.df: harness: bluetooth platform_allow: nrf5340dk/nrf5340/cpunet - extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y tags: @@ -40,7 +44,9 @@ tests: platform_allow: nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y - CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y @@ -50,7 +56,9 @@ tests: sample.bluetooth.hci_uart.nrf5340_netcore.df.iq_report: harness: bluetooth platform_allow: nrf5340dk/nrf5340/cpunet - extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y - CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y @@ -84,6 +92,7 @@ tests: extra_args: - EXTRA_CONF_FILE=overlay-all-bt_ll_sw_split.conf - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" tags: - uart - bluetooth @@ -95,6 +104,7 @@ tests: extra_args: - EXTRA_CONF_FILE=overlay-all-bt_ll_sw_split.conf - DTC_OVERLAY_FILE=./boards/nrf54l15dk_nrf54l15_cpuapp_df.overlay + - SNIPPET="bt-ll-sw-split" tags: - uart - bluetooth diff --git a/samples/bluetooth/hci_vs_scan_req/sample.yaml b/samples/bluetooth/hci_vs_scan_req/sample.yaml index 245a83aa0d96..49526522d16e 100644 --- a/samples/bluetooth/hci_vs_scan_req/sample.yaml +++ b/samples/bluetooth/hci_vs_scan_req/sample.yaml @@ -9,4 +9,6 @@ tests: - nrf52dk/nrf52832 extra_configs: - CONFIG_BT_LL_SW_SPLIT=y + extra_args: + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/iso_central/sample.yaml b/samples/bluetooth/iso_central/sample.yaml index 3a7dedd404ae..57254ee809ab 100644 --- a/samples/bluetooth/iso_central/sample.yaml +++ b/samples/bluetooth/iso_central/sample.yaml @@ -11,11 +11,11 @@ tests: sample.bluetooth.iso_central.bt_ll_sw_split: harness: bluetooth platform_allow: - - qemu_cortex_m3 - - qemu_x86 - nrf52_bsim - nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/mesh/boards/qemu_x86.conf b/samples/bluetooth/mesh/boards/qemu_x86.conf new file mode 100644 index 000000000000..bfb57193b782 --- /dev/null +++ b/samples/bluetooth/mesh/boards/qemu_x86.conf @@ -0,0 +1,6 @@ +# nrf_security only supports Cortex-M via PSA crypto libraries. +# Enforcing usage of built-in Mbed TLS for native simulator. +CONFIG_NRF_SECURITY=n +CONFIG_MBEDTLS_ENABLE_HEAP=n +CONFIG_TRUSTED_STORAGE=n +CONFIG_SECURE_STORAGE=y diff --git a/samples/bluetooth/mesh/prj.conf b/samples/bluetooth/mesh/prj.conf index 14b19316a866..cd7d6532b614 100644 --- a/samples/bluetooth/mesh/prj.conf +++ b/samples/bluetooth/mesh/prj.conf @@ -5,7 +5,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_HWINFO=y CONFIG_BT=y diff --git a/samples/bluetooth/mesh_demo/boards/qemu_x86.conf b/samples/bluetooth/mesh_demo/boards/qemu_x86.conf new file mode 100644 index 000000000000..bfb57193b782 --- /dev/null +++ b/samples/bluetooth/mesh_demo/boards/qemu_x86.conf @@ -0,0 +1,6 @@ +# nrf_security only supports Cortex-M via PSA crypto libraries. +# Enforcing usage of built-in Mbed TLS for native simulator. +CONFIG_NRF_SECURITY=n +CONFIG_MBEDTLS_ENABLE_HEAP=n +CONFIG_TRUSTED_STORAGE=n +CONFIG_SECURE_STORAGE=y diff --git a/samples/bluetooth/mesh_demo/prj.conf b/samples/bluetooth/mesh_demo/prj.conf index bcb738ae5bd1..b7016b02c65b 100644 --- a/samples/bluetooth/mesh_demo/prj.conf +++ b/samples/bluetooth/mesh_demo/prj.conf @@ -31,7 +31,7 @@ CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y # Limit the number of key slots in PSA Crypto core to reduce # RAM footprint diff --git a/samples/bluetooth/mesh_provisioner/boards/qemu_x86.conf b/samples/bluetooth/mesh_provisioner/boards/qemu_x86.conf new file mode 100644 index 000000000000..bfb57193b782 --- /dev/null +++ b/samples/bluetooth/mesh_provisioner/boards/qemu_x86.conf @@ -0,0 +1,6 @@ +# nrf_security only supports Cortex-M via PSA crypto libraries. +# Enforcing usage of built-in Mbed TLS for native simulator. +CONFIG_NRF_SECURITY=n +CONFIG_MBEDTLS_ENABLE_HEAP=n +CONFIG_TRUSTED_STORAGE=n +CONFIG_SECURE_STORAGE=y diff --git a/samples/bluetooth/mesh_provisioner/prj.conf b/samples/bluetooth/mesh_provisioner/prj.conf index 10949c5480db..241767805164 100644 --- a/samples/bluetooth/mesh_provisioner/prj.conf +++ b/samples/bluetooth/mesh_provisioner/prj.conf @@ -45,7 +45,7 @@ CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y #CONFIG_BT_MESH_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml b/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml index d7c816ee5b76..901d40b00d4f 100644 --- a/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml +++ b/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml @@ -23,5 +23,7 @@ tests: integration_platforms: - nrf52_bsim - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake b/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake index 2523aac8ea76..d5d260789ff7 100644 --- a/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake +++ b/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/pbp_public_broadcast_source/sample.yaml b/samples/bluetooth/pbp_public_broadcast_source/sample.yaml index 80c907042119..1d2e31306e29 100644 --- a/samples/bluetooth/pbp_public_broadcast_source/sample.yaml +++ b/samples/bluetooth/pbp_public_broadcast_source/sample.yaml @@ -23,5 +23,7 @@ tests: integration_platforms: - nrf52_bsim - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake b/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake index d3bf7be5b6c3..e0a7fd9d175d 100644 --- a/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake +++ b/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake @@ -18,6 +18,10 @@ if(NOT("${SB_CONFIG_NET_CORE_BOARD}" STREQUAL "")) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/boards/nordic/clock_control/sample.yaml b/samples/boards/nordic/clock_control/sample.yaml index ee63e7c518ed..6e455d29ebc0 100644 --- a/samples/boards/nordic/clock_control/sample.yaml +++ b/samples/boards/nordic/clock_control/sample.yaml @@ -37,7 +37,7 @@ tests: sample.boards.nrf.clock_control.global_hsfll.req_low_freq_n: filter: dt_nodelabel_enabled("hsfll120") extra_configs: - - CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_REQ_LOW_FREQ=n + - CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_REQ_LOW_FREQ=n extra_args: - CONF_FILE="configs/global_hsfll.conf" - DTC_OVERLAY_FILE="configs/global_hsfll.overlay" diff --git a/samples/boards/nordic/clock_control/src/main.c b/samples/boards/nordic/clock_control/src/main.c index ebaaa0cecbd6..d2823db92ac4 100644 --- a/samples/boards/nordic/clock_control/src/main.c +++ b/samples/boards/nordic/clock_control/src/main.c @@ -45,6 +45,13 @@ int main(void) int res; int64_t req_start_uptime; int64_t req_stop_uptime; + struct nrf_clock_spec res_spec; + const struct nrf_clock_spec req_spec = { + .frequency = CONFIG_SAMPLE_CLOCK_FREQUENCY_HZ, + .accuracy = CONFIG_SAMPLE_CLOCK_ACCURACY_PPM, + .precision = CONFIG_SAMPLE_CLOCK_PRECISION, + }; + uint32_t startup_time_us; printk("\n"); printk("clock name: %s\n", SAMPLE_CLOCK_NAME); @@ -52,11 +59,29 @@ int main(void) printk("minimum accuracy request: %uPPM\n", CONFIG_SAMPLE_CLOCK_ACCURACY_PPM); printk("minimum precision request: %u\n", CONFIG_SAMPLE_CLOCK_PRECISION); - const struct nrf_clock_spec spec = { - .frequency = CONFIG_SAMPLE_CLOCK_FREQUENCY_HZ, - .accuracy = CONFIG_SAMPLE_CLOCK_ACCURACY_PPM, - .precision = CONFIG_SAMPLE_CLOCK_PRECISION, - }; + printk("\n"); + ret = nrf_clock_control_resolve(sample_clock_dev, &req_spec, &res_spec); + if (ret == 0) { + printk("resolved frequency request: %uHz\n", res_spec.frequency); + printk("resolved accuracy request: %uPPM\n", res_spec.accuracy); + printk("resolved precision request: %u\n", res_spec.precision); + } else if (ret == -ENOSYS) { + printk("resolve not supported\n"); + } else { + printk("minimum clock specs could not be resolved\n"); + return 0; + } + + printk("\n"); + ret = nrf_clock_control_get_startup_time(sample_clock_dev, &req_spec, &startup_time_us); + if (ret == 0) { + printk("startup time for requested spec: %uus\n", startup_time_us); + } else if (ret == -ENOSYS) { + printk("get startup time not supported\n"); + } else { + printk("failed to get startup time\n"); + return 0; + } sys_notify_init_callback(&cli.notify, sample_notify_cb); @@ -65,7 +90,7 @@ int main(void) printk("\n"); printk("requesting minimum clock specs\n"); req_start_uptime = k_uptime_get(); - ret = nrf_clock_control_request(sample_clock_dev, &spec, &cli); + ret = nrf_clock_control_request(sample_clock_dev, &req_spec, &cli); if (ret < 0) { printk("minimum clock specs could not be met\n"); return 0; @@ -95,7 +120,7 @@ int main(void) printk("\n"); printk("releasing requested clock specs\n"); - ret = nrf_clock_control_release(sample_clock_dev, &spec); + ret = nrf_clock_control_release(sample_clock_dev, &req_spec); if (ret < 0) { printk("failed to release requested clock specs\n"); return 0; diff --git a/samples/boards/nordic/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/boards/nordic/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index bf5ba18d2044..970377c4d896 100644 --- a/samples/boards/nordic/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/samples/boards/nordic/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -7,10 +7,6 @@ status = "okay"; }; -&cpuppr_ram3x_region { - status = "okay"; -}; - &cpuflpr_vpr { status = "okay"; }; diff --git a/samples/boards/nordic/mesh/onoff-app/prj.conf b/samples/boards/nordic/mesh/onoff-app/prj.conf index 0e67042b2653..0783579e795e 100644 --- a/samples/boards/nordic/mesh/onoff-app/prj.conf +++ b/samples/boards/nordic/mesh/onoff-app/prj.conf @@ -9,7 +9,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 diff --git a/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf b/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf index 3bb984208c70..96b5466b4a16 100644 --- a/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf +++ b/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf @@ -7,7 +7,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT_OBSERVER=y CONFIG_BT_BROADCASTER=y diff --git a/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf b/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/boards/nordic/nrf_ironside/update/Kconfig b/samples/boards/nordic/nrf_ironside/update/Kconfig index 702b943ff607..12d3350ef79a 100644 --- a/samples/boards/nordic/nrf_ironside/update/Kconfig +++ b/samples/boards/nordic/nrf_ironside/update/Kconfig @@ -6,6 +6,6 @@ config UPDATE_BLOB_ADDRESS default 0xe100000 help Address of the update blob. The default value matches the placement of the - update blobs delivered with the IRONside SE firmware. + update blobs delivered with the IronSide SE firmware. source "Kconfig.zephyr" diff --git a/samples/boards/nordic/nrf_ironside/update/README.rst b/samples/boards/nordic/nrf_ironside/update/README.rst index 2f44feedf067..484d97d0adda 100644 --- a/samples/boards/nordic/nrf_ironside/update/README.rst +++ b/samples/boards/nordic/nrf_ironside/update/README.rst @@ -1,37 +1,37 @@ .. zephyr:code-sample:: nrf_ironside_update - :name: Nordic IRONside SE firmware update + :name: Nordic IronSide SE firmware update - Update the Nordic IRONside SE firmware. + Update the Nordic IronSide SE firmware. Overview ******** -The Nordic IRONside SE Update sample updates the IRONside SE firmware on a SoC that already has IRONside SE installed. -It can update both the main image and the recovery image of IRONside SE using the IRONside SE firmware release ZIP file. +The Nordic IronSide SE Update sample updates the IronSide SE firmware on a SoC that already has IronSide SE installed. +It can update both the main image and the recovery image of IronSide SE using the IronSide SE firmware release ZIP file. Update procedure **************** The update procedure works as follows: -1. The application invokes the IRONside SE update service and passes the parameters that correspond to the location of the HEX file of the IRONside SE firmware update. +1. The application invokes the IronSide SE update service and passes the parameters that correspond to the location of the HEX file of the IronSide SE firmware update. #. The application prints the return value of the service call and outputs information from the update HEX file. -#. After the service call completes, the IRONside SE firmware updates the internal state of the device. +#. After the service call completes, the IronSide SE firmware updates the internal state of the device. #. The firmware installs the update during the next device boot. This operation can take several seconds. Once the operation has completed, you can read the boot report to verify that the update has taken place. -Building and running the application for nrf54h20dk/nrf54h20/cpuapp/iron -************************************************************************ +Building and running the application for nrf54h20dk/nrf54h20/cpuapp +******************************************************************* .. note:: - You can use this application only when there is already a version of IRONside SE installed on the device. + You can use this application only when there is already a version of IronSide SE installed on the device. -1. Unzip the IRONside SE release ZIP to get the update hex file: +1. Unzip the IronSide SE release ZIP to get the update hex file: .. code-block:: console @@ -39,13 +39,13 @@ Building and running the application for nrf54h20dk/nrf54h20/cpuapp/iron #. Program the appropriate update hex file from the release ZIP using one (not both) of the following commands: - a) To update IRONside SE firmware: + a) To update IronSide SE firmware: .. code-block:: console nrfutil device program --traits jlink --firmware update/ironside_se_update.hex - b) To update IRONside SE recovery firmware: + b) To update IronSide SE recovery firmware: .. code-block:: console @@ -55,7 +55,7 @@ Building and running the application for nrf54h20dk/nrf54h20/cpuapp/iron .. zephyr-app-commands:: :zephyr-app: samples/boards/nordic/nrf_ironside/update - :board: nrf54h20dk/nrf54h20/cpuapp/iron + :board: nrf54h20dk/nrf54h20/cpuapp :goals: flash #. Trigger a reset: diff --git a/samples/boards/nordic/nrf_ironside/update/sample.yaml b/samples/boards/nordic/nrf_ironside/update/sample.yaml index af3c24624b88..3a5d9477da2f 100644 --- a/samples/boards/nordic/nrf_ironside/update/sample.yaml +++ b/samples/boards/nordic/nrf_ironside/update/sample.yaml @@ -1,12 +1,12 @@ sample: - name: Nordic IRONside SE update service - description: Demonstrates how to update the Nordic IRONside SE firmware + name: Nordic IronSide SE update service + description: Demonstrates how to update the Nordic IronSide SE firmware common: build_only: true tags: nrf_ironside integration_platforms: - - nrf54h20dk/nrf54h20/cpuapp/iron + - nrf54h20dk/nrf54h20/cpuapp tests: sample.boards.nordic.nrf_ironside.update: - platform_allow: nrf54h20dk/nrf54h20/cpuapp/iron + platform_allow: nrf54h20dk/nrf54h20/cpuapp diff --git a/samples/boards/nordic/nrf_ironside/update/src/main.c b/samples/boards/nordic/nrf_ironside/update/src/main.c index a06603ca9b28..17098d93d3b4 100644 --- a/samples/boards/nordic/nrf_ironside/update/src/main.c +++ b/samples/boards/nordic/nrf_ironside/update/src/main.c @@ -28,7 +28,7 @@ int main(void) LOG_HEXDUMP_INF((void *)report->random_data, sizeof(report->random_data), "random data"); err = ironside_update(update); - LOG_INF("IRONside update retval: 0x%x", err); + LOG_INF("IronSide update retval: 0x%x", err); if (err == 0) { LOG_HEXDUMP_INF(update->manifest, sizeof(update->manifest), "Update manifest:"); diff --git a/samples/boards/nordic/system_off/sample.yaml b/samples/boards/nordic/system_off/sample.yaml index 81c2f0f262b6..6e17223e12b4 100644 --- a/samples/boards/nordic/system_off/sample.yaml +++ b/samples/boards/nordic/system_off/sample.yaml @@ -42,7 +42,7 @@ tests: ordered: true regex: - "system off demo" - - "Retained data: INVALID" + - "Retained data: valid" - "Boot count: 1" - "Off count: 0" - "Active Ticks:" @@ -87,7 +87,7 @@ tests: ordered: true regex: - "system off demo" - - "Retained data: INVALID" + - "Retained data: valid" - "Boot count: 1" - "Off count: 0" - "Active Ticks:" @@ -134,7 +134,7 @@ tests: ordered: true regex: - "system off demo" - - "Retained data: INVALID" + - "Retained data: valid" - "Boot count: 1" - "Off count: 0" - "Active Ticks:" diff --git a/samples/boards/nordic/system_off/src/main.c b/samples/boards/nordic/system_off/src/main.c index 0b0cbf3cb0bb..d119eff87dac 100644 --- a/samples/boards/nordic/system_off/src/main.c +++ b/samples/boards/nordic/system_off/src/main.c @@ -18,6 +18,8 @@ #include #include +#define NON_WAKEUP_RESET_REASON (RESET_PIN | RESET_SOFTWARE | RESET_POR | RESET_DEBUG) + #if defined(CONFIG_GRTC_WAKEUP_ENABLE) #include #define DEEP_SLEEP_TIME_S 2 @@ -29,15 +31,14 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios); static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp)); #endif -void print_reset_cause(void) +void print_reset_cause(uint32_t reset_cause) { - uint32_t reset_cause; - - hwinfo_get_reset_cause(&reset_cause); if (reset_cause & RESET_DEBUG) { printf("Reset by debugger.\n"); } else if (reset_cause & RESET_CLOCK) { printf("Wakeup from System OFF by GRTC.\n"); + } else if (reset_cause & RESET_LOW_POWER_WAKE) { + printf("Wakeup from System OFF by GPIO.\n"); } else { printf("Other wake up cause 0x%08X.\n", reset_cause); } @@ -46,6 +47,7 @@ void print_reset_cause(void) int main(void) { int rc; + uint32_t reset_cause; const struct device *const cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); if (!device_is_ready(cons)) { @@ -54,11 +56,19 @@ int main(void) } printf("\n%s system off demo\n", CONFIG_BOARD); - print_reset_cause(); + hwinfo_get_reset_cause(&reset_cause); + print_reset_cause(reset_cause); if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) { bool retained_ok = retained_validate(); + if (reset_cause & NON_WAKEUP_RESET_REASON) { + retained.boots = 0; + retained.off_count = 0; + retained.uptime_sum = 0; + retained.uptime_latest = 0; + retained_ok = true; + } /* Increment for this boot attempt and update. */ retained.boots += 1; retained_update(); diff --git a/samples/drivers/counter/alarm/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay b/samples/drivers/counter/alarm/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay deleted file mode 100644 index f65b4dd3b0ba..000000000000 --- a/samples/drivers/counter/alarm/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay +++ /dev/null @@ -1,3 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ - -#include "nrf54h20dk_nrf54h20_common.dtsi" diff --git a/samples/drivers/mbox/CMakeLists.txt b/samples/drivers/mbox/CMakeLists.txt index 3b154d9afcae..e2ea0f6687ec 100644 --- a/samples/drivers/mbox/CMakeLists.txt +++ b/samples/drivers/mbox/CMakeLists.txt @@ -24,7 +24,6 @@ if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP OR CONFIG_BOARD_ESP32_DEVKITC_ESP32_PROCPU OR CONFIG_BOARD_ESP32S3_DEVKITM_ESP32S3_PROCPU OR CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP OR - CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD OR CONFIG_BOARD_NRF54L09PDK_NRF54L09_CPUAPP OR CONFIG_BOARD_NRF54L15DK_NRF54L15_CPUAPP OR CONFIG_BOARD_NRF54L20PDK_NRF54L20_CPUAPP OR diff --git a/samples/drivers/mbox/Kconfig.sysbuild b/samples/drivers/mbox/Kconfig.sysbuild index 1c0d77b7ded3..96f1ba8c7f48 100644 --- a/samples/drivers/mbox/Kconfig.sysbuild +++ b/samples/drivers/mbox/Kconfig.sysbuild @@ -18,7 +18,6 @@ config REMOTE_BOARD default "lpcxpresso55s69/lpc55s69/cpu1" if $(BOARD) = "lpcxpresso55s69" default "frdm_mcxn947/mcxn947/cpu1" if $(BOARD) = "frdm_mcxn947" default "mcx_n9xx_evk/mcxn947/cpu1" if $(BOARD) = "mcx_n9xx_evk" - default "nrf54h20dk/nrf54h20/cpuapp" if "$(BOARD)${BOARD_QUALIFIERS}" = "nrf54h20dk/nrf54h20/cpurad" default "nrf54l09pdk/nrf54l09/cpuflpr" if $(BOARD) = "nrf54l09pdk" default "nrf54l15dk/nrf54l15/cpuflpr" if $(BOARD) = "nrf54l15dk" default "nrf54l20pdk/nrf54l20/cpuflpr" if $(BOARD) = "nrf54l20pdk" diff --git a/samples/drivers/mbox/remote/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/drivers/mbox/boards/nrf54h20dk_nrf54h20_cpuapp.overlay similarity index 100% rename from samples/drivers/mbox/remote/boards/nrf54h20dk_nrf54h20_cpuapp.overlay rename to samples/drivers/mbox/boards/nrf54h20dk_nrf54h20_cpuapp.overlay diff --git a/samples/drivers/mbox/remote/CMakeLists.txt b/samples/drivers/mbox/remote/CMakeLists.txt index baa0e22ff359..2866503e448d 100644 --- a/samples/drivers/mbox/remote/CMakeLists.txt +++ b/samples/drivers/mbox/remote/CMakeLists.txt @@ -23,7 +23,7 @@ if(CONFIG_BOARD_NRF5340DK_NRF5340_CPUNET OR CONFIG_BOARD_ESP32S3_DEVKITM_ESP32S3_APPCPU OR CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUPPR OR CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUFLPR OR - CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP OR + CONFIG_BOARD_NRF54H20DK_NRF54H20_CPURAD OR CONFIG_BOARD_NRF54L09PDK_NRF54L09_CPUFLPR OR CONFIG_BOARD_NRF54L15DK_NRF54L15_CPUFLPR OR CONFIG_BOARD_NRF54L20PDK_NRF54L20_CPUFLPR OR diff --git a/samples/drivers/mbox/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/samples/drivers/mbox/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay similarity index 100% rename from samples/drivers/mbox/boards/nrf54h20dk_nrf54h20_cpurad.overlay rename to samples/drivers/mbox/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay diff --git a/samples/drivers/mbox/sample.yaml b/samples/drivers/mbox/sample.yaml index f1a1e56e771f..e1f90d1d590c 100644 --- a/samples/drivers/mbox/sample.yaml +++ b/samples/drivers/mbox/sample.yaml @@ -59,19 +59,22 @@ tests: - "Ping \\(on channel 16\\)" - "Pong \\(on channel 14\\)" - sample.drivers.mbox.nrf54h20_rad_app: + sample.drivers.mbox.nrf54h20_app_rad: platform_allow: - - nrf54h20dk/nrf54h20/cpurad + - nrf54h20dk/nrf54h20/cpuapp integration_platforms: - - nrf54h20dk/nrf54h20/cpurad + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + - mbox_CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y + - SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf sysbuild: true harness: console harness_config: type: multi_line ordered: false regex: - - "Ping \\(on channel 18\\)" - - "Pong \\(on channel 12\\)" + - "Ping \\(on channel 12\\)" + - "Pong \\(on channel 18\\)" sample.drivers.mbox.nrf54l: platform_allow: diff --git a/samples/drivers/mbox/sysbuild.conf b/samples/drivers/mbox/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/drivers/mbox/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/drivers/mbox/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf b/samples/drivers/mbox/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..dd863e78d993 --- /dev/null +++ b/samples/drivers/mbox/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad" diff --git a/samples/drivers/watchdog/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay b/samples/drivers/watchdog/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay similarity index 100% rename from samples/drivers/watchdog/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay rename to samples/drivers/watchdog/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay diff --git a/samples/net/dns_resolve/Kconfig.sysbuild b/samples/net/dns_resolve/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/dns_resolve/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/ipv4_autoconf/Kconfig.sysbuild b/samples/net/ipv4_autoconf/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/ipv4_autoconf/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/lwm2m_client/Kconfig.sysbuild b/samples/net/lwm2m_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/lwm2m_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/lwm2m_client/overlay-nrf91x.conf b/samples/net/lwm2m_client/overlay-nrf91x.conf new file mode 100644 index 000000000000..9597791c10ee --- /dev/null +++ b/samples/net/lwm2m_client/overlay-nrf91x.conf @@ -0,0 +1,53 @@ +# Configuration file for nRF91x +# This file is merged with prj.conf in the application folder, and options +# set here will take precedence if they are present in both files. + +# General +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_NET_SOCKETS=y +CONFIG_NET_NATIVE=y +CONFIG_NET_SOCKETS_OFFLOAD=y + +CONFIG_NET_CONFIG_MY_IPV6_ADDR="" +CONFIG_NET_CONFIG_PEER_IPV6_ADDR="" +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_CONFIG_MY_IPV4_GW="" + +CONFIG_NET_CONFIG_NEED_IPV6=n +CONFIG_NET_CONFIG_NEED_IPV4=n +CONFIG_NET_CONFIG_AUTO_INIT=n + +# Modem related configurations +CONFIG_NRF_MODEM_LIB_NET_IF=y +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=n +CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y + +CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=n +CONFIG_NRF_MODEM_LIB_NET_IF_LOG_LEVEL_DBG=n + +# Disable Duplicate Address Detection (DAD) +# due to not being properly implemented for offloaded interfaces. +CONFIG_NET_IPV6_NBR_CACHE=n +CONFIG_NET_IPV6_MLD=n + +# Zephyr NET Connection Manager and Connectivity layer. +CONFIG_NET_CONNECTION_MANAGER=y +CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 + +CONFIG_LWM2M_APP_ID="nrf91x" +CONFIG_LWM2M_APP_SERVER="coaps://leshan.eclipseprojects.io:5684" +CONFIG_LWM2M_DNS_SUPPORT=y + +## Enable DTLS support +CONFIG_LWM2M_DTLS_SUPPORT=y +CONFIG_LWM2M_TLS_SESSION_CACHING=y +CONFIG_LWM2M_DTLS_CID=y +CONFIG_TLS_CREDENTIALS=y + +## Crypto +CONFIG_OBERON_BACKEND=y +CONFIG_NORDIC_SECURITY_BACKEND=y +CONFIG_MBEDTLS_SHA256_C=y diff --git a/samples/net/mdns_responder/Kconfig.sysbuild b/samples/net/mdns_responder/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mdns_responder/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/mqtt_publisher/Kconfig.sysbuild b/samples/net/mqtt_publisher/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mqtt_publisher/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/mqtt_sn_publisher/Kconfig.sysbuild b/samples/net/mqtt_sn_publisher/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mqtt_sn_publisher/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/big_http_download/prj.conf b/samples/net/sockets/big_http_download/prj.conf index a406f314dfb2..8677e7113e4b 100644 --- a/samples/net/sockets/big_http_download/prj.conf +++ b/samples/net/sockets/big_http_download/prj.conf @@ -3,6 +3,7 @@ CONFIG_REQUIRES_FULL_LIBC=y CONFIG_MBEDTLS=y CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_MBEDTLS_MD=y +CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y CONFIG_MAIN_STACK_SIZE=2536 # Networking config diff --git a/samples/net/sockets/coap_server/Kconfig.sysbuild b/samples/net/sockets/coap_server/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/coap_server/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_async/Kconfig.sysbuild b/samples/net/sockets/echo_async/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_async/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_client/Kconfig.sysbuild b/samples/net/sockets/echo_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_server/Kconfig.sysbuild b/samples/net/sockets/echo_server/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_server/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/http_get/Kconfig.sysbuild b/samples/net/sockets/http_get/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/http_get/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/sntp_client/Kconfig.sysbuild b/samples/net/sockets/sntp_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/sntp_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/stats/src/main.c b/samples/net/stats/src/main.c index fdfb7e4339c1..7b3d1a844aa0 100644 --- a/samples/net/stats/src/main.c +++ b/samples/net/stats/src/main.c @@ -32,25 +32,25 @@ static void print_stats(struct net_if *iface, struct net_stats *data) } #if defined(CONFIG_NET_IPV6) - printk("IPv6 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n", + printk("IPv6 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u\n", GET_STAT(iface, ipv6.recv), GET_STAT(iface, ipv6.sent), GET_STAT(iface, ipv6.drop), GET_STAT(iface, ipv6.forwarded)); #if defined(CONFIG_NET_IPV6_ND) - printk("IPv6 ND recv %d\tsent\t%d\tdrop\t%d\n", + printk("IPv6 ND recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_nd.recv), GET_STAT(iface, ipv6_nd.sent), GET_STAT(iface, ipv6_nd.drop)); #endif /* CONFIG_NET_IPV6_ND */ #if defined(CONFIG_NET_IPV6_PMTU) - printk("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d\n", + printk("IPv6 PMTU recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_pmtu.recv), GET_STAT(iface, ipv6_pmtu.sent), GET_STAT(iface, ipv6_pmtu.drop)); #endif /* CONFIG_NET_IPV6_PMTU */ #if defined(CONFIG_NET_STATISTICS_MLD) - printk("IPv6 MLD recv %d\tsent\t%d\tdrop\t%d\n", + printk("IPv6 MLD recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_mld.recv), GET_STAT(iface, ipv6_mld.sent), GET_STAT(iface, ipv6_mld.drop)); @@ -58,70 +58,70 @@ static void print_stats(struct net_if *iface, struct net_stats *data) #endif /* CONFIG_NET_IPV6 */ #if defined(CONFIG_NET_IPV4) - printk("IPv4 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n", + printk("IPv4 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u\n", GET_STAT(iface, ipv4.recv), GET_STAT(iface, ipv4.sent), GET_STAT(iface, ipv4.drop), GET_STAT(iface, ipv4.forwarded)); #endif /* CONFIG_NET_IPV4 */ - printk("IP vhlerr %d\thblener\t%d\tlblener\t%d\n", + printk("IP vhlerr %u\thblener\t%u\tlblener\t%u\n", GET_STAT(iface, ip_errors.vhlerr), GET_STAT(iface, ip_errors.hblenerr), GET_STAT(iface, ip_errors.lblenerr)); - printk("IP fragerr %d\tchkerr\t%d\tprotoer\t%d\n", + printk("IP fragerr %u\tchkerr\t%u\tprotoer\t%u\n", GET_STAT(iface, ip_errors.fragerr), GET_STAT(iface, ip_errors.chkerr), GET_STAT(iface, ip_errors.protoerr)); #if defined(CONFIG_NET_IPV4_PMTU) - printk("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d\n", + printk("IPv4 PMTU recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv4_pmtu.recv), GET_STAT(iface, ipv4_pmtu.sent), GET_STAT(iface, ipv4_pmtu.drop)); #endif /* CONFIG_NET_IPV4_PMTU */ - printk("ICMP recv %d\tsent\t%d\tdrop\t%d\n", + printk("ICMP recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, icmp.recv), GET_STAT(iface, icmp.sent), GET_STAT(iface, icmp.drop)); - printk("ICMP typeer %d\tchkerr\t%d\n", + printk("ICMP typeer %u\tchkerr\t%u\n", GET_STAT(iface, icmp.typeerr), GET_STAT(iface, icmp.chkerr)); #if defined(CONFIG_NET_UDP) - printk("UDP recv %d\tsent\t%d\tdrop\t%d\n", + printk("UDP recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, udp.recv), GET_STAT(iface, udp.sent), GET_STAT(iface, udp.drop)); - printk("UDP chkerr %d\n", + printk("UDP chkerr %u\n", GET_STAT(iface, udp.chkerr)); #endif #if defined(CONFIG_NET_STATISTICS_TCP) - printk("TCP bytes recv %u\tsent\t%d\n", + printk("TCP bytes recv %llu\tsent\t%llu\n", GET_STAT(iface, tcp.bytes.received), GET_STAT(iface, tcp.bytes.sent)); - printk("TCP seg recv %d\tsent\t%d\tdrop\t%d\n", + printk("TCP seg recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, tcp.recv), GET_STAT(iface, tcp.sent), GET_STAT(iface, tcp.drop)); - printk("TCP seg resent %d\tchkerr\t%d\tackerr\t%d\n", + printk("TCP seg resent %u\tchkerr\t%u\tackerr\t%u\n", GET_STAT(iface, tcp.resent), GET_STAT(iface, tcp.chkerr), GET_STAT(iface, tcp.ackerr)); - printk("TCP seg rsterr %d\trst\t%d\tre-xmit\t%d\n", + printk("TCP seg rsterr %u\trst\t%u\tre-xmit\t%u\n", GET_STAT(iface, tcp.rsterr), GET_STAT(iface, tcp.rst), GET_STAT(iface, tcp.rexmit)); - printk("TCP conn drop %d\tconnrst\t%d\n", + printk("TCP conn drop %u\tconnrst\t%u\n", GET_STAT(iface, tcp.conndrop), GET_STAT(iface, tcp.connrst)); #endif - printk("Bytes received %u\n", GET_STAT(iface, bytes.received)); - printk("Bytes sent %u\n", GET_STAT(iface, bytes.sent)); - printk("Processing err %d\n", GET_STAT(iface, processing_error)); + printk("Bytes received %llu\n", GET_STAT(iface, bytes.received)); + printk("Bytes sent %llu\n", GET_STAT(iface, bytes.sent)); + printk("Processing err %u\n", GET_STAT(iface, processing_error)); } #if defined(CONFIG_NET_STATISTICS_PER_INTERFACE) @@ -141,8 +141,8 @@ static void print_eth_stats(struct net_if *iface, struct net_stats_eth *data) printk("Statistics for Ethernet interface %p [%d]\n", iface, net_if_get_by_iface(iface)); - printk("Bytes received : %u\n", data->bytes.received); - printk("Bytes sent : %u\n", data->bytes.sent); + printk("Bytes received : %llu\n", data->bytes.received); + printk("Bytes sent : %llu\n", data->bytes.sent); printk("Packets received : %u\n", data->pkts.rx); printk("Packets sent : %u\n", data->pkts.tx); printk("Bcast received : %u\n", data->broadcast.rx); diff --git a/samples/net/syslog_net/Kconfig.sysbuild b/samples/net/syslog_net/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/syslog_net/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/telnet/Kconfig.sysbuild b/samples/net/telnet/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/telnet/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/wifi/Kconfig.sysbuild b/samples/net/wifi/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/wifi/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/wifi/shell/sample.yaml b/samples/net/wifi/shell/sample.yaml index 5f72e0686116..8543e6bfb38b 100644 --- a/samples/net/wifi/shell/sample.yaml +++ b/samples/net/wifi/shell/sample.yaml @@ -58,6 +58,7 @@ tests: - nrf7002dk/nrf5340/cpuapp/nrf7001 sample.net.wifi.nrf7002ek: extra_args: + - SB_CONFIG_WIFI_NRF70=y - CONFIG_BUILD_ONLY_NO_BLOBS=y - SHIELD=nrf7002ek platform_allow: @@ -69,6 +70,7 @@ tests: sample.net.wifi.nrf7002eb: extra_args: - CONFIG_NRF70_UTIL=y + - SB_CONFIG_WIFI_NRF70=y - CONFIG_BUILD_ONLY_NO_BLOBS=y - SHIELD=nrf7002eb platform_allow: diff --git a/samples/net/wifi/test_certs/rsa3k/ca.pem b/samples/net/wifi/test_certs/rsa3k/ca.pem index 210e27daad76..2b872d2e30da 100644 --- a/samples/net/wifi/test_certs/rsa3k/ca.pem +++ b/samples/net/wifi/test_certs/rsa3k/ca.pem @@ -1,29 +1,24 @@ -----BEGIN CERTIFICATE----- -MIIE6TCCA1GgAwIBAgIUH4N5boKrWBsvBRqfKvYDxZ0DDtgwDQYJKoZIhvcNAQEM -BQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYDVQQIDAlTb21ld2hlcmUxEjAQBgNVBAcM -CVNvbWV3aGVyZTEUMBIGA1UECgwLRXhhbXBsZSBJbmMxEzARBgNVBAMMCkV4YW1w -bGUgQ0ExIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUub3JnMCAXDTA5MTIz -MTE2MDEyOFoYDzIxMDkxMjA3MTYwMTI4WjCBgjELMAkGA1UEBhMCQ04xEjAQBgNV -BAgMCVNvbWV3aGVyZTESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQKDAtFeGFt -cGxlIEluYzETMBEGA1UEAwwKRXhhbXBsZSBDQTEgMB4GCSqGSIb3DQEJARYRYWRt -aW5AZXhhbXBsZS5vcmcwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDA -PnXIdC5u6eCrXpQfTYwE6QwbSoxPE6kgN0CeVGqk4ya89RzmW/I6+ENw9exraeAl -xDEc2s1OSmBMeAn7b/nDiV3ik4MpQ2+5ZlmKQHYRrjfdnw/zwkcWncPX+UuTfXlx -b4PGBOF/J7HehpfCCQ9g3aXlMWYxR/A0nkFbnfy3gIX7Q0tvGmFJmYWgKxvEELOM -3qV8Jwmui+sw8SL14F+7vZgfBqjnpXfjFaSa+K63sGWLtyy7oQ7eYhpOylA3QSf7 -Hyu+lLQSnHafEys1eedD/Re+gPFUtga/f+CX111ZYDW4zud6W/V3AT1ZGrnrGmCg -k5NeEkLnxaj+GOSvd9O2pnwPSCA2mdRhhx5XxIVD3rZvfR86KflDco8D9i4jPpA0 -38QduFsYXRFS1zTVZuKSlv/bjAmwsNFb/rAS97PVcJf6UVtNkGorc2R2qGWxVDLm -lJSzv14j0swUQomb31+PzAngvB+b2HbjvFCgIb+YHu4c83Gb4tYYBYcu2VgJ0K0C -AwEAAaNTMFEwHQYDVR0OBBYEFNASTtq6TuD6opLY9NUMtneRjAicMB8GA1UdIwQY -MBaAFNASTtq6TuD6opLY9NUMtneRjAicMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI -hvcNAQEMBQADggGBAFbPTxPsNaQeAjN9J6F32l4YQFwhOWSXI/40VQHZTtWeiP87 -EOpOaeE+oboHn6EIYE7meT92vDD/JzJ6JnD0a3kVgRFWe2Wn1FOpFWVbNMzMk03P -CNYH2Vbbcsi0fDp9mFvfU9jV8+onWz363Q2M+VJ3BxnrOFpp0+NHt0mNPFN4A8/J -58eTde+QBoUUFrKmviceuHNMqG4o3IIk71LTNg6vWUU94YFLjSSoM5LqLQ2gZapg -4vFlYrEATpk/QBzATW4bRT0KLkHDroJj1iU4U5Ju4t2mXVDRtw9Ci0TLe3iD6rO+ -GPtxw5KsR4BvY9m+UORAoRSpYWGv3ZRPPz2EL9duF9rwJsjeCxiy6r4JK32R71JC -njnSImcf2QQ5MX6Kk0hMcrdkZY4oCyMQj6yk+EuI1XlK9vK4wctPS10bPRTiDzP3 -8sSoFkQegoV2FuqCAVECtSHJE6w56fvoV+wwtwn/Q9pQiJisj+wmwCRy2EYq9R1G -pFJpUlMAmEDj5r9lYg== +MIIEBzCCAu+gAwIBAgIUK8+d+8IOzeX+DP3VSvdF3lHiCdcwDQYJKoZIhvcNAQEL +BQAwgZIxCzAJBgNVBAYTAkZSMQ8wDQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNv +bWV3aGVyZTEUMBIGA1UECgwLRXhhbXBsZSBJbmMxJjAkBgNVBAMMHUV4YW1wbGUg +Q2VydGlmaWNhdGUgQXV0aG9yaXR5MSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFt +cGxlLm9yZzAeFw0yNDEwMDgxMDI0MDZaFw0zNDEwMDYxMDI0MDZaMIGSMQswCQYD +VQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hlcmUxFDAS +BgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRl +IEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5vcmcwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWKIwjdRIp9IrpZELN/ZsN13Xj +qQI6n086PNJ7BZfLi0+tD164rmxFk2eukNNksFCPhvMkqUxouGhc4mJjeivvrZxR +oT3cblOQIkkdEci6iTKC2E1a20W/Ur7cTXoIsnKwjiUjXk+cujkrZu4fcHX+O4vy +wTd5tEbhmifT/4u5nN8U2vBcEZqkGHOCp30VZSxtlGwqp4lc+tVziF3uFViW9MXk +3bVt+s1E7ztwG7+WBgVlLYe3CNSWkMxfyYBafH/l7iep6AFjoTn1z3AAjYi7IUNN +0JkW8MTgafRQIu4QsV5luq/Tiar2vwAm/GNgUJdSzUKARsfQzb/XTIgnLQqtAgMB +AAGjUzBRMB0GA1UdDgQWBBSijSC03/Thi6EOdM91V33zsbQpgzAfBgNVHSMEGDAW +gBSijSC03/Thi6EOdM91V33zsbQpgzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQAvKEfmCDoMTKC6bfP6DSs+MSAGc5tCr6w6cz2AKNJ2fOMhkq55 +JF47oBBGm9SdTB6Jqo6c109Ps69/+LMtEEGwvzL0RL0WAuTYGo6sudm9hj/jDHZh +pAqi/2BQQeVgTa6oW0jtNPFe+/cobXo9TJ7wECGrhvVbmfl5ZPc0YVOIjjR0/LhL +q7lqPAlJ5vx0WvsX+QReN97we8vD0x1D3mCySJTi3Irh+grE0yJOSN2fa7cyqi9+ +vSiNUB1eUgQwrO+S8ZazYNvAZXC2Xf4WB4SOifJD73pYPAdwOejc0FA+zfEKa/6/ +vTUs8cIhlmDWO+BEoc9wygMKMmhT5s7/T5Bv -----END CERTIFICATE----- diff --git a/samples/net/wifi/test_certs/rsa3k/ca2.pem b/samples/net/wifi/test_certs/rsa3k/ca2.pem index 210e27daad76..2b872d2e30da 100644 --- a/samples/net/wifi/test_certs/rsa3k/ca2.pem +++ b/samples/net/wifi/test_certs/rsa3k/ca2.pem @@ -1,29 +1,24 @@ -----BEGIN CERTIFICATE----- -MIIE6TCCA1GgAwIBAgIUH4N5boKrWBsvBRqfKvYDxZ0DDtgwDQYJKoZIhvcNAQEM -BQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYDVQQIDAlTb21ld2hlcmUxEjAQBgNVBAcM -CVNvbWV3aGVyZTEUMBIGA1UECgwLRXhhbXBsZSBJbmMxEzARBgNVBAMMCkV4YW1w -bGUgQ0ExIDAeBgkqhkiG9w0BCQEWEWFkbWluQGV4YW1wbGUub3JnMCAXDTA5MTIz -MTE2MDEyOFoYDzIxMDkxMjA3MTYwMTI4WjCBgjELMAkGA1UEBhMCQ04xEjAQBgNV -BAgMCVNvbWV3aGVyZTESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQKDAtFeGFt -cGxlIEluYzETMBEGA1UEAwwKRXhhbXBsZSBDQTEgMB4GCSqGSIb3DQEJARYRYWRt -aW5AZXhhbXBsZS5vcmcwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDA -PnXIdC5u6eCrXpQfTYwE6QwbSoxPE6kgN0CeVGqk4ya89RzmW/I6+ENw9exraeAl -xDEc2s1OSmBMeAn7b/nDiV3ik4MpQ2+5ZlmKQHYRrjfdnw/zwkcWncPX+UuTfXlx -b4PGBOF/J7HehpfCCQ9g3aXlMWYxR/A0nkFbnfy3gIX7Q0tvGmFJmYWgKxvEELOM -3qV8Jwmui+sw8SL14F+7vZgfBqjnpXfjFaSa+K63sGWLtyy7oQ7eYhpOylA3QSf7 -Hyu+lLQSnHafEys1eedD/Re+gPFUtga/f+CX111ZYDW4zud6W/V3AT1ZGrnrGmCg -k5NeEkLnxaj+GOSvd9O2pnwPSCA2mdRhhx5XxIVD3rZvfR86KflDco8D9i4jPpA0 -38QduFsYXRFS1zTVZuKSlv/bjAmwsNFb/rAS97PVcJf6UVtNkGorc2R2qGWxVDLm -lJSzv14j0swUQomb31+PzAngvB+b2HbjvFCgIb+YHu4c83Gb4tYYBYcu2VgJ0K0C -AwEAAaNTMFEwHQYDVR0OBBYEFNASTtq6TuD6opLY9NUMtneRjAicMB8GA1UdIwQY -MBaAFNASTtq6TuD6opLY9NUMtneRjAicMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI -hvcNAQEMBQADggGBAFbPTxPsNaQeAjN9J6F32l4YQFwhOWSXI/40VQHZTtWeiP87 -EOpOaeE+oboHn6EIYE7meT92vDD/JzJ6JnD0a3kVgRFWe2Wn1FOpFWVbNMzMk03P -CNYH2Vbbcsi0fDp9mFvfU9jV8+onWz363Q2M+VJ3BxnrOFpp0+NHt0mNPFN4A8/J -58eTde+QBoUUFrKmviceuHNMqG4o3IIk71LTNg6vWUU94YFLjSSoM5LqLQ2gZapg -4vFlYrEATpk/QBzATW4bRT0KLkHDroJj1iU4U5Ju4t2mXVDRtw9Ci0TLe3iD6rO+ -GPtxw5KsR4BvY9m+UORAoRSpYWGv3ZRPPz2EL9duF9rwJsjeCxiy6r4JK32R71JC -njnSImcf2QQ5MX6Kk0hMcrdkZY4oCyMQj6yk+EuI1XlK9vK4wctPS10bPRTiDzP3 -8sSoFkQegoV2FuqCAVECtSHJE6w56fvoV+wwtwn/Q9pQiJisj+wmwCRy2EYq9R1G -pFJpUlMAmEDj5r9lYg== +MIIEBzCCAu+gAwIBAgIUK8+d+8IOzeX+DP3VSvdF3lHiCdcwDQYJKoZIhvcNAQEL +BQAwgZIxCzAJBgNVBAYTAkZSMQ8wDQYDVQQIDAZSYWRpdXMxEjAQBgNVBAcMCVNv +bWV3aGVyZTEUMBIGA1UECgwLRXhhbXBsZSBJbmMxJjAkBgNVBAMMHUV4YW1wbGUg +Q2VydGlmaWNhdGUgQXV0aG9yaXR5MSAwHgYJKoZIhvcNAQkBFhFhZG1pbkBleGFt +cGxlLm9yZzAeFw0yNDEwMDgxMDI0MDZaFw0zNDEwMDYxMDI0MDZaMIGSMQswCQYD +VQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hlcmUxFDAS +BgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRl +IEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5vcmcwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWKIwjdRIp9IrpZELN/ZsN13Xj +qQI6n086PNJ7BZfLi0+tD164rmxFk2eukNNksFCPhvMkqUxouGhc4mJjeivvrZxR +oT3cblOQIkkdEci6iTKC2E1a20W/Ur7cTXoIsnKwjiUjXk+cujkrZu4fcHX+O4vy +wTd5tEbhmifT/4u5nN8U2vBcEZqkGHOCp30VZSxtlGwqp4lc+tVziF3uFViW9MXk +3bVt+s1E7ztwG7+WBgVlLYe3CNSWkMxfyYBafH/l7iep6AFjoTn1z3AAjYi7IUNN +0JkW8MTgafRQIu4QsV5luq/Tiar2vwAm/GNgUJdSzUKARsfQzb/XTIgnLQqtAgMB +AAGjUzBRMB0GA1UdDgQWBBSijSC03/Thi6EOdM91V33zsbQpgzAfBgNVHSMEGDAW +gBSijSC03/Thi6EOdM91V33zsbQpgzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQAvKEfmCDoMTKC6bfP6DSs+MSAGc5tCr6w6cz2AKNJ2fOMhkq55 +JF47oBBGm9SdTB6Jqo6c109Ps69/+LMtEEGwvzL0RL0WAuTYGo6sudm9hj/jDHZh +pAqi/2BQQeVgTa6oW0jtNPFe+/cobXo9TJ7wECGrhvVbmfl5ZPc0YVOIjjR0/LhL +q7lqPAlJ5vx0WvsX+QReN97we8vD0x1D3mCySJTi3Irh+grE0yJOSN2fa7cyqi9+ +vSiNUB1eUgQwrO+S8ZazYNvAZXC2Xf4WB4SOifJD73pYPAdwOejc0FA+zfEKa/6/ +vTUs8cIhlmDWO+BEoc9wygMKMmhT5s7/T5Bv -----END CERTIFICATE----- diff --git a/samples/net/wifi/test_certs/rsa3k/client-key.pem b/samples/net/wifi/test_certs/rsa3k/client-key.pem index 30736e963c24..6ab70da24524 100644 --- a/samples/net/wifi/test_certs/rsa3k/client-key.pem +++ b/samples/net/wifi/test_certs/rsa3k/client-key.pem @@ -1,40 +1,30 @@ ------BEGIN PRIVATE KEY----- -MIIG/gIBADANBgkqhkiG9w0BAQEFAASCBugwggbkAgEAAoIBgQCyrJdw9xFpDe39 -iBbAoMdpRPY13DpcXywQSFYnnhCGttdRKahOTSiQzP+iG1sczV0WwwFlnqgL2Jh9 -p82jwhQ+UEuG/nRas7cvKlEkEol/kdUwK9+Nvbie6kGqTZqJkwVZ6Dqpm9Kq+pTU -0eJHYu1MOtreQQDIrUvmDLbz7eQsUEKfAKPnmY8NMx/DCqNLoXzmdxjeMGCJ9b5F -++3wDblipYy/+7k11EyZn+MGdtA4Uq5dcv6H7ie1AgPsVO+3p8FbOwa/O5kaCOmf -MkxZBv0jDFBqKv84KBy66wqCj3PsH1WDsd+etxGqvFleBWUb2pamEW2+mqKPmnoZ -uJtkzYK376+s5jULFH9DvHzbwFNQI2IgXriNzYVVCTHIg1ndVFzcGKFCka1DNSma -8cAnWKP2yzr58WKS3iEZ8p12UK/nW353aP0Fz0p73zuMg8fnWrTdh13UZOKudnNq -twe1Ozo+R0e5VCIxJeQIo2MovRqRcnb6U5Yf4IXOx8gjCXnbcBcCAwEAAQKCAYEA -kyAVT9rSRkxHFUaTXajGq0My7iTbFab0tK+r6dF5UESMxnNj+J4Gcj2rngOiofPk -3FJU+yWKwL5oysd7SIYOf0VE+/LZQrrLc5YH3Ik7GYWvI4xs990qggjpa1+dif07 -Ic5dR75c2ZefKCNvjVLDjcrE4NBr4dL5NYRwvim8glTQlvdC//ltVvQrCkLfNe7S -1z9ohcUWKWPmeuA5DDtw1O73GDsiRlX7gWCr423AhTBoDeEcADg2EBGJw3gpMHR8 -HGV7U/TJRb/3hvgkGvxL2pX1EbS48qbMboTBbBvIuSGjv6JiCtAQC4o0ti3RLae4 -axd/4r/u1AkJJJtcRQUJbKMPxaQ8V0aASrVgTCanUhJHS09RCeLBx02DS4zSOkHg -4ySp82oh1rM9zK0iPIo1dcoMmm1lKSmRU2c9SJyHZ0UGRNCLVgs76qzg/nV1WSyE -1Woq61RB8Qepc2v5vSiz8QB4ljrIZtZkcTJzsAS+THeVgYeNVWTIz6rXG2Zg3pCZ -AoHBAOsP/GvNSKykm8dtjRXBtjLpahPtKmOpUR2cptdfuGAIbnaANCXr8oYrLNsz -y4CmWgiTcnO7+c03oT1q8iYe50FvFw6g1xy5F1M/4av5RiPz3rEm8J+lRskC4+RR -+m8VdTF11HCIEw7um+CwPqluDq1DNLdAudIA0lyjhsHkFo+yWcJyrBKW4r2wzgwP -QP6dH3hbvcU1cvKgbj9dbshFR+FG4U4KuV/AsMEtFpEj+Uh/gfnJO6cVnFz7/1vt -iQEFPQKBwQDCls/HyCzYnXmoMvqS+DSBDliwKpGBCd6RuvwrNPJlR1GI38iaSf2t -Vu7PpabQx/uJIwTg5zzv8kVR8pXOwUlL/GcvMcoN7/hauKh7JcOlD1bQ6fPJMcHc -OOFG1JlaLcsW9o075mz/FmpvGF4s+uDPDGE5xFfeYb0E4/N7j5zvOAZJGll6BwIR -snufXR3/JW9lxdrFawqNMSRRG9Y9IkSJfLMQ+1LAY8QviOjjoUdEh0NYfsis+VpV -7/AfMKQ9p+MCgcEAmNRx990mrSjxJ76whj7GKV/dWktOzjFdzfT1/P39MGMK/vzn -6uf3bQhRR8vrOh/uVbkYJutGxQiwSvBntCVPkhmaUiZ89e3ZnoTgQyH1WpbKaT+6 -HvIkjbjVVrN+Mg8vfRLxJqEyUvkMXA/7DcnCvR/+/E6XAlUKcLTZfuK/UHpTJbvM -6OE1VsPHk8uvJFwgA+8R+VCBBgMM6yHiT0/MJkohXs5WLE1qHo8kJwXOpDZS2Ybe -xAmm+kXVh31vIDy5AoHAb4n+5CeL/UaW+6DtHN2FSwysLZ7Y9LxxhdtGvIWHBCLT -S7/qvvX2oSuZjBEKA9b+Cee23ivuNCQNNCH3WSJWH2Y4x0ak6URKecYrXRuSf8TB -INNZ2FPbKZ65Et6+YICrTyhYYKN+iuGQdMnlAad0wXn5KSGwtFoV/P2lDYiOjljw -0Wp3K4lk2DwUvI6lqSEOL6ov8sWesLwgcxWfwj8oRh7ijbNiBcGqLQ0vYXuK3G8k -XU+fO/danrQAUgCRxH29AoHAaobHyG4zSt0srMlV1qe+txcJF7fiyMg3VYGeWlZk -vUNsJjAjH1WvqgxOynN2L4/d5TIPUzrJehrwO+maP8f6UU6X181zQdBhWi3zyEaZ -rvQtoNwwoVL9+sY1/FRIW3dEyJ1+V0mbUi+td8Ygtt7Dy9/15RKLgO4oARUDOiMn -iPbd8ee/e5Zh2esjP6f+cjFMKgwVllO1VaTC5MJhUFAGJxUoMwCr/PFacNRXbyLr -7Rwf2QE670one3F+5w5mGkax ------END PRIVATE KEY----- +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQILVdWyEWhWU0CAggA +MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDMFReIusCg7gSkoUQZV2flBIIE +0BIFQH7+0dc7wHIQQ1y0ao90rrK3ExtCABH6xp4OAHUNPR1549zSEak/9Ba6WLBp +YE0m/lpLz4oUJE4Kd3rg4ekSZk4mapZoW7g5ax4qAEblmM6rqmyjiU0Q6tsAb8n1 +x+RyjUILlgTH1HDmeNA53QNMCw++xIMIJPN29SvFN6vkU2Fd2f74/TuZRSaCEPLO +LKtNMwWCMTrlv0UewEryOvZegPQuEF/Ewmmw/9l5VfkPp6zAtZKzWsfk4jUo5tv2 +5dPoHR+RKjNNVwetnCq59QYMS2My6KLqX4Vzqnbu8K1nlbm85ZHnvLGi8cDn8EB7 +QtRL+Ev5IwcwYJgV5AMojouJLQdR655jeITWI1Gsohz28YG8c1qYX4ZN6albSd1G +fd1tMOWkeu4uEzJ7ijLDfnCzrklnLuAZx8yLzyrOa7i9AwwJmdgUEdbWWsru3L6C +zDJ45rpA0FobdlTem4kpoE9yiyHkIhf3wmI3X+0aodC11pdbHP260KIC8E1K9FUh +s/IoEQCYrBp8UltNTlezwq/E5uOuIu4EpfjEgH1Z3+hSDbnmMAXNX4DbL234x7iy +3Y256DtOeHSElnRz3kDnZVNtM1Kd5fgEYJ1ptYRPYaWyJka7/hC/0UObuM9w+QeO +OlG0QgumQFloyhDa9anPBK4sYJp4g1fK8golUDW4AdpFPNOJvvgOvQUzhPpHjr+N +lpZ75Y6I3JSSKJ/UMlSCOqjak8oZtMtJNMfbx1lgwwDtgjDSJvSdl735gI9VmXXH +qnlGEtyiQ7k1Z1a4HxiY2/CiDHvkymClir/Ik8gt+wmyT9c/9BcehLRf6PxMsDVy +PCkty1LlzN+5tSZJtJnOiTlgsRn/w49Ohp74ITheSdb30/6PnFI+o8rcJHmrjN4d +t3z/bCyWAeC8mS7m0wtXlyBeG9xvdyT8dDHAFOnqxX30dEwEbjNj58kWGAgRf9i3 +HlOAP8yRy7LAV7A4HEPnEzXBxYpsROUw/8d3Jtmr2nAp2hfKP339DYZPHZpRLjJr +WQlJasHHLxHKKjSsuM06WsCO+Tt2FTSgGJuU6nFVK75fssmmJYzj9qMHVM6YSjfY +sT0ZIWRgO9NLFx5O3QxY1wgMLhhv1FREy9NVnMU0W3A1u0F7dwHywZGha2IqEXgu ++UyWIJnePMvluV/s66AN/OpIxKU48c0B4l7XzXkHHd43tDUG3ztfRuPbWCHipuRO +eo+vHGD01iBLSE1ZhrYLHKQhJvIKx/PIEaqJHP/Vy35AD/2/GH09TiIBHzX9aXie +TiKFs30FQv7SpLNHNE7jUxsYGNUbYa70S/Vgn3wkKATcXpCc749XQV4OUbFoqkDm +vuZOjkIOlm/OtZkUuDWmk96mgoVG/gWSEJPynJHUpmWdu/BCdYOgxBk/bmPa1leS +Z5NbO0fGMnNhDMXYA5rqmVzABcNSYhgYw5aciWpBlgYHEYrPxZvCxWftIyb24oEk +wdHEaFbIYbOoVZqo7Ym2hrvVrJb8Qdukf1BmUgfSSSc7BFoSrBUO4SNFtZI55NOB +OM4rnkqfoYR0IpnxzPIpxpsWljG9QsgnTaffStDgIGXiAtBWJFy+44f1IS4EoC6B ++we1Q6atPwYSyPtG8mn4Ce0BNxLDUoFDLMQ7Bt8QBMeX +-----END ENCRYPTED PRIVATE KEY----- diff --git a/samples/net/wifi/test_certs/rsa3k/client-key2.pem b/samples/net/wifi/test_certs/rsa3k/client-key2.pem index 30736e963c24..6ab70da24524 100644 --- a/samples/net/wifi/test_certs/rsa3k/client-key2.pem +++ b/samples/net/wifi/test_certs/rsa3k/client-key2.pem @@ -1,40 +1,30 @@ ------BEGIN PRIVATE KEY----- -MIIG/gIBADANBgkqhkiG9w0BAQEFAASCBugwggbkAgEAAoIBgQCyrJdw9xFpDe39 -iBbAoMdpRPY13DpcXywQSFYnnhCGttdRKahOTSiQzP+iG1sczV0WwwFlnqgL2Jh9 -p82jwhQ+UEuG/nRas7cvKlEkEol/kdUwK9+Nvbie6kGqTZqJkwVZ6Dqpm9Kq+pTU -0eJHYu1MOtreQQDIrUvmDLbz7eQsUEKfAKPnmY8NMx/DCqNLoXzmdxjeMGCJ9b5F -++3wDblipYy/+7k11EyZn+MGdtA4Uq5dcv6H7ie1AgPsVO+3p8FbOwa/O5kaCOmf -MkxZBv0jDFBqKv84KBy66wqCj3PsH1WDsd+etxGqvFleBWUb2pamEW2+mqKPmnoZ -uJtkzYK376+s5jULFH9DvHzbwFNQI2IgXriNzYVVCTHIg1ndVFzcGKFCka1DNSma -8cAnWKP2yzr58WKS3iEZ8p12UK/nW353aP0Fz0p73zuMg8fnWrTdh13UZOKudnNq -twe1Ozo+R0e5VCIxJeQIo2MovRqRcnb6U5Yf4IXOx8gjCXnbcBcCAwEAAQKCAYEA -kyAVT9rSRkxHFUaTXajGq0My7iTbFab0tK+r6dF5UESMxnNj+J4Gcj2rngOiofPk -3FJU+yWKwL5oysd7SIYOf0VE+/LZQrrLc5YH3Ik7GYWvI4xs990qggjpa1+dif07 -Ic5dR75c2ZefKCNvjVLDjcrE4NBr4dL5NYRwvim8glTQlvdC//ltVvQrCkLfNe7S -1z9ohcUWKWPmeuA5DDtw1O73GDsiRlX7gWCr423AhTBoDeEcADg2EBGJw3gpMHR8 -HGV7U/TJRb/3hvgkGvxL2pX1EbS48qbMboTBbBvIuSGjv6JiCtAQC4o0ti3RLae4 -axd/4r/u1AkJJJtcRQUJbKMPxaQ8V0aASrVgTCanUhJHS09RCeLBx02DS4zSOkHg -4ySp82oh1rM9zK0iPIo1dcoMmm1lKSmRU2c9SJyHZ0UGRNCLVgs76qzg/nV1WSyE -1Woq61RB8Qepc2v5vSiz8QB4ljrIZtZkcTJzsAS+THeVgYeNVWTIz6rXG2Zg3pCZ -AoHBAOsP/GvNSKykm8dtjRXBtjLpahPtKmOpUR2cptdfuGAIbnaANCXr8oYrLNsz -y4CmWgiTcnO7+c03oT1q8iYe50FvFw6g1xy5F1M/4av5RiPz3rEm8J+lRskC4+RR -+m8VdTF11HCIEw7um+CwPqluDq1DNLdAudIA0lyjhsHkFo+yWcJyrBKW4r2wzgwP -QP6dH3hbvcU1cvKgbj9dbshFR+FG4U4KuV/AsMEtFpEj+Uh/gfnJO6cVnFz7/1vt -iQEFPQKBwQDCls/HyCzYnXmoMvqS+DSBDliwKpGBCd6RuvwrNPJlR1GI38iaSf2t -Vu7PpabQx/uJIwTg5zzv8kVR8pXOwUlL/GcvMcoN7/hauKh7JcOlD1bQ6fPJMcHc -OOFG1JlaLcsW9o075mz/FmpvGF4s+uDPDGE5xFfeYb0E4/N7j5zvOAZJGll6BwIR -snufXR3/JW9lxdrFawqNMSRRG9Y9IkSJfLMQ+1LAY8QviOjjoUdEh0NYfsis+VpV -7/AfMKQ9p+MCgcEAmNRx990mrSjxJ76whj7GKV/dWktOzjFdzfT1/P39MGMK/vzn -6uf3bQhRR8vrOh/uVbkYJutGxQiwSvBntCVPkhmaUiZ89e3ZnoTgQyH1WpbKaT+6 -HvIkjbjVVrN+Mg8vfRLxJqEyUvkMXA/7DcnCvR/+/E6XAlUKcLTZfuK/UHpTJbvM -6OE1VsPHk8uvJFwgA+8R+VCBBgMM6yHiT0/MJkohXs5WLE1qHo8kJwXOpDZS2Ybe -xAmm+kXVh31vIDy5AoHAb4n+5CeL/UaW+6DtHN2FSwysLZ7Y9LxxhdtGvIWHBCLT -S7/qvvX2oSuZjBEKA9b+Cee23ivuNCQNNCH3WSJWH2Y4x0ak6URKecYrXRuSf8TB -INNZ2FPbKZ65Et6+YICrTyhYYKN+iuGQdMnlAad0wXn5KSGwtFoV/P2lDYiOjljw -0Wp3K4lk2DwUvI6lqSEOL6ov8sWesLwgcxWfwj8oRh7ijbNiBcGqLQ0vYXuK3G8k -XU+fO/danrQAUgCRxH29AoHAaobHyG4zSt0srMlV1qe+txcJF7fiyMg3VYGeWlZk -vUNsJjAjH1WvqgxOynN2L4/d5TIPUzrJehrwO+maP8f6UU6X181zQdBhWi3zyEaZ -rvQtoNwwoVL9+sY1/FRIW3dEyJ1+V0mbUi+td8Ygtt7Dy9/15RKLgO4oARUDOiMn -iPbd8ee/e5Zh2esjP6f+cjFMKgwVllO1VaTC5MJhUFAGJxUoMwCr/PFacNRXbyLr -7Rwf2QE670one3F+5w5mGkax ------END PRIVATE KEY----- +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQILVdWyEWhWU0CAggA +MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDMFReIusCg7gSkoUQZV2flBIIE +0BIFQH7+0dc7wHIQQ1y0ao90rrK3ExtCABH6xp4OAHUNPR1549zSEak/9Ba6WLBp +YE0m/lpLz4oUJE4Kd3rg4ekSZk4mapZoW7g5ax4qAEblmM6rqmyjiU0Q6tsAb8n1 +x+RyjUILlgTH1HDmeNA53QNMCw++xIMIJPN29SvFN6vkU2Fd2f74/TuZRSaCEPLO +LKtNMwWCMTrlv0UewEryOvZegPQuEF/Ewmmw/9l5VfkPp6zAtZKzWsfk4jUo5tv2 +5dPoHR+RKjNNVwetnCq59QYMS2My6KLqX4Vzqnbu8K1nlbm85ZHnvLGi8cDn8EB7 +QtRL+Ev5IwcwYJgV5AMojouJLQdR655jeITWI1Gsohz28YG8c1qYX4ZN6albSd1G +fd1tMOWkeu4uEzJ7ijLDfnCzrklnLuAZx8yLzyrOa7i9AwwJmdgUEdbWWsru3L6C +zDJ45rpA0FobdlTem4kpoE9yiyHkIhf3wmI3X+0aodC11pdbHP260KIC8E1K9FUh +s/IoEQCYrBp8UltNTlezwq/E5uOuIu4EpfjEgH1Z3+hSDbnmMAXNX4DbL234x7iy +3Y256DtOeHSElnRz3kDnZVNtM1Kd5fgEYJ1ptYRPYaWyJka7/hC/0UObuM9w+QeO +OlG0QgumQFloyhDa9anPBK4sYJp4g1fK8golUDW4AdpFPNOJvvgOvQUzhPpHjr+N +lpZ75Y6I3JSSKJ/UMlSCOqjak8oZtMtJNMfbx1lgwwDtgjDSJvSdl735gI9VmXXH +qnlGEtyiQ7k1Z1a4HxiY2/CiDHvkymClir/Ik8gt+wmyT9c/9BcehLRf6PxMsDVy +PCkty1LlzN+5tSZJtJnOiTlgsRn/w49Ohp74ITheSdb30/6PnFI+o8rcJHmrjN4d +t3z/bCyWAeC8mS7m0wtXlyBeG9xvdyT8dDHAFOnqxX30dEwEbjNj58kWGAgRf9i3 +HlOAP8yRy7LAV7A4HEPnEzXBxYpsROUw/8d3Jtmr2nAp2hfKP339DYZPHZpRLjJr +WQlJasHHLxHKKjSsuM06WsCO+Tt2FTSgGJuU6nFVK75fssmmJYzj9qMHVM6YSjfY +sT0ZIWRgO9NLFx5O3QxY1wgMLhhv1FREy9NVnMU0W3A1u0F7dwHywZGha2IqEXgu ++UyWIJnePMvluV/s66AN/OpIxKU48c0B4l7XzXkHHd43tDUG3ztfRuPbWCHipuRO +eo+vHGD01iBLSE1ZhrYLHKQhJvIKx/PIEaqJHP/Vy35AD/2/GH09TiIBHzX9aXie +TiKFs30FQv7SpLNHNE7jUxsYGNUbYa70S/Vgn3wkKATcXpCc749XQV4OUbFoqkDm +vuZOjkIOlm/OtZkUuDWmk96mgoVG/gWSEJPynJHUpmWdu/BCdYOgxBk/bmPa1leS +Z5NbO0fGMnNhDMXYA5rqmVzABcNSYhgYw5aciWpBlgYHEYrPxZvCxWftIyb24oEk +wdHEaFbIYbOoVZqo7Ym2hrvVrJb8Qdukf1BmUgfSSSc7BFoSrBUO4SNFtZI55NOB +OM4rnkqfoYR0IpnxzPIpxpsWljG9QsgnTaffStDgIGXiAtBWJFy+44f1IS4EoC6B ++we1Q6atPwYSyPtG8mn4Ce0BNxLDUoFDLMQ7Bt8QBMeX +-----END ENCRYPTED PRIVATE KEY----- diff --git a/samples/net/wifi/test_certs/rsa3k/client.pem b/samples/net/wifi/test_certs/rsa3k/client.pem index 16397db7756c..9e815474cd8d 100644 --- a/samples/net/wifi/test_certs/rsa3k/client.pem +++ b/samples/net/wifi/test_certs/rsa3k/client.pem @@ -1,26 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIEaDCCAtACAQEwDQYJKoZIhvcNAQEMBQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYD -VQQIDAlTb21ld2hlcmUxEjAQBgNVBAcMCVNvbWV3aGVyZTEUMBIGA1UECgwLRXhh -bXBsZSBJbmMxEzARBgNVBAMMCkV4YW1wbGUgQ0ExIDAeBgkqhkiG9w0BCQEWEWFk -bWluQGV4YW1wbGUub3JnMCAXDTA5MTIzMTE2MDM1MVoYDzIxMDkxMjA3MTYwMzUx -WjBvMQswCQYDVQQGEwJDTjESMBAGA1UECAwJU29tZXdoZXJlMRQwEgYDVQQKDAtF -eGFtcGxlIEluYzEVMBMGA1UEAwwMRXhhbXBsZSBVc2VyMR8wHQYJKoZIhvcNAQkB -FhB1c2VyQGV4YW1wbGUub3JnMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKC -AYEAsqyXcPcRaQ3t/YgWwKDHaUT2Ndw6XF8sEEhWJ54QhrbXUSmoTk0okMz/ohtb -HM1dFsMBZZ6oC9iYfafNo8IUPlBLhv50WrO3LypRJBKJf5HVMCvfjb24nupBqk2a -iZMFWeg6qZvSqvqU1NHiR2LtTDra3kEAyK1L5gy28+3kLFBCnwCj55mPDTMfwwqj -S6F85ncY3jBgifW+Rfvt8A25YqWMv/u5NdRMmZ/jBnbQOFKuXXL+h+4ntQID7FTv -t6fBWzsGvzuZGgjpnzJMWQb9IwxQair/OCgcuusKgo9z7B9Vg7HfnrcRqrxZXgVl -G9qWphFtvpqij5p6GbibZM2Ct++vrOY1CxR/Q7x828BTUCNiIF64jc2FVQkxyINZ -3VRc3BihQpGtQzUpmvHAJ1ij9ss6+fFikt4hGfKddlCv51t+d2j9Bc9Ke987jIPH -51q03Ydd1GTirnZzarcHtTs6PkdHuVQiMSXkCKNjKL0akXJ2+lOWH+CFzsfIIwl5 -23AXAgMBAAEwDQYJKoZIhvcNAQEMBQADggGBACYMd24RQJEdzLqmG3mQ7zLbCWS3 -grla+4o1qsWtkS+SZDWdDb0rgkB7ZmBoPklhpHPIWe8ijkPzjdIu2y5kopyM3+ey -GkJL3nF7xIleayN052dEhrkWiZcFEM84z2yVflhEdfs42PyQbxlMLf1RFcsLkuYG -yubuoT03+S2xvdfYEOqiSROYsKNMB6ZyXc4N/HtdYjf+fgYXc4vp6vZAT1Y6HAEK -IDppcggfn6y16fczU8g3SLkfnYOzOgJYi2EqcbetsjvNwXHpI3JWeei63rIxv/yh -UctQue5iv9esiLvRsNmAPA5D99YO3gAovdSRNRhTbXYDSa8jkRFFLJ/VPiR9nSYS -w2n+ZYPR3/i0c4gh+lDBIF6QZ49c+sFdAOs0awUM+AeyFyzXpYliF0d/Jh34kLtU -0tmu3HxxU+mBFFElK70NVIdtJ99/D5fJAiP3RHOBpXp2K3mqTgvBxqHpMpNUa0ZO -qKKoZvp6M764d8ccNQJpbCbHsxr9U0rDa/vdxg== +MIIDojCCAooCFGZ4UJXBKG70aewILFtsy4mbvaYZMA0GCSqGSIb3DQEBCwUAMIGS +MQswCQYDVQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hl +cmUxFDASBgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRp +ZmljYXRlIEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5v +cmcwHhcNMjQxMDA4MTAyNjI1WhcNMzQxMDA2MTAyNjI1WjCBhzELMAkGA1UEBhMC +RlIxDzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQK +DAtFeGFtcGxlIEluYzEbMBkGA1UEAwwSY2xpZW50LmV4YW1wbGUub3JnMSAwHgYJ +KoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLm9yZzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAMu3HXJvi2Q4hQnLL4v/sCyEr5x+ZtBcSi2yETMViaf2EStW +UOs1A1pmCQbO7nadLQcWaX4tzefQCRrs1X4hIQuDIqRPNi6h6G1g5HEtqBWZhvwu +hDbmFiX8/Vtw/P0/9sox2DzyLG0mjJUAYAbKtyC1kQalybVBtrSaazyyAyh6oOuU +chAb7SmmNDsRB959TWM/mp+6yCcFGzCDKNBwlwthB6Uw92d3SfOyXEnZm8rPf0hV +4ICL5iB+xEYBv1LKmznFK/4UAyKpxAygc5fxKVWwlSsq8MrES5ak0n6H71wViaXK +BrH5yh9jEkK9XSeaUwg8C9eOOexyx/5JDY3TTE8CAwEAATANBgkqhkiG9w0BAQsF +AAOCAQEAUNddNiRUlJH0acJJv8ztXNWjNewd17tAk1BBHp6yyGAD8b52p6QbDAdS +xO3WsSc2bqSy599jp4GshO27TMQsBRMfoggCG21Aj6sIs0Hd4shTE4T0GUBEBxC2 +/HReuD+cGIzzKMYlvK8RPSaGLPvPw5SryvmOnjD368V0KCHwT04Z14i4sMxlkd5q +wB7fxTkVla9MR4uWObX62mJykmqT86chScJpldtBpRh8wrEa3Gt9FZoi/eqP0De8 +oCxmCZDrozGTZ4IIaNzchx3Ensh1RQwvvxd6ATerYdUjq4V2TlTksDRdCXtj+uNJ +FnB32sUHiIouxudAsqDf8UL9/99RCw== -----END CERTIFICATE----- diff --git a/samples/net/wifi/test_certs/rsa3k/client2.pem b/samples/net/wifi/test_certs/rsa3k/client2.pem index 16397db7756c..9e815474cd8d 100644 --- a/samples/net/wifi/test_certs/rsa3k/client2.pem +++ b/samples/net/wifi/test_certs/rsa3k/client2.pem @@ -1,26 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIEaDCCAtACAQEwDQYJKoZIhvcNAQEMBQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYD -VQQIDAlTb21ld2hlcmUxEjAQBgNVBAcMCVNvbWV3aGVyZTEUMBIGA1UECgwLRXhh -bXBsZSBJbmMxEzARBgNVBAMMCkV4YW1wbGUgQ0ExIDAeBgkqhkiG9w0BCQEWEWFk -bWluQGV4YW1wbGUub3JnMCAXDTA5MTIzMTE2MDM1MVoYDzIxMDkxMjA3MTYwMzUx -WjBvMQswCQYDVQQGEwJDTjESMBAGA1UECAwJU29tZXdoZXJlMRQwEgYDVQQKDAtF -eGFtcGxlIEluYzEVMBMGA1UEAwwMRXhhbXBsZSBVc2VyMR8wHQYJKoZIhvcNAQkB -FhB1c2VyQGV4YW1wbGUub3JnMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKC -AYEAsqyXcPcRaQ3t/YgWwKDHaUT2Ndw6XF8sEEhWJ54QhrbXUSmoTk0okMz/ohtb -HM1dFsMBZZ6oC9iYfafNo8IUPlBLhv50WrO3LypRJBKJf5HVMCvfjb24nupBqk2a -iZMFWeg6qZvSqvqU1NHiR2LtTDra3kEAyK1L5gy28+3kLFBCnwCj55mPDTMfwwqj -S6F85ncY3jBgifW+Rfvt8A25YqWMv/u5NdRMmZ/jBnbQOFKuXXL+h+4ntQID7FTv -t6fBWzsGvzuZGgjpnzJMWQb9IwxQair/OCgcuusKgo9z7B9Vg7HfnrcRqrxZXgVl -G9qWphFtvpqij5p6GbibZM2Ct++vrOY1CxR/Q7x828BTUCNiIF64jc2FVQkxyINZ -3VRc3BihQpGtQzUpmvHAJ1ij9ss6+fFikt4hGfKddlCv51t+d2j9Bc9Ke987jIPH -51q03Ydd1GTirnZzarcHtTs6PkdHuVQiMSXkCKNjKL0akXJ2+lOWH+CFzsfIIwl5 -23AXAgMBAAEwDQYJKoZIhvcNAQEMBQADggGBACYMd24RQJEdzLqmG3mQ7zLbCWS3 -grla+4o1qsWtkS+SZDWdDb0rgkB7ZmBoPklhpHPIWe8ijkPzjdIu2y5kopyM3+ey -GkJL3nF7xIleayN052dEhrkWiZcFEM84z2yVflhEdfs42PyQbxlMLf1RFcsLkuYG -yubuoT03+S2xvdfYEOqiSROYsKNMB6ZyXc4N/HtdYjf+fgYXc4vp6vZAT1Y6HAEK -IDppcggfn6y16fczU8g3SLkfnYOzOgJYi2EqcbetsjvNwXHpI3JWeei63rIxv/yh -UctQue5iv9esiLvRsNmAPA5D99YO3gAovdSRNRhTbXYDSa8jkRFFLJ/VPiR9nSYS -w2n+ZYPR3/i0c4gh+lDBIF6QZ49c+sFdAOs0awUM+AeyFyzXpYliF0d/Jh34kLtU -0tmu3HxxU+mBFFElK70NVIdtJ99/D5fJAiP3RHOBpXp2K3mqTgvBxqHpMpNUa0ZO -qKKoZvp6M764d8ccNQJpbCbHsxr9U0rDa/vdxg== +MIIDojCCAooCFGZ4UJXBKG70aewILFtsy4mbvaYZMA0GCSqGSIb3DQEBCwUAMIGS +MQswCQYDVQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hl +cmUxFDASBgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRp +ZmljYXRlIEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5v +cmcwHhcNMjQxMDA4MTAyNjI1WhcNMzQxMDA2MTAyNjI1WjCBhzELMAkGA1UEBhMC +RlIxDzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQK +DAtFeGFtcGxlIEluYzEbMBkGA1UEAwwSY2xpZW50LmV4YW1wbGUub3JnMSAwHgYJ +KoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLm9yZzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAMu3HXJvi2Q4hQnLL4v/sCyEr5x+ZtBcSi2yETMViaf2EStW +UOs1A1pmCQbO7nadLQcWaX4tzefQCRrs1X4hIQuDIqRPNi6h6G1g5HEtqBWZhvwu +hDbmFiX8/Vtw/P0/9sox2DzyLG0mjJUAYAbKtyC1kQalybVBtrSaazyyAyh6oOuU +chAb7SmmNDsRB959TWM/mp+6yCcFGzCDKNBwlwthB6Uw92d3SfOyXEnZm8rPf0hV +4ICL5iB+xEYBv1LKmznFK/4UAyKpxAygc5fxKVWwlSsq8MrES5ak0n6H71wViaXK +BrH5yh9jEkK9XSeaUwg8C9eOOexyx/5JDY3TTE8CAwEAATANBgkqhkiG9w0BAQsF +AAOCAQEAUNddNiRUlJH0acJJv8ztXNWjNewd17tAk1BBHp6yyGAD8b52p6QbDAdS +xO3WsSc2bqSy599jp4GshO27TMQsBRMfoggCG21Aj6sIs0Hd4shTE4T0GUBEBxC2 +/HReuD+cGIzzKMYlvK8RPSaGLPvPw5SryvmOnjD368V0KCHwT04Z14i4sMxlkd5q +wB7fxTkVla9MR4uWObX62mJykmqT86chScJpldtBpRh8wrEa3Gt9FZoi/eqP0De8 +oCxmCZDrozGTZ4IIaNzchx3Ensh1RQwvvxd6ATerYdUjq4V2TlTksDRdCXtj+uNJ +FnB32sUHiIouxudAsqDf8UL9/99RCw== -----END CERTIFICATE----- diff --git a/samples/net/wifi/test_certs/rsa3k/server-key.pem b/samples/net/wifi/test_certs/rsa3k/server-key.pem index 5eb00d2476d5..5f032cad701d 100644 --- a/samples/net/wifi/test_certs/rsa3k/server-key.pem +++ b/samples/net/wifi/test_certs/rsa3k/server-key.pem @@ -1,40 +1,30 @@ ------BEGIN PRIVATE KEY----- -MIIG/wIBADANBgkqhkiG9w0BAQEFAASCBukwggblAgEAAoIBgQDeiBjDByOPbWRo -bRzULnUJrAGHj4F3JSdu4DCtC5cUsEVxVGoWuZwUJ+eUJiMN9JvIvRsCSSFxoZOg -R8kldU8fsrQ/AFeYMcV+PSeHCwHVe6fM8zL8Iv+ilNy7Jxtslg+dueK2pnQG54Ia -VEKYY+Xhg068PmISaym6D+i4eWFUiqE5bOHWlp53Rz51UbaAy7gxoeDv4oIfwhzI -GjgeFUSGclTNeXD7QcsowW1R3h5lT3MUIxi6FmHiz4laDZVets8vRwvxGKdtSxAu -m/JlbFhvypyp1lJK/DPAlyMC6zuhudZKPxnSByJ/ejczcmUtILbHPp9CGEPs5+26 -vJQjJ4HTGQOefJGQzwj1oHWOkcPft4m2KJn6/GWhJLcUwwRuZB/XblVWJ99Gg6pg -C8ju52O4Akrv96CbzApwGRSxuZ2QugUe3pbiMiclFLiig9qmAmQOKrpTVHshnI1R -KHM2MdyWYQ5uDMN9nrvV6VLS7eDX8dfsaD3ZyywQungSXNADBJUCAwEAAQKCAYEA -tKCr2MJWrvkQY2MN33zGK0+e/jYR1HAoDeuUFyItQ/HArDjk1AVdF088vhgmpBFE -0jANWFGb/+wzNAqQzwLlcslPXUQd1b+wmsNw7kCVAIAauFU/sUGHVqSWdqNLs1wq -2NAlojSCQYhxJoX2eFO+KMq4gjvwxxqNCCYZtINx6XmNXFtxBQnFHvSJUhk9llXF -8SOAvbaSAM1DJ3mAy4pf0PHEu/QzLP8+tJos7iLpcTqIInRKgeHhGoVy69HSyMqA -5lfGvaL1YjbLFEGOqE215uVB2PsRLuZbyHKDeKEdSD8uwyNCOSfg+MJ1sQLG0UNR -wU/1ltXM24MSz6upvse4AfoHTx9zv2Gpc7BfyYj3m6C9cxQjSZ0GJ5XK9drJMkcj -5u1G2o9nSp/48pSfYLGLrIHLf74fh6OdGyK1xplcl/VwdZFzcdBh5CxPnosdtJyM -cdHmprqnODrE3tsPUlZ+MNtalN9stpIKgtjVq8wzMIjxeIrrmw8aGoHyPbWUd1UR -AoHBAPAGwO1ZZ0JflMYk0HmCmAezBLn/SFxrvzXH1V+DXRLOnxE7xh9/7fKmEpL6 -wNzfB5o45kxVFSel9TQxERIEGitDkCTEJThwpHVaZT+DoREKGC7xToosXalsLTUv -9IFrYgeru1g+L9UeXUkrqETi9sBppD3OnWsCJyLZAFatDQrSmLIxPGcMseyMMmDD -bzhUzLmoGzsQC+/GhWmLwylYRlzuZIvEoqwCGhQdP74B1UFcsvHZsufFO1oMxiSp -fifD3wKBwQDtV0qB4Z2oO9LTLpEeCYWif9h4S7ghihIbDhOV8o2lUrTGxr3z93Bz -ojyEoVZVVAO8dj3TiiXQLCtK77fqHMUG76S/stO4kj81Sa9ltVULvEeafxWNfjPL -xjtlAQogXcqLee0EGa9RVFglREEhvsJ7rgSlSy8XIhELdMfLOHAtbFb8OzLZhxzE -MpN8n3aTQvtgwswY5XKWhV6xdp7uPAHfAYlezCwviVat70x7G+eRmKhPtwsKsCib -ST9HnbYVpgsCgcEAuqoV6b/ojPa2Ra4lrwm/3+T53QhKJw3oQxPovYH0pQapMAbT -WnXsABPlSAbYbCzKxcZQW7ajYBUxb2hlRSSJkXHWrLEZ3R3E2Dr3mIBuh0jZa9Bf -6xb7tCGbusxTkz6Gmz6T0Nlz64LUu23HS+NSUGsXvrVrOOgQtYobOE0WYn9LHvEp -b16xFCwnlZcHbMCOAihZHQKqtcsmv+FgYkvzVJxU91lxxOFRlKj2hHb6eP11cJ6E -ArkhIjPi+GoT4SrzAoHAUdHy9J2T3UhqYLU//+vmbuPF+4qW+rD/luYeaGYK4MCH -Y7NmDrHxyVtXo51/BsGE3DajD8cjTAW+EwJbE9FBNyfsUs3SYWHBepxhZB3EKNyK -jr9a7cFhF9HJ7gMSu5+50KWCyRQVtWLvVEGYdoqtvzd5kIY/wKjU2W8z5WIagf5E -aoX5/LWwfA63e5H5rcC8qlndRIPtIejugR1Uoup69qcv9UdLwEOHZ0UEx7gR98Z5 -16lRnCiohwgUUZsUB5iLAoHBAIn1lfEQF4veH1gL/qaxggAMQxyjvG012fpj8mLA -r19y04JkuuR8HrjKQkdqFtCS2J2pnHruOzgSe1SS+Q0MY4smMdai98tWYRfced/r -Vu/LswfH60Fk7DGwh8HKTHVOePPvHXXxb1Ue7H1Wj9ef7+eEvLCSGfz9XXXALhMQ -kEjs8+NuLtijpE/h3mtkidhcDm77CuYSfmca3Glxbp8NnLUv//qLGECtq6bU+uLP -vBFFJRssGjlvHzD+5NCTaWwScg== ------END PRIVATE KEY----- +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIjI78fcZSH7oCAggA +MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDfF676hRrL290F0MgMDZiuBIIE +0Hkz7skRV8Ox0SoX5N8GsOPfN4PS1cLyHgokY6dUhJPU5vUzOn9iSiGQSEzSguQ7 +11mssjRC2T45wB/95VK2EPtRw1f/6VOUR6RJnnGb0PV1Rydp/x5TZ6vzcXpakqly +eljJR/20fIJClsZzhw0iu5la9fkF6G8WYFEkqex5jALSiN4qVLvkiqcTnh5+amem +8+OCKgvgooKD2ids4/0GGfJRQSC6DFf3kuxNl+MMvmDXmz/vrD85ONnyXzKXDA3N +3vRgL/YT6GzwIXb+7/c/tIMpnacxPAdbNOs3DY5ss4xcK68L5PwpM2BljzBa5dGw +Smgf2VRaYRVzmrte5j280QjfrlHRU2cHaxm0GCu2AOTGwMXcSNYMXfDNuxc57oQJ +vHXMeZD4K5lACbhYdZ5lJNFvv29YI7dZ7QOGu6nXlAuhZfbdc/cgT0som7eG8xpT +pERllhQ5ych9sP9nAccN6VUsWgmlF73lbSptBek1ccYkp9LIYCteJUPl2qPcz6zl +A7zrZ54f3Lg0fOm2pCtg+qKBiw1nd3MR/YbRCgyvudyZE2cCN/ZspWqxsavbGYOz +JOfIFNnyAcOYtEv1n1BGLfMa1THW2bDV8XmHVHUtM0k4z250QAmLygWLY2166iUF +qotBkvctKKdulzGdT4nVer1UEKTqcxhDf0dRiHN5spZtFrOee0uGIoQWHt2oecaK +pJovW+i0qO/1DG5spfU2m1bz6jR2u6nxi340oRrMSoe1ELVg3l1/wmM8yzh07GuK +pshzxwqAG/FnaKCvcKGUG2EfnAvOcbMgSa2w3GvyRkcDPn00arvX9nuXj0gkRDBi +eoVMkKKTeeYSGQ4ik+ja3xkgHcxh5W8aoezLvBbmUq206cmhLwfnYMhnvFTs6EBK +E0ENpCHwF/qoVBIzRCijG/eeCuf3a1YkJsWlvEeVrPeOmDFeDft3SSGOzHxE2A/7 +HWmHbWTm7dPOfgsU4zf+HglnBjN3kYU7StyM0EGxmB4lfB2BiWiL/3R13ERHQZfa +oOqa4/hOFXOXfTQk6ufXtBx8L9BemBqh36zbs2xVvIizJKeRMruoRblWZkHhUKR8 +K5GA7FYkU9ZPPP0UPKsO94xzwfbevi+7nWeUZoqcqAUy8Jt5aD2QpvFVbPBBOz17 +PGaubeVn/Ry8swPvkpddtmJ4mgF+3SVctmzY+EE/oN1XS8wa+XeuaThzk89Lvrfa +606nRWrNw3PSKjYoEEtRLhPeJCi9uOVenbOjtclio9mV5Sugwurolczvq8DAGpMG +W4WgALgOWDjQAudiNH5dtcMGkBONbYywkJc7cT2OZFmzkCbchPPWlKGopuaFGAoU +SPj7C9SenHmOWAFRX5jJrOZAuVqkdKN3ShWZUL+cDkOCCQlZ0E31u0m9yozY1MeO +Sx42GtZaSGff37FGYeMZM2ztlutw2zmv2B1g52SBHTjCqQU/ud2Q6/U0kUzjbsdF +/0KQY9wgZRdOvbnA2lBirN1rXzLWPdduOZ5QImfHfvToN+oOlEqVvvWG12DdA4e5 +y4Dumx00lfKEsGutjF3oKgE6jsjwqAwCoYEAFHTtsvA0hKPisQwNHZmpjGARvR56 +yMEmXynKvgyVGvVP2a9VdqBXSpstL24HfDIu+nlyEWGQ +-----END ENCRYPTED PRIVATE KEY----- diff --git a/samples/net/wifi/test_certs/rsa3k/server.pem b/samples/net/wifi/test_certs/rsa3k/server.pem index f5a5dd36e8fb..d8f82faf6dd3 100644 --- a/samples/net/wifi/test_certs/rsa3k/server.pem +++ b/samples/net/wifi/test_certs/rsa3k/server.pem @@ -1,26 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIEbDCCAtQCAQEwDQYJKoZIhvcNAQEMBQAwgYIxCzAJBgNVBAYTAkNOMRIwEAYD -VQQIDAlTb21ld2hlcmUxEjAQBgNVBAcMCVNvbWV3aGVyZTEUMBIGA1UECgwLRXhh -bXBsZSBJbmMxEzARBgNVBAMMCkV4YW1wbGUgQ0ExIDAeBgkqhkiG9w0BCQEWEWFk -bWluQGV4YW1wbGUub3JnMCAXDTA5MTIzMTE2MDI1MloYDzIxMDkxMjA3MTYwMjUy -WjBzMQswCQYDVQQGEwJDTjESMBAGA1UECAwJU29tZXdoZXJlMRQwEgYDVQQKDAtF -eGFtcGxlIEluYzEXMBUGA1UEAwwORXhhbXBsZSBTZXJ2ZXIxITAfBgkqhkiG9w0B -CQEWEnNlcnZlckBleGFtcGxlLm9yZzCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCC -AYoCggGBAN6IGMMHI49tZGhtHNQudQmsAYePgXclJ27gMK0LlxSwRXFUaha5nBQn -55QmIw30m8i9GwJJIXGhk6BHySV1Tx+ytD8AV5gxxX49J4cLAdV7p8zzMvwi/6KU -3LsnG2yWD5254ramdAbnghpUQphj5eGDTrw+YhJrKboP6Lh5YVSKoTls4daWnndH -PnVRtoDLuDGh4O/igh/CHMgaOB4VRIZyVM15cPtByyjBbVHeHmVPcxQjGLoWYeLP -iVoNlV62zy9HC/EYp21LEC6b8mVsWG/KnKnWUkr8M8CXIwLrO6G51ko/GdIHIn96 -NzNyZS0gtsc+n0IYQ+zn7bq8lCMngdMZA558kZDPCPWgdY6Rw9+3ibYomfr8ZaEk -txTDBG5kH9duVVYn30aDqmALyO7nY7gCSu/3oJvMCnAZFLG5nZC6BR7eluIyJyUU -uKKD2qYCZA4qulNUeyGcjVEoczYx3JZhDm4Mw32eu9XpUtLt4Nfx1+xoPdnLLBC6 -eBJc0AMElQIDAQABMA0GCSqGSIb3DQEBDAUAA4IBgQBpKHoroH7HBdH0TVtHl6WF -C52YO02BIAWXK/vCXdWGLs81SIMwbYd0YCp6K/6wG8hWdyJWi12LVuVG7SbTgx7y -odEwO4t5ntNfcmN6SDo8Y8RbROnTDI5ubkUdsOB5AaTI3km5goeapgrwUzXpXWYi -sh2S0FJQAnrx4qdGPShCI1RF1WMV3TGcAj3oc4brnIiMFAecmj99hOkSM7ScJ27X -oqozXYf36UI8AyVUw+jBUlGko6v9jNH3k40zAgcdajfStiOXPDyr+HtL2KcV8WaV -oaXT2Sp5VUr/ghjUfbonWY4RTesXFehVktXw7BuD5koNSlJXbHY5BCUxTBC8EaiJ -+9gVQJcOdb/WhOJV2b24ZHecHckoDGYN4gHQ/lPR67HuibcNTzWYfNWSygGfknCS -HO30Yts7tzVFTudKKbUc4XvdaXpStmFPWGh1oy0hkDnPIiXcRu2WWmyOeRGeJWnb -j62Bz21jBu2V9BXJtRjuI0Uvxfjb/2Mbw95KUDncd34= +MIIDojCCAooCFCPQcj7ej5jhr6/mLlAoLYgfgsYcMA0GCSqGSIb3DQEBCwUAMIGS +MQswCQYDVQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hl +cmUxFDASBgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRp +ZmljYXRlIEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5v +cmcwHhcNMjQxMDA4MTAyNTI5WhcNMzQxMDA2MTAyNTI5WjCBhzELMAkGA1UEBhMC +RlIxDzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQK +DAtFeGFtcGxlIEluYzEbMBkGA1UEAwwSc2VydmVyLmV4YW1wbGUub3JnMSAwHgYJ +KoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLm9yZzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBANcE/OPHQK/y1b6UsIktNK7WIZB528HECY7Bz18EGba0uHod +91RbzHSJ1qI3iQyldI1UW/kY5oYjBW3lhLH0BkD/EsqvNYCV+3YzAM3ITtdOdEU9 +CqjgXttehQHfXvc7jQlF8Q2gYPUz2dDLo/gcTkz1d+mCr6nQUjT8Kq/nG54T0NnD +k8udchjUlNaQsvx/WVs3TUYxMbWzQRtpJIbv99rAWq7YgQbkNZnSYC1VgrU/BiuQ +0KrP6rfkxvBCGwIh2JXIL3FV4N8AsgGZvjXQ3zXKXwuPhxWdSmjKWlioVM3mha2A +/1e1gX6nFY/uk46D60XWxcJ6tHGHoafU7EtN3zMCAwEAATANBgkqhkiG9w0BAQsF +AAOCAQEAWwdTMphD0jxLtYO0iq/+fMtq2R96ZUN9wprZ7qg1evUNQjqLR4jKX306 +ZJX5uw+6r5Ve/k368qvcSF/sSfvBm8yd3JcegTl5t8T2/Aks8o3sfyuS0uyJC1rS +zTrd7FmJG9YMosU1BqYobda64MXq7g+6MyrQoZ6fVdPvC6Sox3+a4fl9xjdm4CTY +MsWqBJMe26LptvRIJ01/B6PjVTvsn/fxxj7rHmnJ/j63AIiBntm0vV/85cwYy/4o +HlPH/Qjvn3hZjUlBcveiYat998F+s9gH2usvCkG3kly/n1/667LLCymmCHxtH8ka +7tF3siO1EANureFY8qj6ZvlKeTkZ6g== -----END CERTIFICATE----- diff --git a/samples/net/wifi/test_certs/server-key2.pem b/samples/net/wifi/test_certs/server-key2.pem new file mode 100644 index 000000000000..5f032cad701d --- /dev/null +++ b/samples/net/wifi/test_certs/server-key2.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIjI78fcZSH7oCAggA +MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDfF676hRrL290F0MgMDZiuBIIE +0Hkz7skRV8Ox0SoX5N8GsOPfN4PS1cLyHgokY6dUhJPU5vUzOn9iSiGQSEzSguQ7 +11mssjRC2T45wB/95VK2EPtRw1f/6VOUR6RJnnGb0PV1Rydp/x5TZ6vzcXpakqly +eljJR/20fIJClsZzhw0iu5la9fkF6G8WYFEkqex5jALSiN4qVLvkiqcTnh5+amem +8+OCKgvgooKD2ids4/0GGfJRQSC6DFf3kuxNl+MMvmDXmz/vrD85ONnyXzKXDA3N +3vRgL/YT6GzwIXb+7/c/tIMpnacxPAdbNOs3DY5ss4xcK68L5PwpM2BljzBa5dGw +Smgf2VRaYRVzmrte5j280QjfrlHRU2cHaxm0GCu2AOTGwMXcSNYMXfDNuxc57oQJ +vHXMeZD4K5lACbhYdZ5lJNFvv29YI7dZ7QOGu6nXlAuhZfbdc/cgT0som7eG8xpT +pERllhQ5ych9sP9nAccN6VUsWgmlF73lbSptBek1ccYkp9LIYCteJUPl2qPcz6zl +A7zrZ54f3Lg0fOm2pCtg+qKBiw1nd3MR/YbRCgyvudyZE2cCN/ZspWqxsavbGYOz +JOfIFNnyAcOYtEv1n1BGLfMa1THW2bDV8XmHVHUtM0k4z250QAmLygWLY2166iUF +qotBkvctKKdulzGdT4nVer1UEKTqcxhDf0dRiHN5spZtFrOee0uGIoQWHt2oecaK +pJovW+i0qO/1DG5spfU2m1bz6jR2u6nxi340oRrMSoe1ELVg3l1/wmM8yzh07GuK +pshzxwqAG/FnaKCvcKGUG2EfnAvOcbMgSa2w3GvyRkcDPn00arvX9nuXj0gkRDBi +eoVMkKKTeeYSGQ4ik+ja3xkgHcxh5W8aoezLvBbmUq206cmhLwfnYMhnvFTs6EBK +E0ENpCHwF/qoVBIzRCijG/eeCuf3a1YkJsWlvEeVrPeOmDFeDft3SSGOzHxE2A/7 +HWmHbWTm7dPOfgsU4zf+HglnBjN3kYU7StyM0EGxmB4lfB2BiWiL/3R13ERHQZfa +oOqa4/hOFXOXfTQk6ufXtBx8L9BemBqh36zbs2xVvIizJKeRMruoRblWZkHhUKR8 +K5GA7FYkU9ZPPP0UPKsO94xzwfbevi+7nWeUZoqcqAUy8Jt5aD2QpvFVbPBBOz17 +PGaubeVn/Ry8swPvkpddtmJ4mgF+3SVctmzY+EE/oN1XS8wa+XeuaThzk89Lvrfa +606nRWrNw3PSKjYoEEtRLhPeJCi9uOVenbOjtclio9mV5Sugwurolczvq8DAGpMG +W4WgALgOWDjQAudiNH5dtcMGkBONbYywkJc7cT2OZFmzkCbchPPWlKGopuaFGAoU +SPj7C9SenHmOWAFRX5jJrOZAuVqkdKN3ShWZUL+cDkOCCQlZ0E31u0m9yozY1MeO +Sx42GtZaSGff37FGYeMZM2ztlutw2zmv2B1g52SBHTjCqQU/ud2Q6/U0kUzjbsdF +/0KQY9wgZRdOvbnA2lBirN1rXzLWPdduOZ5QImfHfvToN+oOlEqVvvWG12DdA4e5 +y4Dumx00lfKEsGutjF3oKgE6jsjwqAwCoYEAFHTtsvA0hKPisQwNHZmpjGARvR56 +yMEmXynKvgyVGvVP2a9VdqBXSpstL24HfDIu+nlyEWGQ +-----END ENCRYPTED PRIVATE KEY----- diff --git a/samples/net/wifi/test_certs/server2.pem b/samples/net/wifi/test_certs/server2.pem new file mode 100644 index 000000000000..d8f82faf6dd3 --- /dev/null +++ b/samples/net/wifi/test_certs/server2.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDojCCAooCFCPQcj7ej5jhr6/mLlAoLYgfgsYcMA0GCSqGSIb3DQEBCwUAMIGS +MQswCQYDVQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hl +cmUxFDASBgNVBAoMC0V4YW1wbGUgSW5jMSYwJAYDVQQDDB1FeGFtcGxlIENlcnRp +ZmljYXRlIEF1dGhvcml0eTEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBsZS5v +cmcwHhcNMjQxMDA4MTAyNTI5WhcNMzQxMDA2MTAyNTI5WjCBhzELMAkGA1UEBhMC +RlIxDzANBgNVBAgMBlJhZGl1czESMBAGA1UEBwwJU29tZXdoZXJlMRQwEgYDVQQK +DAtFeGFtcGxlIEluYzEbMBkGA1UEAwwSc2VydmVyLmV4YW1wbGUub3JnMSAwHgYJ +KoZIhvcNAQkBFhFhZG1pbkBleGFtcGxlLm9yZzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBANcE/OPHQK/y1b6UsIktNK7WIZB528HECY7Bz18EGba0uHod +91RbzHSJ1qI3iQyldI1UW/kY5oYjBW3lhLH0BkD/EsqvNYCV+3YzAM3ITtdOdEU9 +CqjgXttehQHfXvc7jQlF8Q2gYPUz2dDLo/gcTkz1d+mCr6nQUjT8Kq/nG54T0NnD +k8udchjUlNaQsvx/WVs3TUYxMbWzQRtpJIbv99rAWq7YgQbkNZnSYC1VgrU/BiuQ +0KrP6rfkxvBCGwIh2JXIL3FV4N8AsgGZvjXQ3zXKXwuPhxWdSmjKWlioVM3mha2A +/1e1gX6nFY/uk46D60XWxcJ6tHGHoafU7EtN3zMCAwEAATANBgkqhkiG9w0BAQsF +AAOCAQEAWwdTMphD0jxLtYO0iq/+fMtq2R96ZUN9wprZ7qg1evUNQjqLR4jKX306 +ZJX5uw+6r5Ve/k368qvcSF/sSfvBm8yd3JcegTl5t8T2/Aks8o3sfyuS0uyJC1rS +zTrd7FmJG9YMosU1BqYobda64MXq7g+6MyrQoZ6fVdPvC6Sox3+a4fl9xjdm4CTY +MsWqBJMe26LptvRIJ01/B6PjVTvsn/fxxj7rHmnJ/j63AIiBntm0vV/85cwYy/4o +HlPH/Qjvn3hZjUlBcveiYat998F+s9gH2usvCkG3kly/n1/667LLCymmCHxtH8ka +7tF3siO1EANureFY8qj6ZvlKeTkZ6g== +-----END CERTIFICATE----- diff --git a/samples/shields/npm1300_ek/nrf52dk_nrf52832.overlay b/samples/shields/npm1300_ek/nrf52dk_nrf52832.overlay index 7bcc1bef5a46..e4f2cca20ce5 100644 --- a/samples/shields/npm1300_ek/nrf52dk_nrf52832.overlay +++ b/samples/shields/npm1300_ek/nrf52dk_nrf52832.overlay @@ -26,12 +26,12 @@ }; &npm1300_ek_ldo1 { - regulator-initial-mode = ; + regulator-initial-mode = ; enable-gpio-config = <2 GPIO_ACTIVE_LOW>; }; &npm1300_ek_ldo2 { - regulator-initial-mode = ; + regulator-initial-mode = ; enable-gpio-config = <2 GPIO_ACTIVE_LOW>; }; diff --git a/samples/shields/npm1300_ek/src/main.c b/samples/shields/npm1300_ek/src/main.c index 7ced01456628..9ecffb69e219 100644 --- a/samples/shields/npm1300_ek/src/main.c +++ b/samples/shields/npm1300_ek/src/main.c @@ -9,10 +9,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -68,9 +68,9 @@ void configure_events(void) /* Setup callback for shiphold button press */ static struct gpio_callback event_cb; - gpio_init_callback(&event_cb, event_callback, BIT(NPM1300_EVENT_SHIPHOLD_PRESS)); + gpio_init_callback(&event_cb, event_callback, BIT(NPM13XX_EVENT_SHIPHOLD_PRESS)); - mfd_npm1300_add_callback(pmic, &event_cb); + mfd_npm13xx_add_callback(pmic, &event_cb); } void read_sensors(void) @@ -86,11 +86,11 @@ void read_sensors(void) sensor_channel_get(charger, SENSOR_CHAN_GAUGE_VOLTAGE, &volt); sensor_channel_get(charger, SENSOR_CHAN_GAUGE_AVG_CURRENT, ¤t); sensor_channel_get(charger, SENSOR_CHAN_GAUGE_TEMP, &temp); - sensor_channel_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM1300_CHARGER_STATUS, + sensor_channel_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM13XX_CHARGER_STATUS, &status); - sensor_channel_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM1300_CHARGER_ERROR, &error); - sensor_attr_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM1300_CHARGER_VBUS_STATUS, - (enum sensor_attribute)SENSOR_ATTR_NPM1300_CHARGER_VBUS_PRESENT, + sensor_channel_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM13XX_CHARGER_ERROR, &error); + sensor_attr_get(charger, (enum sensor_channel)SENSOR_CHAN_NPM13XX_CHARGER_VBUS_STATUS, + (enum sensor_attribute)SENSOR_ATTR_NPM13XX_CHARGER_VBUS_PRESENT, &vbus_present); printk("V: %d.%03d ", volt.val1, volt.val2 / 1000); diff --git a/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf b/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf b/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/logging/multidomain/sysbuild.conf b/samples/subsys/logging/multidomain/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/logging/multidomain/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay new file mode 100644 index 000000000000..fcc2e240fd9e --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/app_nrf5340_bt.overlay @@ -0,0 +1,5 @@ +/ { + chosen { + nordic,pm-ext-flash = &mx25r64; + }; +}; diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay new file mode 100644 index 000000000000..ddbd39f4bdec --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay @@ -0,0 +1,46 @@ +/ { + chosen { + nordic,pm-ext-flash = &mx25r64; + }; +}; + +/delete-node/ &boot_partition; +/delete-node/ &slot0_partition; +/delete-node/ &slot1_partition; + +/delete-node/ &slot0_ns_partition; +/delete-node/ &slot1_ns_partition; + +/delete-node/ &storage_partition; + +&cpuapp_rram { + reg = < 0x0 DT_SIZE_K(1524) >; + partitions { + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x000000000 0x00014000>; + }; + slot0_partition: partition@14000 { + label = "image-0"; + reg = <0x000014000 0x0015A000>; + }; + storage_partition: partition@16E000 { + label = "storage"; + reg = < 0x16E000 0x9000 >; + }; + }; +}; + +&mx25r64 { + status = "okay"; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + slot1_partition: partition@0 { + label = "image-1"; + reg = <0x000000000 0x0015A000>; + }; + }; +}; diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml b/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml new file mode 100644 index 000000000000..7a48d51ec334 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/pm_static_nrf5340_bt.yml @@ -0,0 +1,55 @@ +app: + address: 0x10200 + region: flash_primary + size: 0xdfe00 +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf b/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf index 06a27644bacb..925ac0c93a27 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf +++ b/samples/subsys/mgmt/mcumgr/smp_svr/prj.conf @@ -8,7 +8,7 @@ CONFIG_FLASH_MAP=y # Some command handlers require a large stack. CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304 -CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_MAIN_STACK_SIZE=2176 # Ensure an MCUboot-compatible binary is generated. CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf b/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf new file mode 100644 index 000000000000..cb53d3e6beb6 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/prj_nrf5340_bt.conf @@ -0,0 +1,88 @@ +# Enable MCUmgr and dependencies. +CONFIG_NET_BUF=y +CONFIG_ZCBOR=y +CONFIG_CRC=y +CONFIG_MCUMGR=y +CONFIG_STREAM_FLASH=y +CONFIG_FLASH_MAP=y +CONFIG_BT=y +CONFIG_BT_PERIPHERAL=y + +# Some command handlers require a large stack. +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304 +CONFIG_MAIN_STACK_SIZE=2176 + +# Ensure an MCUboot-compatible binary is generated. +CONFIG_BOOTLOADER_MCUBOOT=y + +# Enable flash operations. +CONFIG_FLASH=y + +# Required by the `taskstat` command. +CONFIG_THREAD_MONITOR=y + +# Support for taskstat command +CONFIG_MCUMGR_GRP_OS_TASKSTAT=y + +# Enable statistics and statistic names. +CONFIG_STATS=y +CONFIG_STATS_NAMES=y + +# Enable most core commands. +CONFIG_FLASH=y +CONFIG_IMG_MANAGER=y +CONFIG_MCUMGR_GRP_IMG=y +CONFIG_MCUMGR_GRP_OS=y +CONFIG_MCUMGR_GRP_STAT=y + +# Enable logging +CONFIG_LOG=y +CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y + +# Disable debug logging +CONFIG_LOG_MAX_LEVEL=3 + +# Allow for large Bluetooth data packets. +CONFIG_BT_L2CAP_TX_MTU=498 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 + +# Enable the Bluetooth mcumgr transport (unauthenticated). +CONFIG_MCUMGR_TRANSPORT_BT=y +CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y + +# Enable the Shell mcumgr transport. +CONFIG_BASE64=y +CONFIG_CRC=y +CONFIG_SHELL=y +CONFIG_SHELL_BACKEND_SERIAL=y +CONFIG_MCUMGR_TRANSPORT_SHELL=y + +# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies. +# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands, +# transmitted with the maximum possible MTU value: 498 bytes. +CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y +CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475 +CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y +CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608 + +# Enable the LittleFS file system. +CONFIG_FILE_SYSTEM=y +CONFIG_FILE_SYSTEM_LITTLEFS=y + +# Enable file system commands +CONFIG_MCUMGR_GRP_FS=y + +# Enable the storage erase command. +CONFIG_MCUMGR_GRP_ZBASIC=y +CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y + +# Disable Bluetooth ping support +CONFIG_BT_CTLR_LE_PING=n + +# Disable shell commands that are not needed +CONFIG_CLOCK_CONTROL_NRF_SHELL=n +CONFIG_DEVICE_SHELL=n +CONFIG_DEVMEM_SHELL=n +CONFIG_FLASH_SHELL=n diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml index 8ede9b77d07b..aef16825a75b 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml @@ -14,9 +14,12 @@ tests: - nrf52840dk/nrf52840 - pinnacle_100_dvk - mg100 + - nrf54l15dk/nrf54l15/cpuapp + - nrf54l15dk/nrf54l10/cpuapp integration_platforms: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 + - nrf54l15dk/nrf54l15/cpuapp sample.mcumgr.smp_svr.bt_static_svc: harness: bluetooth tags: bluetooth @@ -88,7 +91,7 @@ tests: - mimxrt685_evk/mimxrt685s/cm33 - rd_rw612_bga - nrf52840dk/nrf52840 - - nrf54h20dk/nrf54h20/cpuapp/iron + - nrf54h20dk/nrf54h20/cpuapp - pinnacle_100_dvk - mg100 integration_platforms: @@ -170,6 +173,33 @@ tests: - mg100 integration_platforms: - nrf52840dk/nrf52840 + sample.mcumgr.smp_svr.bt.nrf54l15dk.ext_flash: + extra_args: + - OVERLAY_CONFIG="overlay-bt.conf" + - DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay" + - mcuboot_CONF_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.conf" + - mcuboot_EXTRA_DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay" + - SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y + - SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + - nrf54l15dk/nrf54l10/cpuapp + - nrf54l15dk/nrf54l05/cpuapp + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp + sample.mcumgr.smp_svr.bt.nrf54l15dk.ext_flash.pure_dts: + extra_args: + - OVERLAY_CONFIG="overlay-bt.conf" + - DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay" + - mcuboot_CONF_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.conf" + - mcuboot_EXTRA_DTC_OVERLAY_FILE="boards/nrf54l15dk_nrf54l15_cpuapp_ext_flash.overlay" + - SB_CONFIG_PARTITION_MANAGER=n + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + - nrf54l15dk/nrf54l10/cpuapp + - nrf54l15dk/nrf54l05/cpuapp + integration_platforms: + - nrf54l15dk/nrf54l15/cpuapp sample.mcumgr.smp_svr.ram_load: extra_args: FILE_SUFFIX="ram_load" platform_allow: @@ -192,3 +222,11 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52840dk/nrf52840 + sample.mcumgr.smp_svr.bt.nrf5340dk.ext_flash: + sysbuild: true + extra_args: + - FILE_SUFFIX=nrf5340_bt + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: + - nrf5340dk/nrf5340/cpuapp diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake new file mode 100644 index 000000000000..f0a9f06df847 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild.cmake @@ -0,0 +1,16 @@ +# +# Copyright (c) 2024 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# + +if(FILE_SUFFIX STREQUAL "nrf5340_bt") + if(SB_CONFIG_SOC_NRF5340_CPUAPP) + # nRF5340 with Bluetooth configuration, add partition manager configuration to MCUboot image + list(APPEND mcuboot_EXTRA_DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/app_nrf5340_bt.overlay) + list(REMOVE_DUPLICATES mcuboot_EXTRA_DTC_OVERLAY_FILE) + set(mcuboot_EXTRA_DTC_OVERLAY_FILE ${mcuboot_EXTRA_DTC_OVERLAY_FILE} CACHE INTERNAL "" FORCE) + else() + message(FATAL_ERROR "File suffix 'nrf5340_bt' can only be used on an nRF5340 CPUAPP board target") + endif() +endif() diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf new file mode 100644 index 000000000000..98260877332f --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2022 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_BT_MAX_CONN=2 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot_nrf5340_bt.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot_nrf5340_bt.conf new file mode 100644 index 000000000000..05c51e50ab40 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/mcuboot_nrf5340_bt.conf @@ -0,0 +1 @@ +CONFIG_BOOT_MAX_IMG_SECTORS=220 diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf new file mode 100644 index 000000000000..16bcac179e83 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild_nrf5340_bt.conf @@ -0,0 +1,8 @@ +# Enable MCUboot bootloader support +SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y +SB_CONFIG_NETCORE_HCI_IPC=y +SB_CONFIG_SECURE_BOOT_NETCORE=y +SB_CONFIG_NETCORE_APP_UPDATE=y +SB_CONFIG_MCUBOOT_NRF53_MULTI_IMAGE_UPDATE=y +SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y diff --git a/samples/subsys/usb/dfu/sysbuild.conf b/samples/subsys/usb/dfu/sysbuild.conf new file mode 100644 index 000000000000..47f00ff3cff8 --- /dev/null +++ b/samples/subsys/usb/dfu/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/subsys/usb/hid-keyboard/app.overlay b/samples/subsys/usb/hid-keyboard/app.overlay index 0d3d2ee7bd85..0905e8850bfd 100644 --- a/samples/subsys/usb/hid-keyboard/app.overlay +++ b/samples/subsys/usb/hid-keyboard/app.overlay @@ -7,7 +7,7 @@ / { hid_dev_0: hid_dev_0 { compatible = "zephyr,hid-device"; - interface-name = "HID0"; + label = "HID0"; protocol-code = "keyboard"; in-report-size = <64>; in-polling-period-us = <1000>; diff --git a/samples/subsys/usb/hid-keyboard/large_in_report.overlay b/samples/subsys/usb/hid-keyboard/large_in_report.overlay index 93b47691a77f..548342f4b3ea 100644 --- a/samples/subsys/usb/hid-keyboard/large_in_report.overlay +++ b/samples/subsys/usb/hid-keyboard/large_in_report.overlay @@ -7,7 +7,7 @@ / { hid_dev_0: hid_dev_0 { compatible = "zephyr,hid-device"; - interface-name = "HID0"; + label = "HID0"; in-report-size = <256>; in-polling-period-us = <1000>; }; diff --git a/samples/subsys/usb/hid-mouse/usbd_next.overlay b/samples/subsys/usb/hid-mouse/usbd_next.overlay index ce74aa518796..86365a94ae54 100644 --- a/samples/subsys/usb/hid-mouse/usbd_next.overlay +++ b/samples/subsys/usb/hid-mouse/usbd_next.overlay @@ -7,7 +7,7 @@ / { hid_dev_0: hid_dev_0 { compatible = "zephyr,hid-device"; - interface-name = "HID0"; + label = "HID0"; protocol-code = "none"; in-polling-period-us = <1000>; in-report-size = <64>; diff --git a/samples/sysbuild/hello_world/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf b/samples/sysbuild/hello_world/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf deleted file mode 100644 index ca2bc07e4f29..000000000000 --- a/samples/sysbuild/hello_world/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y diff --git a/samples/sysbuild/hello_world/sample.yaml b/samples/sysbuild/hello_world/sample.yaml index c8ca9cbe4c0d..e638594c634e 100644 --- a/samples/sysbuild/hello_world/sample.yaml +++ b/samples/sysbuild/hello_world/sample.yaml @@ -25,13 +25,9 @@ tests: - nrf54h20dk/nrf54h20/cpuapp integration_platforms: - nrf54h20dk/nrf54h20/cpuapp - extra_args: SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf - - sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpurad.iron: - platform_allow: - - nrf54h20dk/nrf54h20/cpuapp/iron - extra_args: SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad_iron.conf - + extra_args: + - SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + - hello_world_CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpuppr: platform_allow: - nrf54h20dk/nrf54h20/cpuapp diff --git a/samples/sysbuild/hello_world/sysbuild.cmake b/samples/sysbuild/hello_world/sysbuild.cmake index c7c2615c665a..8f8fc49dbff3 100644 --- a/samples/sysbuild/hello_world/sysbuild.cmake +++ b/samples/sysbuild/hello_world/sysbuild.cmake @@ -11,5 +11,17 @@ ExternalZephyrProject_Add( BOARD ${SB_CONFIG_REMOTE_BOARD} ) +if(SB_CONFIG_SOC_SERIES_NRF53X) + set_property(GLOBAL APPEND PROPERTY PM_DOMAINS CPUNET) + set_property(GLOBAL APPEND PROPERTY PM_CPUNET_IMAGES remote) + set_property(GLOBAL PROPERTY DOMAIN_APP_CPUNET remote) + set(CPUNET_PM_DOMAIN_DYNAMIC_PARTITION remote CACHE INTERNAL "") +else(SB_CONFIG_SOC_SERIES_NRF54LX) + set_property(GLOBAL APPEND PROPERTY PM_DOMAINS CPUFLPR) + set_property(GLOBAL APPEND PROPERTY PM_CPUFLPR_IMAGES remote) + set_property(GLOBAL PROPERTY DOMAIN_APP_CPUFLPR remote) + set(CPUFLPR_PM_DOMAIN_DYNAMIC_PARTITION remote CACHE INTERNAL "") +endif() + add_dependencies(${DEFAULT_IMAGE} remote) sysbuild_add_dependencies(FLASH ${DEFAULT_IMAGE} remote) diff --git a/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad_iron.conf b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad_iron.conf deleted file mode 100644 index 8d4a230adbe1..000000000000 --- a/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad_iron.conf +++ /dev/null @@ -1 +0,0 @@ -SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad/iron" diff --git a/samples/tfm_integration/psa_crypto/sample.yaml b/samples/tfm_integration/psa_crypto/sample.yaml index ea9844730fc1..7d287985bf3c 100644 --- a/samples/tfm_integration/psa_crypto/sample.yaml +++ b/samples/tfm_integration/psa_crypto/sample.yaml @@ -16,8 +16,6 @@ tests: platform_allow: - mps2/an521/cpu0/ns - v2m_musca_s1/musca_s1/ns - - nrf5340dk/nrf5340/cpuapp/ns - - nrf9160dk/nrf9160/ns - stm32l562e_dk/stm32l562xx/ns - bl5340_dvk/nrf5340/cpuapp/ns - max32657evkit/max32657/ns diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index cd97ea96717f..4889a14d704b 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -458,6 +458,13 @@ def get_modules(self, modules_file, sysbuild_modules_file, settings_file): modules = [name for name in os.listdir(modules_dir) if modules_dir / name / 'Kconfig'] + nrf_modules_dir = ZEPHYR_BASE / Path('../nrf/modules') + nrf_modules = [] + if os.path.exists(nrf_modules_dir): + nrf_modules = [name for name in os.listdir(nrf_modules_dir) if + os.path.exists(os.path.join(nrf_modules_dir, name, + 'Kconfig'))] + with open(modules_file, 'r') as fp_module_file: content = fp_module_file.read() @@ -467,6 +474,15 @@ def get_modules(self, modules_file, sysbuild_modules_file, settings_file): re.sub('[^a-zA-Z0-9]', '_', module).upper(), modules_dir / module / 'Kconfig' )) + for module in nrf_modules: + fp_module_file.write("ZEPHYR_{}_KCONFIG = {}\n".format( + re.sub('[^a-zA-Z0-9]', '_', module).upper(), + nrf_modules_dir / module / 'Kconfig' + )) + fp_module_file.write("NCS_{}_KCONFIG = {}\n".format( + re.sub('[^a-zA-Z0-9]', '_', module).upper(), + modules_dir / module / 'Kconfig' + )) fp_module_file.write(content) def get_kconfig_dts(self, kconfig_dts_file, settings_file): @@ -1211,6 +1227,29 @@ class SysbuildKconfigCheck(KconfigCheck): "SUIT_MPI_GENERATE", # Used by nRF runners to program provisioning data "SUIT_MPI_RAD_AREA_PATH", # Used by nRF runners to program provisioning data # zephyr-keep-sorted-stop + + # NCS-specific allowlist + # zephyr-keep-sorted-start re(^\s+") + "APP_CPUNET_RUN", # Used by sample + "APP_DFU", # Used by sample + "BT_FAST_PAIR", # Legacy/removed, used in migration documentation + "COMP_DATA_LAYOUT_ARRAY", # Used by test + "COMP_DATA_LAYOUT_MULTIPLE", # Used by test + "COMP_DATA_LAYOUT_SINGLE", # Used by test + "DTM_NO_DFE", # Used by DTM application + "DTM_TRANSPORT_HCI", # Used by DTM application + "INCLUDE_REMOTE_IMAGE", # Used by machine learning application + "ML_APP_INCLUDE_REMOTE_IMAGE", # Used by machine learning application + "ML_APP_REMOTE_BOARD", # Used by machine learning application + "MY_APP_IMAGE_ABC", # Used in documentation + "REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING", # Used in tests + "SOC_FLASH_NRF_RADIO_SYNC_RPC", # Used in documentation + "SUIT_ENVELOPE_", # Used by jinja + "SUIT_ENVELOPE_SEQUENCE_NUM", # Legacy/removed, used in migration documentation + "SUIT_MPI_", # Used by jinja + "SUIT_RECOVERY_APPLICATION_CUSTOM", # Used in documentation + "SUPPORT_NETCORE_PERIPHERAL_RADIO_TEST", # Used by wifi radio test sample + # zephyr-keep-sorted-stop } diff --git a/scripts/gitlint/zephyr_commit_rules.py b/scripts/gitlint/zephyr_commit_rules.py index a2c9cd3cb7fe..ef317e22684c 100644 --- a/scripts/gitlint/zephyr_commit_rules.py +++ b/scripts/gitlint/zephyr_commit_rules.py @@ -78,7 +78,7 @@ class TitleMaxLengthRevert(LineRule): name = "title-max-length-no-revert" id = "UC5" target = CommitMessageTitle - options_spec = [IntOption('line-length', 75, "Max line length")] + options_spec = [IntOption('line-length', 120, "Max line length")] violation_message = "Commit title exceeds max length ({0}>{1})" def validate(self, line, _commit): @@ -103,7 +103,7 @@ class MaxLineLengthExceptions(LineRule): name = "max-line-length-with-exceptions" id = "UC4" target = CommitMessageBody - options_spec = [IntOption('line-length', 75, "Max line length")] + options_spec = [IntOption('line-length', 120, "Max line length")] violation_message = "Commit message body line exceeds max length ({0}>{1})" def validate(self, line, _commit): diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index ce4ce2aa6c28..4b42ce30cef4 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -983,8 +983,8 @@ def arith(kconf, name, *args): the operation on the first two arguments and operates the same operation as the result and the following argument. For interoperability with inc and dec, - if there is only one argument, it will be split with a comma and processed - as a sequence of numbers. + each argument can be a single number or a comma-separated list of numbers, + but all numbers are processed as if they were individual arguments. Examples in Kconfig: @@ -1008,22 +1008,36 @@ def arith(kconf, name, *args): $(div, $(dec, 1, 1)) # Error (0 div 0) """ - intarray = map(int, args if len(args) > 1 else args[0].split(",")) + intarray = (int(val, base=0) for arg in args for val in arg.split(",")) if name == "add": return str(int(functools.reduce(operator.add, intarray))) + elif name == "add_hex": + return hex(int(functools.reduce(operator.add, intarray))) elif name == "sub": return str(int(functools.reduce(operator.sub, intarray))) + elif name == "sub_hex": + return hex(int(functools.reduce(operator.sub, intarray))) elif name == "mul": return str(int(functools.reduce(operator.mul, intarray))) + elif name == "mul_hex": + return hex(int(functools.reduce(operator.mul, intarray))) elif name == "div": return str(int(functools.reduce(operator.truediv, intarray))) + elif name == "div_hex": + return hex(int(functools.reduce(operator.truediv, intarray))) elif name == "mod": return str(int(functools.reduce(operator.mod, intarray))) + elif name == "mod_hex": + return hex(int(functools.reduce(operator.mod, intarray))) elif name == "max": return str(int(functools.reduce(max, intarray))) + elif name == "max_hex": + return hex(int(functools.reduce(max, intarray))) elif name == "min": return str(int(functools.reduce(min, intarray))) + elif name == "min_hex": + return hex(int(functools.reduce(min, intarray))) else: assert False @@ -1034,12 +1048,16 @@ def inc_dec(kconf, name, *args): Returns a string that concatenates numbers with a comma as a separator. """ - intarray = map(int, args if len(args) > 1 else args[0].split(",")) + intarray = (int(val, base=0) for arg in args for val in arg.split(",")) if name == "inc": return ",".join(map(lambda a: str(a + 1), intarray)) + if name == "inc_hex": + return ",".join(map(lambda a: hex(a + 1), intarray)) elif name == "dec": return ",".join(map(lambda a: str(a - 1), intarray)) + elif name == "dec_hex": + return ",".join(map(lambda a: hex(a - 1), intarray)) else: assert False @@ -1106,12 +1124,21 @@ def inc_dec(kconf, name, *args): "shields_list_contains": (shields_list_contains, 1, 1), "substring": (substring, 2, 3), "add": (arith, 1, 255), + "add_hex": (arith, 1, 255), "sub": (arith, 1, 255), + "sub_hex": (arith, 1, 255), "mul": (arith, 1, 255), + "mul_hex": (arith, 1, 255), "div": (arith, 1, 255), + "div_hex": (arith, 1, 255), "mod": (arith, 1, 255), + "mod_hex": (arith, 1, 255), "max": (arith, 1, 255), + "max_hex": (arith, 1, 255), "min": (arith, 1, 255), + "min_hex": (arith, 1, 255), "inc": (inc_dec, 1, 255), + "inc_hex": (inc_dec, 1, 255), "dec": (inc_dec, 1, 255), + "dec_hex": (inc_dec, 1, 255), } diff --git a/scripts/pylib/twister/twisterlib/hardwaremap.py b/scripts/pylib/twister/twisterlib/hardwaremap.py index d3308b8cbe3f..5c0c5eb12385 100644 --- a/scripts/pylib/twister/twisterlib/hardwaremap.py +++ b/scripts/pylib/twister/twisterlib/hardwaremap.py @@ -386,7 +386,7 @@ def save(self, hwm_file): boot_ids = [] # use existing map - self.detected = natsorted(self.detected, key=lambda x: x.serial or '') + self.detected.sort(key=lambda x: x.serial or '') if os.path.exists(hwm_file): with open(hwm_file) as yaml_file: hwm = yaml.load(yaml_file, Loader=SafeLoader) diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index 5b1a782eca9c..9d050ca30a88 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -1895,7 +1895,6 @@ def run(self): except queue.Empty: break else: - inst.metrics.update(self.instances[inst.name].metrics) inst.metrics["handler_time"] = inst.execution_time self.instances[inst.name] = inst diff --git a/scripts/quarantine.yaml b/scripts/quarantine.yaml new file mode 100644 index 000000000000..20c4f9248ea9 --- /dev/null +++ b/scripts/quarantine.yaml @@ -0,0 +1,88 @@ +# The configurations resulting as a product of scenarios and platforms +# will be skipped if quarantine is used. More details here: +# https://docs.zephyrproject.org/latest/guides/test/twister.html#quarantine + +- scenarios: + - testing.ztest.busy_sim + - testing.ztest.busy_sim_nrf52840dk_pin + platforms: + - nrf52840dk_nrf52840 + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.unary_f64 + platforms: + - nrf5340dk_nrf5340_cpunet + - qemu_cortex_m3 + comment: "Flash overflows" + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.binary_f16 + - libraries.cmsis_dsp.matrix.binary_f16.fpu + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Flash overflows" + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.binary_q15 + - libraries.cmsis_dsp.matrix.binary_q15.fpu + - libraries.cmsis_dsp.matrix.unary_f32 + - libraries.cmsis_dsp.matrix.unary_f32.fpu + - libraries.cmsis_dsp.matrix.unary_f64 + - libraries.cmsis_dsp.matrix.unary_f64.fpu + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Flash overflows" + +# libsdl2-dev package should be added into docker image +- scenarios: + - sample.boards.nrf.nrf_led_matrix + - sample.display.lvgl.gui + platforms: + - native_posix + comment: "libsdl2-dev package not available" + +- scenarios: + - sample.net.sockets.echo_server.usbnet + - sample.net.sockets.echo_server.usbnet_composite + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - sample.net.zperf.netusb_ecm + - sample.net.zperf.netusb_eem + - sample.net.zperf.netusb_rndis + platforms: + - nrf52833dk_nrf52833 + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - net.mqtt.tls + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - kernel.common.picolibc + - libraries.picolibc + - libraries.libc.picolibc.mem_alloc + - libraries.picolibc.sprintf_new + platforms: + - nrf52dk_nrf52832 + comment: "Ram overflows, also in the upstream" + +- scenarios: + - sample.psa_crypto + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Due to using sdk-zephyr manifest instead of nrf. Should be fixed after the change" diff --git a/scripts/requirements-run-test.txt b/scripts/requirements-run-test.txt index d3a4be916735..08ff89b0c545 100644 --- a/scripts/requirements-run-test.txt +++ b/scripts/requirements-run-test.txt @@ -7,7 +7,6 @@ pyocd>=0.35.0 # used by twister for board/hardware map tabulate -natsort # used by mcuboot cbor>=1.0.0 diff --git a/scripts/tests/twister/test_runner.py b/scripts/tests/twister/test_runner.py index 0e6227acefeb..e689095fc7c1 100644 --- a/scripts/tests/twister/test_runner.py +++ b/scripts/tests/twister/test_runner.py @@ -2530,7 +2530,7 @@ def mock_client_from_environ(jobs): pipeline_q = queue.LifoQueue() done_q = queue.LifoQueue() done_instance = mock.Mock( - metrics={'k2': 'v2'}, + metrics={'k': 'v2'}, execution_time=30 ) done_instance.name='dummy instance' @@ -2568,8 +2568,7 @@ def iteration_increment(value=1, decrement=False): assert tr.jobserver.name == expected_jobserver assert tr.instances['dummy instance'].metrics == { - 'k': 'v', - 'k2': 'v2', + 'k': 'v2', 'handler_time': 30 } diff --git a/scripts/west_commands/build.py b/scripts/west_commands/build.py index 90d1a037e4f7..1b7bf3b80a18 100644 --- a/scripts/west_commands/build.py +++ b/scripts/west_commands/build.py @@ -624,7 +624,12 @@ def _run_cmake(self, board, origin, cmake_opts): if user_args: cmake_opts.extend(shlex.split(user_args)) - config_sysbuild = config_getboolean('sysbuild', False) + config_sysbuild = config_getboolean('sysbuild', None) + + if config_sysbuild is None: + # If no option is set, then enable sysbuild globally + config_sysbuild = True + if self.args.sysbuild or (config_sysbuild and not self.args.no_sysbuild): cmake_opts.extend([f'-S{SYSBUILD_PROJ_DIR}', f'-DAPP_DIR:PATH={self.source_dir}']) diff --git a/scripts/west_commands/runners/nrf_common.py b/scripts/west_commands/runners/nrf_common.py index af4f8286722b..a7401084ef31 100644 --- a/scripts/west_commands/runners/nrf_common.py +++ b/scripts/west_commands/runners/nrf_common.py @@ -320,8 +320,7 @@ def recover_target(self): # recover operation unlocks the core and then flashes a small image that # keeps the debug access port open, recovering the network core last # would result in that small image being deleted from the app core. - # In the case of the 54H, the order is indifferent. - if self.family in ('nrf53', 'nrf54h', 'nrf92'): + if self.family in ('nrf53', 'nrf92'): self.exec_op('recover', core='Network') self.exec_op('recover') @@ -369,9 +368,9 @@ def program_hex(self): if self.family in ('nrf54h', 'nrf92'): erase_arg = 'ERASE_NONE' - generated_uicr = self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR') + regtool_generated_uicr = self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR') - if generated_uicr and not self.hex_get_uicrs().get(core): + if regtool_generated_uicr and not self.hex_get_uicrs().get(core): raise RuntimeError( f"Expected a UICR to be contained in: {self.hex_}\n" "Please ensure that the correct version of nrf-regtool is " @@ -379,7 +378,7 @@ def program_hex(self): ) if self.erase: - if self.build_conf.get('CONFIG_SOC_NRF54H20_IRON'): + if self.family == 'nrf54h': self.exec_op('erase', kind='all') else: self.exec_op('erase', core='Application', kind='all') @@ -434,7 +433,27 @@ def program_hex(self): core='Application', ) - if not self.erase and generated_uicr: + if self.build_conf.getboolean("CONFIG_NRF_HALTIUM_GENERATE_UICR"): + zephyr_build_dir = Path(self.cfg.build_dir) / 'zephyr' + + self.op_program( + str(zephyr_build_dir / 'uicr.hex'), + 'ERASE_NONE', + None, + defer=True, + core='Application', + ) + + if self.build_conf.getboolean("CONFIG_NRF_HALTIUM_UICR_PERIPHCONF"): + self.op_program( + str(zephyr_build_dir / 'periphconf.hex'), + 'ERASE_NONE', + None, + defer=True, + core='Application', + ) + + if not self.erase and regtool_generated_uicr: self.exec_op('erase', core=core, kind='uicr') else: if self.erase: @@ -464,11 +483,19 @@ def program_hex(self): self.logger.debug(f'Erase modes: chip:{erase_arg} ext_mem:' f'{ext_mem_erase_opt}') - # Temp hack while waiting for NRF54H20_IRON support for Network in nrfutil - if self.build_conf.get('CONFIG_SOC_NRF54H20_IRON') and core == "Network": + # Temp hack while waiting for nrfutil Network support for NRF54H20 with IronSide + if self.family == 'nrf54h' and core == 'Network': core = "Application" self.op_program(self.hex_, erase_arg, ext_mem_erase_opt, defer=True, core=core) + + if self.erase or self.recover: + # provision keys if keyfile.json exists in the build directory + keyfile = Path(self.cfg.build_dir).parent / 'keyfile.json' + if keyfile.exists(): + self.logger.info(f'Provisioning key file: {keyfile}') + self.exec_op('x-provision-keys', keyfile=str(keyfile), defer=True) + self.flush(force=False) diff --git a/scripts/west_commands/runners/nrfutil.py b/scripts/west_commands/runners/nrfutil.py index 1fb44949507f..f11d2a7ad133 100644 --- a/scripts/west_commands/runners/nrfutil.py +++ b/scripts/west_commands/runners/nrfutil.py @@ -147,6 +147,8 @@ def _append_batch(self, op, json_file): cmd += ['--reset-kind', _op['kind']] elif op_type == 'erase': cmd.append(f'--{_op["kind"]}') + elif op_type == 'x-provision-keys': + cmd += ['--key-file', _op['keyfile']] cmd += ['--core', op['core']] if op.get('core') else [] cmd += ['--x-family', f'{self.family}'] diff --git a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake index db6e60f9ab7c..75778f655a86 100644 --- a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake @@ -261,7 +261,7 @@ function(ExternalZephyrProject_Add) set(sysbuild_image_conf_dir ${APP_DIR}/sysbuild) set(sysbuild_image_name_conf_dir ${APP_DIR}/sysbuild/${ZBUILD_APPLICATION}) # User defined `-D_CONF_FILE=` takes precedence over anything else. - if (NOT ${ZBUILD_APPLICATION}_CONF_FILE) + if(NOT ${ZBUILD_APPLICATION}_CONF_FILE) if(EXISTS ${sysbuild_image_name_conf_dir}) set(${ZBUILD_APPLICATION}_APPLICATION_CONFIG_DIR ${sysbuild_image_name_conf_dir} CACHE INTERNAL "Application configuration dir controlled by sysbuild" @@ -275,7 +275,7 @@ function(ExternalZephyrProject_Add) NAMES ${ZBUILD_APPLICATION}.conf SUFFIX ${FILE_SUFFIX} ) - if (NOT (${ZBUILD_APPLICATION}_OVERLAY_CONFIG OR ${ZBUILD_APPLICATION}_EXTRA_CONF_FILE) + if(NOT (${ZBUILD_APPLICATION}_OVERLAY_CONFIG OR ${ZBUILD_APPLICATION}_EXTRA_CONF_FILE) AND EXISTS ${sysbuild_image_conf_fragment} ) set(${ZBUILD_APPLICATION}_EXTRA_CONF_FILE ${sysbuild_image_conf_fragment} @@ -283,12 +283,23 @@ function(ExternalZephyrProject_Add) ) endif() - # Check for overlay named .overlay. - set(sysbuild_image_dts_overlay ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}.overlay) - if (NOT ${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE AND EXISTS ${sysbuild_image_dts_overlay}) - set(${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE ${sysbuild_image_dts_overlay} - CACHE INTERNAL "devicetree overlay file defined by main application" - ) + if(NOT ${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE) + # Check for overlay named .overlay. + set(sysbuild_image_dts_overlay_files ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}.overlay) + + # Check for overlay named _.overlay. + if(FILE_SUFFIX) + list(PREPEND sysbuild_image_dts_overlay_files ${sysbuild_image_conf_dir}/${ZBUILD_APPLICATION}_${FILE_SUFFIX}.overlay) + endif() + + foreach(overlay_file ${sysbuild_image_dts_overlay_files}) + if(EXISTS ${overlay_file}) + set(${ZBUILD_APPLICATION}_DTC_OVERLAY_FILE ${overlay_file} + CACHE INTERNAL "devicetree overlay file defined by main application" + ) + break() + endif() + endforeach() endif() endif() diff --git a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake index f366c66dbde0..f0e4c29fcadc 100644 --- a/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_kconfig.cmake @@ -102,6 +102,17 @@ set(shield_conf_files) list(APPEND ZEPHYR_KCONFIG_MODULES_DIR BOARD=${BOARD}) set(KCONFIG_NAMESPACE SB_CONFIG) +foreach(module_name ${ZEPHYR_MODULE_NAMES}) + zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name}) + + if(SYSBUILD_${MODULE_NAME_UPPER}_KCONFIG) + list(APPEND + ZEPHYR_KCONFIG_MODULES_DIR + "SYSBUILD_${MODULE_NAME_UPPER}_KCONFIG=${SYSBUILD_${MODULE_NAME_UPPER}_KCONFIG}" + ) + endif() +endforeach() + if(EXISTS ${APP_DIR}/Kconfig.sysbuild) set(KCONFIG_ROOT ${APP_DIR}/Kconfig.sysbuild) endif() diff --git a/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay b/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay index 04bf83ef44d4..a57a0e82ba6e 100644 --- a/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay +++ b/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay @@ -2,6 +2,10 @@ status = "okay"; }; +&bt_hci_sdc { + status = "disabled"; +}; + / { chosen { zephyr,bt-hci = &bt_hci_controller; diff --git a/snippets/nordic-ppr-xip/soc/nrf54h20_cpuapp.overlay b/snippets/nordic-ppr-xip/soc/nrf54h20_cpuapp.overlay index 4d02921660b5..2d884a3455a2 100644 --- a/snippets/nordic-ppr-xip/soc/nrf54h20_cpuapp.overlay +++ b/snippets/nordic-ppr-xip/soc/nrf54h20_cpuapp.overlay @@ -3,10 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuppr_ram3x_region { - status = "okay"; -}; - &cpuppr_vpr { execution-memory = <&cpuppr_code_partition>; /delete-property/ source-memory; diff --git a/snippets/nordic-ppr/soc/nrf54h20_cpuapp.overlay b/snippets/nordic-ppr/soc/nrf54h20_cpuapp.overlay index 75128f42a13f..ae635c9ca9b6 100644 --- a/snippets/nordic-ppr/soc/nrf54h20_cpuapp.overlay +++ b/snippets/nordic-ppr/soc/nrf54h20_cpuapp.overlay @@ -3,10 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuppr_ram3x_region { - status = "okay"; -}; - &uart135 { status = "reserved"; }; diff --git a/snippets/wifi-enterprise/wifi-enterprise.conf b/snippets/wifi-enterprise/wifi-enterprise.conf index dbac5ee63874..4de1130cf69f 100644 --- a/snippets/wifi-enterprise/wifi-enterprise.conf +++ b/snippets/wifi-enterprise/wifi-enterprise.conf @@ -7,6 +7,15 @@ CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_MBEDTLS_HEAP_SIZE=70000 +#For use with Wi-Fi Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y +CONFIG_NVS=y +CONFIG_SETTINGS=y +CONFIG_SETTINGS_NVS=y + # For use with TLS credentials CONFIG_TLS_CREDENTIALS_SHELL=y CONFIG_BASE64=y diff --git a/soc/nordic/common/CMakeLists.txt b/soc/nordic/common/CMakeLists.txt index ac75d0838696..825be4842fb7 100644 --- a/soc/nordic/common/CMakeLists.txt +++ b/soc/nordic/common/CMakeLists.txt @@ -3,6 +3,10 @@ add_subdirectory_ifdef(CONFIG_RISCV_CORE_NORDIC_VPR vpr) +if(CONFIG_NRF_PERIPHCONF_SECTION OR CONFIG_NRF_HALTIUM_GENERATE_UICR) + add_subdirectory(uicr) +endif() + # Let SystemInit() be called in place of soc_reset_hook() by default. zephyr_linker_symbol(SYMBOL soc_reset_hook EXPR "@SystemInit@") diff --git a/soc/nordic/common/Kconfig b/soc/nordic/common/Kconfig index 059274fd299f..782d9452b677 100644 --- a/soc/nordic/common/Kconfig +++ b/soc/nordic/common/Kconfig @@ -49,3 +49,4 @@ source "subsys/logging/Kconfig.template.log_config" endif # MRAM_LATENCY rsource "vpr/Kconfig" +rsource "uicr/Kconfig" diff --git a/soc/nordic/common/Kconfig.peripherals b/soc/nordic/common/Kconfig.peripherals index 5a6e820efcb9..90bd21f84663 100644 --- a/soc/nordic/common/Kconfig.peripherals +++ b/soc/nordic/common/Kconfig.peripherals @@ -13,10 +13,12 @@ config HAS_HW_NRF_BPROT def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_BPROT)) config HAS_HW_NRF_CC310 - def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_310)) + def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_310)) || \ + ($(dt_nodelabel_enabled,psa_rng) && SOC_SERIES_NRF91X) config HAS_HW_NRF_CC312 - def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_312)) + def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_312)) || \ + ($(dt_nodelabel_enabled,psa_rng) && SOC_NRF5340_CPUAPP) config HAS_HW_NRF_CCM def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_CCM)) @@ -118,7 +120,8 @@ config HAS_HW_NRF_MWU def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_MWU)) config HAS_HW_NRF_NFCT - def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_NFCT)) + def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_NFCT)) || \ + $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_NFCT_V2)) config HAS_HW_NRF_NVMC_PE def_bool $(dt_nodelabel_bool_prop,flash_controller,partial-erase) @@ -279,6 +282,12 @@ config HAS_HW_NRF_SPIM21 config HAS_HW_NRF_SPIM22 def_bool $(dt_nodelabel_enabled_with_compat,spi22,$(DT_COMPAT_NORDIC_NRF_SPIM)) +config HAS_HW_NRF_SPIM23 + def_bool $(dt_nodelabel_enabled_with_compat,spi23,$(DT_COMPAT_NORDIC_NRF_SPIM)) + +config HAS_HW_NRF_SPIM24 + def_bool $(dt_nodelabel_enabled_with_compat,spi24,$(DT_COMPAT_NORDIC_NRF_SPIM)) + config HAS_HW_NRF_SPIM30 def_bool $(dt_nodelabel_enabled_with_compat,spi30,$(DT_COMPAT_NORDIC_NRF_SPIM)) @@ -336,6 +345,12 @@ config HAS_HW_NRF_SPIS21 config HAS_HW_NRF_SPIS22 def_bool $(dt_nodelabel_enabled_with_compat,spi22,$(DT_COMPAT_NORDIC_NRF_SPIS)) +config HAS_HW_NRF_SPIS23 + def_bool $(dt_nodelabel_enabled_with_compat,spi23,$(DT_COMPAT_NORDIC_NRF_SPIS)) + +config HAS_HW_NRF_SPIS24 + def_bool $(dt_nodelabel_enabled_with_compat,spi24,$(DT_COMPAT_NORDIC_NRF_SPIS)) + config HAS_HW_NRF_SPIS30 def_bool $(dt_nodelabel_enabled_with_compat,spi30,$(DT_COMPAT_NORDIC_NRF_SPIS)) @@ -501,6 +516,12 @@ config HAS_HW_NRF_TWIM21 config HAS_HW_NRF_TWIM22 def_bool $(dt_nodelabel_enabled_with_compat,i2c22,$(DT_COMPAT_NORDIC_NRF_TWIM)) +config HAS_HW_NRF_TWIM23 + def_bool $(dt_nodelabel_enabled_with_compat,i2c23,$(DT_COMPAT_NORDIC_NRF_TWIM)) + +config HAS_HW_NRF_TWIM24 + def_bool $(dt_nodelabel_enabled_with_compat,i2c24,$(DT_COMPAT_NORDIC_NRF_TWIM)) + config HAS_HW_NRF_TWIM30 def_bool $(dt_nodelabel_enabled_with_compat,i2c30,$(DT_COMPAT_NORDIC_NRF_TWIM)) @@ -552,6 +573,12 @@ config HAS_HW_NRF_TWIS21 config HAS_HW_NRF_TWIS22 def_bool $(dt_nodelabel_enabled_with_compat,i2c22,$(DT_COMPAT_NORDIC_NRF_TWIS)) +config HAS_HW_NRF_TWIS23 + def_bool $(dt_nodelabel_enabled_with_compat,i2c23,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS24 + def_bool $(dt_nodelabel_enabled_with_compat,i2c24,$(DT_COMPAT_NORDIC_NRF_TWIS)) + config HAS_HW_NRF_TWIS30 def_bool $(dt_nodelabel_enabled_with_compat,i2c30,$(DT_COMPAT_NORDIC_NRF_TWIS)) diff --git a/soc/nordic/common/uicr/CMakeLists.txt b/soc/nordic/common/uicr/CMakeLists.txt new file mode 100644 index 000000000000..0bde6b47f576 --- /dev/null +++ b/soc/nordic/common/uicr/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_NRF_PERIPHCONF_SECTION) + zephyr_linker_sources(SECTIONS uicr.ld) +endif() + +if(CONFIG_NRF_HALTIUM_GENERATE_UICR) + if(CONFIG_NRF_PERIPHCONF_SECTION) + set(in_periphconf_elf_arg + --in-periphconf-elf $ + ) + endif() + + if(CONFIG_NRF_HALTIUM_UICR_PERIPHCONF) + set(periphconf_hex_file ${PROJECT_BINARY_DIR}/periphconf.hex) + set(out_periphconf_hex_arg + --out-periphconf-hex ${periphconf_hex_file} + ) + list(APPEND optional_byproducts ${periphconf_hex_file}) + endif() + + set(uicr_hex_file ${PROJECT_BINARY_DIR}/uicr.hex) + set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${ZEPHYR_BASE}/scripts/dts/python-devicetree/src + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/gen_uicr.py + --in-config ${DOTCONFIG} + --in-edt-pickle ${EDT_PICKLE} + ${in_periphconf_elf_arg} + ${out_periphconf_hex_arg} + --out-uicr-hex ${uicr_hex_file} + ) + set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts + ${uicr_hex_file} ${optional_byproducts} + ) +endif() diff --git a/soc/nordic/common/uicr/Kconfig b/soc/nordic/common/uicr/Kconfig new file mode 100644 index 000000000000..f132510a7a5d --- /dev/null +++ b/soc/nordic/common/uicr/Kconfig @@ -0,0 +1,31 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config NRF_HALTIUM_GENERATE_UICR + bool "Generate UICR file" + depends on SOC_NRF54H20_CPUAPP + default y + help + Generate UICR HEX file. + +if NRF_HALTIUM_GENERATE_UICR + +config NRF_HALTIUM_UICR_PERIPHCONF + bool "Initialize global domain peripherals" + default y + help + Generates a blob containing static global domain peripheral initialization + values extracted from the build artifacts, and configures UICR.PERIPHCONF + to point at the blob. The initialization values are then loaded ahead of + ahead of the application boot. + +endif + +config NRF_PERIPHCONF_SECTION + bool "Populate global peripheral initialization section" + default y if SOC_NRF54H20_CPUAPP + depends on LINKER_DEVNULL_SUPPORT + imply LINKER_DEVNULL_MEMORY + help + Include static global domain peripheral initialization values from the + build in a dedicated section in the devnull region. diff --git a/soc/nordic/common/uicr/gen_uicr.py b/soc/nordic/common/uicr/gen_uicr.py new file mode 100644 index 000000000000..50f96eab566f --- /dev/null +++ b/soc/nordic/common/uicr/gen_uicr.py @@ -0,0 +1,270 @@ +""" +Copyright (c) 2025 Nordic Semiconductor ASA +SPDX-License-Identifier: Apache-2.0 +""" + +from __future__ import annotations + +import argparse +import ctypes as c +import math +import pickle +import re +import sys +from collections import defaultdict +from itertools import groupby + +from elftools.elf.elffile import ELFFile +from intelhex import IntelHex + +# Name of the ELF section containing PERIPHCONF entries. +# Must match the name used in the linker script. +PERIPHCONF_SECTION = "uicr_periphconf_entry" + +# Expected nodelabel of the UICR devicetree node, used to extract its location from the devicetree. +UICR_NODELABEL = "uicr" +# Nodelabel of the PERIPHCONF devicetree node, used to extract its location from the devicetree. +PERIPHCONF_NODELABEL = "periphconf_partition" + +# Common values for representing enabled/disabled in the UICR format. +ENABLED_VALUE = 0xFFFF_FFFF +DISABLED_VALUE = 0xBD23_28A8 + + +class ScriptError(RuntimeError): ... + + +class PeriphconfEntry(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("regptr", c.c_uint32), + ("value", c.c_uint32), + ] + + +PERIPHCONF_ENTRY_SIZE = c.sizeof(PeriphconfEntry) + + +class Approtect(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("APPLICATION", c.c_uint32), + ("RADIOCORE", c.c_uint32), + ("RESERVED", c.c_uint32), + ("CORESIGHT", c.c_uint32), + ] + + +class Protectedmem(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("ENABLE", c.c_uint32), + ("SIZE4KB", c.c_uint32), + ] + + +class Recovery(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("ENABLE", c.c_uint32), + ("PROCESSOR", c.c_uint32), + ("INITSVTOR", c.c_uint32), + ("SIZE4KB", c.c_uint32), + ] + + +class Its(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("ENABLE", c.c_uint32), + ("ADDRESS", c.c_uint32), + ("APPLICATIONSIZE", c.c_uint32), + ("RADIOCORESIZE", c.c_uint32), + ] + + +class Periphconf(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("ENABLE", c.c_uint32), + ("ADDRESS", c.c_uint32), + ("MAXCOUNT", c.c_uint32), + ] + + +class Mpcconf(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("ENABLE", c.c_uint32), + ("ADDRESS", c.c_uint32), + ("MAXCOUNT", c.c_uint32), + ] + + +class Uicr(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("VERSION", c.c_uint32), + ("RESERVED", c.c_uint32), + ("LOCK", c.c_uint32), + ("RESERVED1", c.c_uint32), + ("APPROTECT", Approtect), + ("ERASEPROTECT", c.c_uint32), + ("PROTECTEDMEM", Protectedmem), + ("RECOVERY", Recovery), + ("ITS", Its), + ("RESERVED2", c.c_uint32 * 7), + ("PERIPHCONF", Periphconf), + ("MPCCONF", Mpcconf), + ] + + +def main() -> None: + parser = argparse.ArgumentParser( + allow_abbrev=False, + description=( + "Generate artifacts for the UICR and associated configuration blobs from application " + "build outputs. User Information Configuration Registers (UICR), in the context of " + "certain Nordic SoCs, are used to configure system resources, like memory and " + "peripherals, and to protect the device in various ways." + ), + ) + parser.add_argument( + "--in-config", + required=True, + type=argparse.FileType("r"), + help="Path to the .config file from the application build", + ) + parser.add_argument( + "--in-edt-pickle", + required=True, + type=argparse.FileType("rb"), + help="Path to the edt.pickle file from the application build", + ) + parser.add_argument( + "--in-periphconf-elf", + dest="in_periphconf_elfs", + default=[], + action="append", + type=argparse.FileType("rb"), + help=( + "Path to an ELF file to extract PERIPHCONF data from. Can be provided multiple times. " + "The PERIPHCONF data from each ELF file is combined in a single list which is sorted " + "by ascending address and cleared of duplicate entries." + ), + ) + parser.add_argument( + "--out-uicr-hex", + required=True, + type=argparse.FileType("w", encoding="utf-8"), + help="Path to write the generated UICR HEX file to", + ) + parser.add_argument( + "--out-periphconf-hex", + default=None, + type=argparse.FileType("w", encoding="utf-8"), + help="Path to write the generated PERIPHCONF HEX file to", + ) + args = parser.parse_args() + + try: + init_values = DISABLED_VALUE.to_bytes(4, "little") * (c.sizeof(Uicr) // 4) + uicr = Uicr.from_buffer_copy(init_values) + + kconfig_str = args.in_config.read() + kconfig = parse_kconfig(kconfig_str) + + edt = pickle.load(args.in_edt_pickle) + + try: + periphconf_partition = edt.label2node[PERIPHCONF_NODELABEL] + except LookupError as e: + raise ScriptError( + "Failed to find a PERIPHCONF partition in the devicetree. " + f"Expected a DT node with label '{PERIPHCONF_NODELABEL}'." + ) from e + + flash_base_address = periphconf_partition.flash_controller.regs[0].addr + periphconf_address = flash_base_address + periphconf_partition.regs[0].addr + periphconf_size = periphconf_partition.regs[0].size + + periphconf_combined = extract_and_combine_periphconfs(args.in_periphconf_elfs) + padding_len = periphconf_size - len(periphconf_combined) + periphconf_final = periphconf_combined + bytes([0xFF for _ in range(padding_len)]) + + if kconfig.get("CONFIG_NRF_HALTIUM_UICR_PERIPHCONF") == "y": + uicr.PERIPHCONF.ENABLE = ENABLED_VALUE + uicr.PERIPHCONF.ADDRESS = periphconf_address + uicr.PERIPHCONF.MAXCOUNT = math.floor(periphconf_size / 8) + + try: + uicr_node = edt.label2node[UICR_NODELABEL] + except LookupError as e: + raise ScriptError( + "Failed to find UICR node in the devicetree. " + f"Expected a DT node with label '{UICR_NODELABEL}'." + ) from e + + uicr_hex = IntelHex() + uicr_hex.frombytes(bytes(uicr), offset=uicr_node.regs[0].addr) + + uicr_hex.write_hex_file(args.out_uicr_hex) + + if args.out_periphconf_hex is not None: + periphconf_hex = IntelHex() + periphconf_hex.frombytes(periphconf_final, offset=periphconf_address) + periphconf_hex.write_hex_file(args.out_periphconf_hex) + + except ScriptError as e: + print(f"Error: {e!s}") + sys.exit(1) + + +def extract_and_combine_periphconfs(elf_files: list[argparse.FileType]) -> bytes: + combined_periphconf = [] + + for in_file in elf_files: + elf = ELFFile(in_file) + conf_section = elf.get_section_by_name(PERIPHCONF_SECTION) + if conf_section is None: + continue + + conf_section_data = conf_section.data() + num_entries = len(conf_section_data) // PERIPHCONF_ENTRY_SIZE + periphconf = (PeriphconfEntry * num_entries).from_buffer_copy(conf_section_data) + combined_periphconf.extend(periphconf) + + combined_periphconf.sort(key=lambda e: e.regptr) + deduplicated_periphconf = [] + + for regptr, regptr_entries in groupby(combined_periphconf, key=lambda e: e.regptr): + entries = list(regptr_entries) + if len(entries) > 1: + unique_values = {e.value for e in entries} + if len(unique_values) > 1: + raise ScriptError( + f"PERIPHCONF has conflicting values for register 0x{regptr:09_x}: " + + ", ".join([f"0x{val:09_x}" for val in unique_values]) + ) + deduplicated_periphconf.append(entries[0]) + + final_periphconf = (PeriphconfEntry * len(deduplicated_periphconf))() + for i, entry in enumerate(deduplicated_periphconf): + final_periphconf[i] = entry + + return bytes(final_periphconf) + + +def parse_kconfig(content: str) -> dict[str, str | None]: + result = defaultdict(None) + match_iter = re.finditer( + r"^(?P(SB_)?CONFIG_[^=\s]+)=(?P[^\s#])+$", content, re.MULTILINE + ) + for match in match_iter: + result[match["config"]] = match["value"] + + return result + + +if __name__ == "__main__": + main() diff --git a/soc/nordic/common/uicr/uicr.h b/soc/nordic/common/uicr/uicr.h new file mode 100644 index 000000000000..7ceb12429e22 --- /dev/null +++ b/soc/nordic/common/uicr/uicr.h @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef SOC_NORDIC_COMMON_UICR_UICR_H_ +#define SOC_NORDIC_COMMON_UICR_UICR_H_ + +#include +#include +#include +#include +#include + +/** Entry in the PERIPHCONF table. */ +struct uicr_periphconf_entry { + /** Register pointer. */ + uint32_t regptr; + /** Register value. */ + uint32_t value; +} __packed; + +/** @brief Add an entry to the PERIPHCONF table section. + * + * This should typically not be used directly. + * Prefer to use one of the higher level macros. + */ +#define UICR_PERIPHCONF_ADD(_regptr, _value) \ + static STRUCT_SECTION_ITERABLE(uicr_periphconf_entry, \ + _UICR_PERIPHCONF_ENTRY_NAME(__COUNTER__)) = { \ + .regptr = (_regptr), \ + .value = (_value), \ + } + +#define _UICR_PERIPHCONF_ENTRY_NAME(_id) __UICR_PERIPHCONF_ENTRY_NAME(_id) +#define __UICR_PERIPHCONF_ENTRY_NAME(_id) _uicr_periphconf_entry_##_id + +/** @brief Add a PERIPHCONF entry for a SPU PERIPH[n].PERM register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Peripheral slave index on the bus (PERIPH[n] register index). + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _dmasec If true, set DMASEC to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_PERIPH_PERM_SET(_spu, _index, _secattr, _dmasec, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->PERIPH[(_index)].PERM, \ + (uint32_t)((((_ownerid) << SPU_PERIPH_PERM_OWNERID_Pos) & \ + SPU_PERIPH_PERM_OWNERID_Msk) | \ + (((_secattr) ? SPU_PERIPH_PERM_SECATTR_Secure \ + : SPU_PERIPH_PERM_SECATTR_NonSecure) \ + << SPU_PERIPH_PERM_SECATTR_Pos) | \ + (((_dmasec) ? SPU_PERIPH_PERM_DMASEC_Secure \ + : SPU_PERIPH_PERM_DMASEC_NonSecure) \ + << SPU_PERIPH_PERM_DMASEC_Pos) | \ + (SPU_PERIPH_PERM_LOCK_Locked << SPU_PERIPH_PERM_LOCK_Pos))) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.IPCT.CH[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_IPCT_CH_SET(_spu, _index, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.IPCT.CH[_index], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.IPCT.INTERRUPT[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_IPCT_INTERRUPT_SET(_spu, _index, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.IPCT.INTERRUPT[_index], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.DPPIC.CH[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_DPPIC_CH_SET(_spu, _index, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.DPPIC.CH[_index], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.DPPIC.CHG[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Register index. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_DPPIC_CHG_SET(_spu, _index, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.DPPIC.CHG[_index], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.GPIOTE[n].CH[m] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index (GPIOTE[n] register index). + * @param _subindex Feature subindex (CH[m] register index). + * @param _secattr If true, set the SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_GPIOTE_CH_SET(_spu, _index, _subindex, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD( \ + (uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.GPIOTE[_index].CH[_subindex], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.GPIOTE.INTERRUPT[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _subindex Feature subindex. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_GPIOTE_INTERRUPT_SET(_spu, _index, _subindex, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD( \ + (uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.GPIOTE[_index].INTERRUPT[_subindex], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.GPIO[n].PIN[m] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _subindex Feature subindex. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_GPIO_PIN_SET(_spu, _index, _subindex, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD( \ + (uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.GPIO[_index].PIN[_subindex], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/** @brief Add a PERIPHCONF entry for a SPU FEATURE.GRTC.CC[n] register value. + * + * @param _spu Global domain SPU instance address. + * @param _index Feature index. + * @param _secattr If true, set SECATTR to secure, otherwise set it to non-secure. + * @param _ownerid OWNERID field value. + */ +#define UICR_SPU_FEATURE_GRTC_CC_SET(_spu, _index, _secattr, _ownerid) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_SPU_Type *)(_spu))->FEATURE.GRTC.CC[_index], \ + _UICR_SPU_FEATURE_VAL(_secattr, _ownerid)) + +/* Common macro for encoding a SPU FEATURE.* register value. + * Note that the MDK SPU_FEATURE_IPCT_CH_ macros are used for all since all the FEATURE registers + * have the same layout with different naming. + */ +#define _UICR_SPU_FEATURE_VAL(_secattr, _ownerid) \ + (uint32_t)((((_ownerid) << SPU_FEATURE_IPCT_CH_OWNERID_Pos) & \ + SPU_FEATURE_IPCT_CH_OWNERID_Msk) | \ + (((_secattr) ? SPU_FEATURE_IPCT_CH_SECATTR_Secure \ + : SPU_FEATURE_IPCT_CH_SECATTR_NonSecure) \ + << SPU_FEATURE_IPCT_CH_SECATTR_Pos) | \ + (SPU_FEATURE_IPCT_CH_LOCK_Locked << SPU_FEATURE_IPCT_CH_LOCK_Pos)) + +/** @brief Add PERIPHCONF entries for configuring IPCMAP CHANNEL.SOURCE[n] and CHANNEL.SINK[n]. + * + * @param _index CHANNEL.SOURCE[n]/CHANNEL.SINK[n] register index. + * @param _source_domain DOMAIN field value in CHANNEL[n].SOURCE. + * @param _source_ch SOURCE field value in CHANNEL[n].SOURCE. + * @param _sink_domain DOMAIN field value in CHANNEL[n].SINK. + * @param _sink_ch SINK field value in CHANNEL[n].SINK. + */ +#define UICR_IPCMAP_CHANNEL_CFG(_index, _source_domain, _source_ch, _sink_domain, _sink_ch) \ + UICR_IPCMAP_CHANNEL_SOURCE_SET(_index, _source_domain, _source_ch, 1); \ + UICR_IPCMAP_CHANNEL_SINK_SET(_index, _sink_domain, _sink_ch) + +#define UICR_IPCMAP_CHANNEL_SOURCE_SET(_index, _domain, _ch, _enable) \ + UICR_PERIPHCONF_ADD((uint32_t)&NRF_IPCMAP->CHANNEL[(_index)].SOURCE, \ + (uint32_t)((((_domain) << IPCMAP_CHANNEL_SOURCE_DOMAIN_Pos) & \ + IPCMAP_CHANNEL_SOURCE_DOMAIN_Msk) | \ + (((_ch) << IPCMAP_CHANNEL_SOURCE_SOURCE_Pos) & \ + IPCMAP_CHANNEL_SOURCE_SOURCE_Msk) | \ + (((_enable) ? IPCMAP_CHANNEL_SOURCE_ENABLE_Enabled \ + : IPCMAP_CHANNEL_SOURCE_ENABLE_Disabled) \ + << IPCMAP_CHANNEL_SOURCE_ENABLE_Pos))) + +#define UICR_IPCMAP_CHANNEL_SINK_SET(_index, _domain, _ch) \ + UICR_PERIPHCONF_ADD((uint32_t)&NRF_IPCMAP->CHANNEL[(_index)].SINK, \ + (uint32_t)((((_domain) << IPCMAP_CHANNEL_SINK_DOMAIN_Pos) & \ + IPCMAP_CHANNEL_SINK_DOMAIN_Msk) | \ + (((_ch) << IPCMAP_CHANNEL_SINK_SINK_Pos) & \ + IPCMAP_CHANNEL_SINK_SINK_Msk))) + +/** @brief Add a PERIPHCONF entry for an IRQMAP IRQ[n].SINK register value. + * + * @param _irqnum IRQ number (IRQ[n] register index). + * @param _processor Processor to route the interrupt to (PROCESSORID field value). + */ +#define UICR_IRQMAP_IRQ_SINK_SET(_irqnum, _processor) \ + UICR_PERIPHCONF_ADD((uint32_t)&NRF_IRQMAP->IRQ[(_irqnum)].SINK, \ + (uint32_t)(((_processor) << IRQMAP_IRQ_SINK_PROCESSORID_Pos) & \ + IRQMAP_IRQ_SINK_PROCESSORID_Msk)) + +/** @brief Add a PERIPHCONF entry for configuring a GPIO PIN_CNF[n] CTRLSEL field value. + * + * @param _gpio GPIO instance address. + * @param _pin Pin number (PIN_CNF[n] register index). + * @param _ctrlsel CTRLSEL field value. + */ +#define UICR_GPIO_PIN_CNF_CTRLSEL_SET(_gpio, _pin, _ctrlsel) \ + UICR_PERIPHCONF_ADD( \ + (uint32_t)&((NRF_GPIO_Type *)(_gpio))->PIN_CNF[(_pin)], \ + ((GPIO_PIN_CNF_ResetValue) | \ + (uint32_t)(((_ctrlsel) << GPIO_PIN_CNF_CTRLSEL_Pos) & GPIO_PIN_CNF_CTRLSEL_Msk))) + +/** @brief Add a PERIPHCONF entry for a PPIB SUBSCRIBE_SEND[n] register. + * + * @param _ppib Global domain PPIB instance address. + * @param _ppib_ch PPIB channel number. + */ +#define UICR_PPIB_SUBSCRIBE_SEND_ENABLE(_ppib, _ppib_ch) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_PPIB_Type *)(_ppib))->SUBSCRIBE_SEND[(_ppib_ch)], \ + (uint32_t)PPIB_SUBSCRIBE_SEND_EN_Msk) + +/** @brief Add a PERIPHCONF entry for a PPIB PUBLISH_RECEIVE[n] register. + * + * @param _ppib Global domain PPIB instance address. + * @param _ppib_ch PPIB channel number. + */ +#define UICR_PPIB_PUBLISH_RECEIVE_ENABLE(_ppib, _ppib_ch) \ + UICR_PERIPHCONF_ADD((uint32_t)&((NRF_PPIB_Type *)(_ppib))->PUBLISH_RECEIVE[(_ppib_ch)], \ + (uint32_t)PPIB_PUBLISH_RECEIVE_EN_Msk) + +/* The definitions below are not currently available in the MDK but are needed for the macros + * above. When they are, this can be deleted. + */ +#ifndef IPCMAP_CHANNEL_SOURCE_SOURCE_Msk + +typedef struct { + __IOM uint32_t SOURCE; + __IOM uint32_t SINK; +} NRF_IPCMAP_CHANNEL_Type; + +#define IPCMAP_CHANNEL_SOURCE_SOURCE_Pos (0UL) +#define IPCMAP_CHANNEL_SOURCE_SOURCE_Msk (0xFUL << IPCMAP_CHANNEL_SOURCE_SOURCE_Pos) +#define IPCMAP_CHANNEL_SOURCE_DOMAIN_Pos (8UL) +#define IPCMAP_CHANNEL_SOURCE_DOMAIN_Msk (0xFUL << IPCMAP_CHANNEL_SOURCE_DOMAIN_Pos) +#define IPCMAP_CHANNEL_SOURCE_ENABLE_Pos (31UL) +#define IPCMAP_CHANNEL_SOURCE_ENABLE_Disabled (0x0UL) +#define IPCMAP_CHANNEL_SOURCE_ENABLE_Enabled (0x1UL) +#define IPCMAP_CHANNEL_SINK_SINK_Pos (0UL) +#define IPCMAP_CHANNEL_SINK_SINK_Msk (0xFUL << IPCMAP_CHANNEL_SINK_SINK_Pos) +#define IPCMAP_CHANNEL_SINK_DOMAIN_Pos (8UL) +#define IPCMAP_CHANNEL_SINK_DOMAIN_Msk (0xFUL << IPCMAP_CHANNEL_SINK_DOMAIN_Pos) + +typedef struct { + __IM uint32_t RESERVED[256]; + __IOM NRF_IPCMAP_CHANNEL_Type CHANNEL[16]; +} NRF_IPCMAP_Type; + +#endif /* IPCMAP_CHANNEL_SOURCE_SOURCE_Msk */ + +#ifndef NRF_IPCMAP +#define NRF_IPCMAP ((NRF_IPCMAP_Type *)0x5F923000UL) +#endif + +#ifndef IRQMAP_IRQ_SINK_PROCESSORID_Msk + +typedef struct { + __IOM uint32_t SINK; +} NRF_IRQMAP_IRQ_Type; + +#define IRQMAP_IRQ_SINK_PROCESSORID_Pos (8UL) +#define IRQMAP_IRQ_SINK_PROCESSORID_Msk (0xFUL << IRQMAP_IRQ_SINK_PROCESSORID_Pos) + +typedef struct { + __IM uint32_t RESERVED[256]; + __IOM NRF_IRQMAP_IRQ_Type IRQ[480]; +} NRF_IRQMAP_Type; + +#endif /* IRQMAP_IRQ_SINK_PROCESSORID_Msk */ + +#ifndef NRF_IRQMAP +#define NRF_IRQMAP ((NRF_IRQMAP_Type *)0x5F924000UL) +#endif /* NRF_IRQMAP */ + +#ifndef GPIO_PIN_CNF_CTRLSEL_Pos + +#define GPIO_PIN_CNF_CTRLSEL_Pos (28UL) +#define GPIO_PIN_CNF_CTRLSEL_Msk (0x7UL << GPIO_PIN_CNF_CTRLSEL_Pos) +#define GPIO_PIN_CNF_CTRLSEL_Min (0x0UL) +#define GPIO_PIN_CNF_CTRLSEL_Max (0x7UL) +#define GPIO_PIN_CNF_CTRLSEL_GPIO (0x0UL) +#define GPIO_PIN_CNF_CTRLSEL_VPR (0x1UL) +#define GPIO_PIN_CNF_CTRLSEL_GRC (0x1UL) +#define GPIO_PIN_CNF_CTRLSEL_SecureDomain (0x2UL) +#define GPIO_PIN_CNF_CTRLSEL_PWM (0x2UL) +#define GPIO_PIN_CNF_CTRLSEL_I3C (0x2UL) +#define GPIO_PIN_CNF_CTRLSEL_Serial (0x3UL) +#define GPIO_PIN_CNF_CTRLSEL_HSSPI (0x3UL) +#define GPIO_PIN_CNF_CTRLSEL_RadioCore (0x4UL) +#define GPIO_PIN_CNF_CTRLSEL_EXMIF (0x4UL) +#define GPIO_PIN_CNF_CTRLSEL_CELL (0x4UL) +#define GPIO_PIN_CNF_CTRLSEL_DTB (0x6UL) +#define GPIO_PIN_CNF_CTRLSEL_TND (0x7UL) + +#endif /* GPIO_PIN_CNF_CTRLSEL_Pos */ + +#endif /* SOC_NORDIC_COMMON_UICR_UICR_H_ */ diff --git a/soc/nordic/common/uicr/uicr.ld b/soc/nordic/common/uicr/uicr.ld new file mode 100644 index 000000000000..210495b1c66c --- /dev/null +++ b/soc/nordic/common/uicr/uicr.ld @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +SECTION_PROLOGUE(uicr_periphconf_entry,(COPY),SUBALIGN(Z_LINK_ITERABLE_SUBALIGN)) +{ + Z_LINK_ITERABLE(uicr_periphconf_entry); +} GROUP_ROM_LINK_IN(DEVNULL_REGION, DEVNULL_REGION) diff --git a/soc/nordic/nrf53/Kconfig b/soc/nordic/nrf53/Kconfig index 8aade63f54a1..1a747bec9ea6 100644 --- a/soc/nordic/nrf53/Kconfig +++ b/soc/nordic/nrf53/Kconfig @@ -167,12 +167,32 @@ config NRF_SPU_FLASH_REGION_SIZE help FLASH region size for the NRF_SPU peripheral +config NRF_TRUSTZONE_FLASH_REGION_SIZE + hex + default NRF_SPU_FLASH_REGION_SIZE + help + Define the flash region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + config NRF_SPU_RAM_REGION_SIZE hex default 0x2000 help RAM region size for the NRF_SPU peripheral +config NRF_TRUSTZONE_RAM_REGION_SIZE + hex + default NRF_SPU_RAM_REGION_SIZE + help + Define the RAM region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + config SOC_NRF_GPIO_FORWARDER_FOR_NRF5340 bool "Forward GPIO pins to network core" depends on NRF_SOC_SECURE_SUPPORTED diff --git a/soc/nordic/nrf54h/CMakeLists.txt b/soc/nordic/nrf54h/CMakeLists.txt index 23c1cab1e77a..a7deb7d66de2 100644 --- a/soc/nordic/nrf54h/CMakeLists.txt +++ b/soc/nordic/nrf54h/CMakeLists.txt @@ -9,6 +9,7 @@ if(CONFIG_ARM) endif() zephyr_library_sources_ifdef(CONFIG_PM_S2RAM pm_s2ram.c) +zephyr_library_sources_ifdef(CONFIG_NRF_PERIPHCONF_SECTION uicr_periphconf_table.c) zephyr_include_directories(.) diff --git a/soc/nordic/nrf54h/Kconfig b/soc/nordic/nrf54h/Kconfig index c0e619cd1e2d..f9ed41ee3211 100644 --- a/soc/nordic/nrf54h/Kconfig +++ b/soc/nordic/nrf54h/Kconfig @@ -8,8 +8,8 @@ config SOC_SERIES_NRF54HX select HAS_NRFX select HAS_NORDIC_DRIVERS select SOC_EARLY_INIT_HOOK if ARM - select SOC_LATE_INIT_HOOK if SOC_NRF54H20_CPURAD_ENABLE select NRF_PLATFORM_HALTIUM + select EXPERIMENTAL if MCUBOOT config SOC_NRF54H20_CPUAPP_COMMON bool @@ -67,16 +67,35 @@ config SOC_NRF54H20_CPURAD_COMMON select HAS_PM select HAS_POWEROFF +config SOC_NRF54H20_TDD_ENABLE + bool "Power and configure the trace and debug domain (TDD)" + depends on SOC_NRF54H20_CPUAPP + select NRF_IRONSIDE_TDD_SERVICE + select SOC_LATE_INIT_HOOK + help + This will at application boot time request that the trace and + debug domain (TDD) is powered up and configured. + This allows configuring the coresight peripherals from + the application domain. + config SOC_NRF54H20_CPURAD_ENABLE bool "Boot the nRF54H20 Radio core" default y if NRF_802154_SER_HOST depends on SOC_NRF54H20_CPUAPP select NRF_IRONSIDE_CPUCONF_SERVICE + select SOC_LATE_INIT_HOOK help This will at application boot time enable clock to the Radiocore, and also power will be requested to the Radiocore subsystem. The Radiocore will then start executing instructions. +config SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR + bool "Check VTOR before booting Radio core" + default y + depends on SOC_NRF54H20_CPURAD_ENABLE + help + Verify that VTOR is not 0xFFFFFFFF before booting the Radiocore. + config SOC_NRF54H20_CPURAD select SOC_NRF54H20_CPURAD_COMMON @@ -88,6 +107,3 @@ config SOC_NRF54H20_CPUFLPR rsource "bicr/Kconfig" rsource "gpd/Kconfig" - -config SOC_NRF54H20_IRON - select EXPERIMENTAL if MCUBOOT diff --git a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp index 595cc2d38860..69bde826ba41 100644 --- a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp +++ b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp @@ -8,9 +8,6 @@ if SOC_NRF54H20_CPUAPP config NUM_IRQS default 471 -config NRF_REGTOOL_GENERATE_UICR - default y - config SHELL_BACKEND_SERIAL default n if NRF_ETR_SHELL diff --git a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpurad b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpurad index 1fffdeae6d2e..8f86835b92c5 100644 --- a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpurad +++ b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpurad @@ -8,9 +8,6 @@ if SOC_NRF54H20_CPURAD config NUM_IRQS default 471 -config NRF_REGTOOL_GENERATE_UICR - default y - config PM default y diff --git a/soc/nordic/nrf54h/Kconfig.soc b/soc/nordic/nrf54h/Kconfig.soc index ac9101c177ca..459854e13b2d 100644 --- a/soc/nordic/nrf54h/Kconfig.soc +++ b/soc/nordic/nrf54h/Kconfig.soc @@ -33,10 +33,5 @@ config SOC_NRF54H20_CPUFLPR help nRF54H20 CPUFLPR -config SOC_NRF54H20_IRON - bool - help - Indicates that local domain firmware is compatible with Nordic IRONside SE. - config SOC default "nrf54h20" if SOC_NRF54H20 diff --git a/soc/nordic/nrf54h/pm_s2ram.c b/soc/nordic/nrf54h/pm_s2ram.c index c18c9650cdce..1ec5da4aa199 100644 --- a/soc/nordic/nrf54h/pm_s2ram.c +++ b/soc/nordic/nrf54h/pm_s2ram.c @@ -180,48 +180,23 @@ int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off) return ret; } -void __attribute__((naked)) pm_s2ram_mark_set(void) +void pm_s2ram_mark_set(void) { /* empty */ - __asm__ volatile("bx lr\n"); } -bool __attribute__((naked)) pm_s2ram_mark_check_and_clear(void) +bool pm_s2ram_mark_check_and_clear(void) { - __asm__ volatile( - /* Set return value to 0 */ - "mov r0, #0\n" + bool restore_valid; + uint32_t reset_reason = nrf_resetinfo_resetreas_local_get(NRF_RESETINFO); - /* Load and check RESETREAS register */ - "ldr r3, [%[resetinfo_addr], %[resetreas_offs]]\n" - "cmp r3, %[resetreas_unretained_mask]\n" - - "bne exit\n" - - /* Clear RESETREAS register */ - "str r0, [%[resetinfo_addr], %[resetreas_offs]]\n" - - /* Load RESTOREVALID register */ - "ldr r3, [%[resetinfo_addr], %[restorevalid_offs]]\n" - - /* Clear RESTOREVALID */ - "str r0, [%[resetinfo_addr], %[restorevalid_offs]]\n" - - /* Check RESTOREVALID register */ - "cmp r3, %[restorevalid_present_mask]\n" - "bne exit\n" - - /* Set return value to 1 */ - "mov r0, #1\n" + if (reset_reason != NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK) { + return false; + } + nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, 0); - "exit:\n" - "bx lr\n" - : - : [resetinfo_addr] "r"(NRF_RESETINFO), - [resetreas_offs] "r"(offsetof(NRF_RESETINFO_Type, RESETREAS.LOCAL)), - [resetreas_unretained_mask] "r"(NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK), - [restorevalid_offs] "r"(offsetof(NRF_RESETINFO_Type, RESTOREVALID)), - [restorevalid_present_mask] "r"(RESETINFO_RESTOREVALID_RESTOREVALID_Msk) + restore_valid = nrf_resetinfo_restore_valid_check(NRF_RESETINFO); + nrf_resetinfo_restore_valid_set(NRF_RESETINFO, false); - : "r0", "r1", "r3", "r4", "memory"); + return restore_valid ? true : false; } diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index c1849ab3a239..944cf4bca1c0 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -22,7 +22,9 @@ #include #include #include +#include #include +#include LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); @@ -32,6 +34,15 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); #define HSFLL_NODE DT_NODELABEL(cpurad_hsfll) #endif +#ifdef CONFIG_USE_DT_CODE_PARTITION +#define FLASH_LOAD_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) +#elif defined(CONFIG_FLASH_LOAD_OFFSET) +#define FLASH_LOAD_OFFSET CONFIG_FLASH_LOAD_OFFSET +#endif + +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + (DT_REG_ADDR(DT_NODELABEL(label)) == FLASH_LOAD_OFFSET) + sys_snode_t soc_node; #define FICR_ADDR_GET(node_id, name) \ @@ -44,8 +55,6 @@ sys_snode_t soc_node; ADDRESS_DOMAIN_Msk | \ ADDRESS_BUS_Msk))) -#define DT_NODELABEL_CPURAD_SLOT0_PARTITION DT_NODELABEL(cpurad_slot0_partition) - static void power_domain_init(void) { /* @@ -153,16 +162,34 @@ void soc_early_init_hook(void) nrf_spu_periph_perm_dmasec_set(spu, nrf_address_slave_get(ccm030_addr), true); #endif - if (DT_NODE_HAS_STATUS(DT_NODELABEL(nfct), disabled) && + if (((IS_ENABLED(CONFIG_SOC_NRF54H20_CPUAPP) && + DT_NODE_HAS_STATUS(DT_NODELABEL(nfct), disabled)) || + DT_NODE_HAS_STATUS(DT_NODELABEL(nfct), reserved)) && DT_PROP_OR(DT_NODELABEL(nfct), nfct_pins_as_gpios, 0)) { nrf_nfct_pad_config_enable_set(NRF_NFCT, false); } } -#if defined(CONFIG_SOC_NRF54H20_CPURAD_ENABLE) +#if defined(CONFIG_SOC_LATE_INIT_HOOK) + void soc_late_init_hook(void) { - int err; +#if defined(CONFIG_SOC_NRF54H20_TDD_ENABLE) + int err_tdd; + + err_tdd = ironside_se_tdd_configure(IRONSIDE_SE_TDD_CONFIG_ON_DEFAULT); + __ASSERT(err_tdd == 0, "err_tdd was %d", err_tdd); + + UICR_GPIO_PIN_CNF_CTRLSEL_SET(NRF_P7, 3, GPIO_PIN_CNF_CTRLSEL_TND); + UICR_GPIO_PIN_CNF_CTRLSEL_SET(NRF_P7, 4, GPIO_PIN_CNF_CTRLSEL_TND); + UICR_GPIO_PIN_CNF_CTRLSEL_SET(NRF_P7, 5, GPIO_PIN_CNF_CTRLSEL_TND); + UICR_GPIO_PIN_CNF_CTRLSEL_SET(NRF_P7, 6, GPIO_PIN_CNF_CTRLSEL_TND); + UICR_GPIO_PIN_CNF_CTRLSEL_SET(NRF_P7, 7, GPIO_PIN_CNF_CTRLSEL_TND); + +#endif + +#if defined(CONFIG_SOC_NRF54H20_CPURAD_ENABLE) + int err_cpuconf; /* The msg will be used for communication prior to IPC * communication being set up. But at this moment no such @@ -170,16 +197,41 @@ void soc_late_init_hook(void) */ uint8_t *msg = NULL; size_t msg_size = 0; + void *radiocore_address = NULL; + +#if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition)) + if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { + radiocore_address = + (void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot1_partition))) + + DT_REG_ADDR(DT_NODELABEL(cpurad_slot1_partition)) + + CONFIG_ROM_START_OFFSET); + } else { + radiocore_address = + (void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) + + DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) + + CONFIG_ROM_START_OFFSET); + } +#else + radiocore_address = + (void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) + + DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) + + CONFIG_ROM_START_OFFSET); +#endif + + if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) && + sys_read32((mem_addr_t)radiocore_address) == 0xFFFFFFFFUL) { + LOG_ERR("Radiocore is not programmed, it will not be started"); - void *radiocore_address = - (void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL_CPURAD_SLOT0_PARTITION)) + - DT_REG_ADDR(DT_NODELABEL_CPURAD_SLOT0_PARTITION)); + return; + } /* Don't wait as this is not yet supported. */ bool cpu_wait = false; - err = ironside_cpuconf(NRF_PROCESSOR_RADIOCORE, radiocore_address, cpu_wait, msg, msg_size); - __ASSERT(err == 0, "err was %d", err); + err_cpuconf = ironside_cpuconf(NRF_PROCESSOR_RADIOCORE, radiocore_address, cpu_wait, msg, + msg_size); + __ASSERT(err_cpuconf == 0, "err_cpuconf was %d", err_cpuconf); +#endif } #endif diff --git a/soc/nordic/nrf54h/uicr_periphconf_table.c b/soc/nordic/nrf54h/uicr_periphconf_table.c new file mode 100644 index 000000000000..bf7f85402a60 --- /dev/null +++ b/soc/nordic/nrf54h/uicr_periphconf_table.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include + +#define SPU131_ADDR (0x5F920000UL) +#define SPU133_ADDR (0x5F990000UL) +#define PPIB130_ADDR (0x5f925000UL) +#define PPIB133_ADDR (0x5f99d000UL) + +/* GRTC channels used by the radio core. */ +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 8, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 9, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 10, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 11, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 12, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 13, true, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 14, true, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_GRTC_CC_SET(SPU133_ADDR, 15, true, NRF_OWNER_RADIOCORE); + +/* DPPIC130 channels used by the radio core. */ +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU131_ADDR, 0, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU131_ADDR, 2, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU131_ADDR, 3, false, NRF_OWNER_RADIOCORE); + +/* DPPIC132 channels used by the radio core. */ +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU133_ADDR, 0, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU133_ADDR, 2, false, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_DPPIC_CH_SET(SPU133_ADDR, 3, false, NRF_OWNER_RADIOCORE); + +/* Link (DPPIC130 ch.0) <== (DPPIC132 ch.0) */ +UICR_PPIB_PUBLISH_RECEIVE_ENABLE(PPIB130_ADDR, 8); +UICR_PPIB_SUBSCRIBE_SEND_ENABLE(PPIB133_ADDR, 0); + +/* Link (DPPIC130 ch.2) <== (DPPIC132 ch.2) */ +UICR_PPIB_PUBLISH_RECEIVE_ENABLE(PPIB130_ADDR, 10); +UICR_PPIB_SUBSCRIBE_SEND_ENABLE(PPIB133_ADDR, 2); + +/* Link (DPPIC130 ch.3) ==> (DPPIC132 ch.3) */ +UICR_PPIB_SUBSCRIBE_SEND_ENABLE(PPIB130_ADDR, 11); +UICR_PPIB_PUBLISH_RECEIVE_ENABLE(PPIB133_ADDR, 3); + +/* IPCT channels used by the radio core. */ +UICR_SPU_FEATURE_IPCT_CH_SET(SPU131_ADDR, 0, true, NRF_OWNER_RADIOCORE); +UICR_SPU_FEATURE_IPCT_CH_SET(SPU131_ADDR, 2, true, NRF_OWNER_RADIOCORE); + +/* Cross-domain mapping of the IPCT channels. */ +UICR_IPCMAP_CHANNEL_CFG(0, NRF_DOMAIN_RADIOCORE, 2, NRF_DOMAIN_GLOBALSLOW, 2); +UICR_IPCMAP_CHANNEL_CFG(1, NRF_DOMAIN_GLOBALSLOW, 0, NRF_DOMAIN_RADIOCORE, 0); +UICR_IPCMAP_CHANNEL_CFG(2, NRF_DOMAIN_GLOBALSLOW, 2, NRF_DOMAIN_RADIOCORE, 2); diff --git a/soc/nordic/nrf54l/CMakeLists.txt b/soc/nordic/nrf54l/CMakeLists.txt index cebbda571b68..d986fe9c20d5 100644 --- a/soc/nordic/nrf54l/CMakeLists.txt +++ b/soc/nordic/nrf54l/CMakeLists.txt @@ -6,3 +6,12 @@ zephyr_library_sources( ../validate_rram_partitions.c ) zephyr_include_directories(.) + +# We need a buffer in memory in a static location which can be used by +# the KMU peripheral. The KMU has a static destination address, we chose +# this address to be 0x20000000, which is the first address in the SRAM. +if(NOT CONFIG_BUILD_WITH_TFM AND CONFIG_PSA_NEED_CRACEN_KMU_DRIVER AND CONFIG_XIP) +# Exclamation mark is printable character with the lowest number in ASCII table. +# We are sure that this file will be included first. +zephyr_linker_sources(RAM_SECTIONS SORT_KEY ! kmu_push_area_section.ld) +endif() diff --git a/soc/nordic/nrf54l/Kconfig b/soc/nordic/nrf54l/Kconfig index 6dc5e9f13cd3..c37d596d0f00 100644 --- a/soc/nordic/nrf54l/Kconfig +++ b/soc/nordic/nrf54l/Kconfig @@ -56,10 +56,18 @@ config SOC_NRF54L20_ENGA_CPUFLPR if SOC_SERIES_NRF54LX config SOC_NRF54LX_SKIP_CLOCK_CONFIG - bool "Skip clock frequency configuration in system initialization" + bool + prompt "Skip clock frequency configuration in system initialization" if TRUSTED_EXECUTION_SECURE + default y if TRUSTED_EXECUTION_NONSECURE help - With this option, the CPU clock frequency is not set during system initialization. - The CPU runs with the default, hardware-selected frequency. + With this option, the CPU clock frequency is not set during this + Zephyr image's system initialization. The CPU runs with either + the HW reset values, or with the configuration set by an image + earlier in the boot chain. + + Note that for security reasons it is not supported to configure + the clock peripheral (NRF_OSCILLATORS) from the non-secure + domain. config SOC_NRF54LX_DISABLE_FICR_TRIMCNF bool "Disable trimming of the device" @@ -84,4 +92,10 @@ config SOC_NRF_FORCE_CONSTLAT of base resources on while in sleep. The advantage of having a constant and predictable latency will be at the cost of having increased power consumption. +config SOC_NRF54L_ANOMALY_56_WORKAROUND + bool "Apply workaround 56 for nRF54L SoCs" + default y + help + This option enables configuration workaround 56 for nRF54L Series SoCs. + endif # SOC_SERIES_NRF54LX diff --git a/soc/nordic/nrf54l/kmu_push_area_section.ld b/soc/nordic/nrf54l/kmu_push_area_section.ld new file mode 100644 index 000000000000..e8c8cd9f09ad --- /dev/null +++ b/soc/nordic/nrf54l/kmu_push_area_section.ld @@ -0,0 +1,19 @@ +# This section must be loaded first of all the +# custom sections because we want it to be placed +# at the top address of RAM. +SECTION_PROLOGUE(NRF_KMU_RESERVED_PUSH_SECTION,(NOLOAD) ,) +{ + __nrf_kmu_reserved_push_area = .; + *(.nrf_kmu_reserved_push_area) + __nrf_kmu_reserved_push_area_end = .; +} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION) + +# It doesn't seem to be possible to enforce placing a section +# at a specific address in memory using the Zephyr SECTION macros. +# So this assert is necessary to avoid accidentatly moving this +# section to a different address. +ASSERT(__nrf_kmu_reserved_push_area == RAM_ADDR, "Error: \ + The section NRF_KMU_RESERVED_PUSH_SECTION needs to be \ + placed on the top RAM address but it is not, please edit \ + your linker scripts to make sure that it is placed on \ + the to RAM address.") diff --git a/soc/nordic/nrf91/Kconfig b/soc/nordic/nrf91/Kconfig index ed38eff73a2d..9f55cdd77ed9 100644 --- a/soc/nordic/nrf91/Kconfig +++ b/soc/nordic/nrf91/Kconfig @@ -24,6 +24,16 @@ config NRF_SPU_FLASH_REGION_SIZE help FLASH region size for the NRF_SPU peripheral +config NRF_TRUSTZONE_FLASH_REGION_SIZE + hex + default NRF_SPU_FLASH_REGION_SIZE + help + Define the flash region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + config NRF_SPU_RAM_REGION_SIZE hex default 0x2000 @@ -34,4 +44,14 @@ config NRF_ENABLE_ICACHE bool "Instruction cache (I-Cache)" default y +config NRF_TRUSTZONE_RAM_REGION_SIZE + hex + default NRF_SPU_RAM_REGION_SIZE + help + Define the RAM region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + endif # SOC_SERIES_NRF91X diff --git a/soc/nordic/nrf92/Kconfig b/soc/nordic/nrf92/Kconfig index 7fdf57d61c39..a7769c00b6f2 100644 --- a/soc/nordic/nrf92/Kconfig +++ b/soc/nordic/nrf92/Kconfig @@ -7,6 +7,7 @@ config SOC_SERIES_NRF92X select HAS_NRFS select HAS_NRFX select HAS_NORDIC_DRIVERS + select SOC_EARLY_INIT_HOOK if ARM select NRF_PLATFORM_HALTIUM config SOC_NRF9230_ENGB_CPUAPP @@ -48,3 +49,6 @@ config SOC_NRF9230_ENGB_CPURAD config SOC_NRF9230_ENGB_CPUPPR select RISCV_CORE_NORDIC_VPR + +config SOC_NRF9280_IRON + select EXPERIMENTAL if MCUBOOT diff --git a/soc/nordic/nrf92/Kconfig.soc b/soc/nordic/nrf92/Kconfig.soc index 99fc28643b74..6ad2fb8a0147 100644 --- a/soc/nordic/nrf92/Kconfig.soc +++ b/soc/nordic/nrf92/Kconfig.soc @@ -62,5 +62,10 @@ config SOC_NRF9280_CPUPPR help nRF9280 CPUPPR +config SOC_NRF9280_IRON + bool + help + Indicates that local domain firmware is compatible with Nordic IronSide SE. + config SOC default "nrf9280" if SOC_NRF9280 diff --git a/soc/nordic/nrf92/soc.c b/soc/nordic/nrf92/soc.c index d9a54e4f1aa6..3652b554711a 100644 --- a/soc/nordic/nrf92/soc.c +++ b/soc/nordic/nrf92/soc.c @@ -84,7 +84,7 @@ static int trim_hsfll(void) return 0; } -static int nordicsemi_nrf92_init(void) +void soc_early_init_hook(void) { sys_cache_instr_enable(); sys_cache_data_enable(); @@ -102,13 +102,9 @@ static int nordicsemi_nrf92_init(void) nrf_spu_periph_perm_dmasec_set(spu, nrf_address_slave_get(ccm030_addr), true); #endif - - return 0; } void arch_busy_wait(uint32_t time_us) { nrfx_coredep_delay_us(time_us); } - -SYS_INIT(nordicsemi_nrf92_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); diff --git a/soc/nordic/validate_base_addresses.c b/soc/nordic/validate_base_addresses.c index 9de947a5c7f6..f3c9c8bf2145 100644 --- a/soc/nordic/validate_base_addresses.c +++ b/soc/nordic/validate_base_addresses.c @@ -199,6 +199,8 @@ CHECK_DT_REG(i2c3, NRF_TWIM3); CHECK_DT_REG(i2c20, NRF_TWIM20); CHECK_DT_REG(i2c21, NRF_TWIM21); CHECK_DT_REG(i2c22, NRF_TWIM22); +CHECK_DT_REG(i2c23, NRF_TWIM23); +CHECK_DT_REG(i2c24, NRF_TWIM24); CHECK_DT_REG(i2c30, NRF_TWIM30); CHECK_DT_REG(i2c130, NRF_TWIM130); CHECK_DT_REG(i2c131, NRF_TWIM131); @@ -266,6 +268,8 @@ CHECK_DT_REG(spi00, NRF_SPIM00); CHECK_DT_REG(spi20, NRF_SPIM20); CHECK_DT_REG(spi21, NRF_SPIM21); CHECK_DT_REG(spi22, NRF_SPIM22); +CHECK_DT_REG(spi23, NRF_SPIM23); +CHECK_DT_REG(spi24, NRF_SPIM24); CHECK_DT_REG(spi30, NRF_SPIM30); CHECK_DT_REG(spi120, NRF_SPIM120); CHECK_DT_REG(spi121, NRF_SPIM121); @@ -319,6 +323,8 @@ CHECK_DT_REG(uart00, NRF_UARTE00); CHECK_DT_REG(uart20, NRF_UARTE20); CHECK_DT_REG(uart21, NRF_UARTE21); CHECK_DT_REG(uart22, NRF_UARTE22); +CHECK_DT_REG(uart23, NRF_UARTE23); +CHECK_DT_REG(uart24, NRF_UARTE24); CHECK_DT_REG(uart30, NRF_UARTE30); CHECK_DT_REG(uart120, NRF_UARTE120); CHECK_DT_REG(uart130, NRF_UARTE130); @@ -329,7 +335,11 @@ CHECK_DT_REG(uart134, NRF_UARTE134); CHECK_DT_REG(uart135, NRF_UARTE135); CHECK_DT_REG(uart136, NRF_UARTE136); CHECK_DT_REG(uart137, NRF_UARTE137); +#if !defined(CONFIG_SOC_SERIES_NRF54HX) CHECK_DT_REG(uicr, NRF_UICR); +#else +CHECK_DT_REG(uicr, NRF_APPLICATION_UICR); +#endif CHECK_DT_REG(cpuapp_uicr, NRF_APPLICATION_UICR); CHECK_DT_REG(bicr, NRF_APPLICATION_BICR); CHECK_DT_REG(cpurad_uicr, NRF_RADIOCORE_UICR); diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 2cc9600d27f0..60726163581c 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -143,10 +143,12 @@ config BT_CTLR the HAS_BT_CTLR option. config BT_LL_SW_SPLIT - bool "Software-based Bluetooth LE Link Layer" + bool "Software-based Bluetooth LE Link Layer [EXPERIMENTAL]" default y depends on DT_HAS_ZEPHYR_BT_HCI_LL_SW_SPLIT_ENABLED select HAS_BT_CTLR + select EXPERIMENTAL + select ENTROPY_GENERATOR help Use Zephyr software Bluetooth LE Link Layer ULL LLL split implementation. diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c index d3e1f77b3553..f93ea59f38e3 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c @@ -62,7 +62,7 @@ static struct { /* FIXME: This could probably use a chosen entropy device instead on relying on * the nodelabel being the same as for the old nrf rng. */ -static const struct device *const dev_entropy = DEVICE_DT_GET(DT_NODELABEL(rng)); +static const struct device *const dev_entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); #endif /* CONFIG_ENTROPY_HAS_DRIVER */ static int init_reset(void); diff --git a/subsys/bluetooth/crypto/Kconfig b/subsys/bluetooth/crypto/Kconfig index 0856daf9d9a5..0f46a0f59a0f 100644 --- a/subsys/bluetooth/crypto/Kconfig +++ b/subsys/bluetooth/crypto/Kconfig @@ -8,6 +8,7 @@ config BT_CRYPTO select PSA_WANT_KEY_TYPE_AES select PSA_WANT_ALG_CMAC select PSA_WANT_ALG_ECB_NO_PADDING + imply MBEDTLS_CIPHER_AES_ENABLED if !BUILD_WITH_TFM imply MBEDTLS_AES_ROM_TABLES if MBEDTLS_PSA_CRYPTO_C help This option enables the Bluetooth Cryptographic Toolbox. diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 7611761bb453..3830745417ae 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -630,6 +630,24 @@ config BT_ID_UNPAIR_MATCHING_BONDS link-layer. The Host does not have control over this acknowledgment, and the order of distribution is fixed by the specification. +config BT_ID_AUTO_SWAP_MATCHING_BONDS + bool "Automatically swap conflicting entries in the Resolving List" + depends on !BT_ID_UNPAIR_MATCHING_BONDS + depends on BT_PRIVACY && BT_PERIPHERAL && !BT_CENTRAL + help + If this option is enabled, the Host will not add a new bond with + the same peer address (or IRK) to the Resolving List if there is + already a bond with the same peer address (or IRK) on another local + identity. + + In case of Peripheral, the Host will swap the existing entry in the + Resolving List with the new one, so that the new bond will be used for + address resolution for the new local identity if the device starts + advertising with the new local identity. + + Important: this option is supported exclusively in the Peripheral + role. Excluding the Central role. + config BT_ID_ALLOW_UNAUTH_OVERWRITE bool "Allow unauthenticated pairing with same peer with other local identity" depends on !BT_SMP_ALLOW_UNAUTH_OVERWRITE diff --git a/subsys/bluetooth/host/Kconfig.gatt b/subsys/bluetooth/host/Kconfig.gatt index a04241a3e94f..221bc413c4bc 100644 --- a/subsys/bluetooth/host/Kconfig.gatt +++ b/subsys/bluetooth/host/Kconfig.gatt @@ -38,6 +38,23 @@ config BT_ATT_RETRY_ON_SEC_ERR If an ATT request fails due to insufficient security, the host will try to elevate the security level and retry the ATT request. +config BT_ATT_SENT_CB_AFTER_TX + bool "Delay ATT sent callback until data transmission is done by controller [EXPERIMENTAL]" + select EXPERIMENTAL + help + By default, the BLE stack calls sent callback for ATT data when the + data is passed to BLE controller for transmission. Enabling this + Kconfig option delays calling the sent callback until data + transmission is finished by BLE controller (the callback is called + upon receiving the Number of Completed Packets HCI Event). + + The feature is not available in Zephyr RTOS (it's specific to NCS + Zephyr fork). It is a temporary solution allowing to control flow of + GATT notifications with HID reports for HID use-case. + + Enabling this option may require increasing CONFIG_BT_CONN_TX_MAX in + configuration, because ATT would use additional TX contexts. + config BT_EATT bool "Enhanced ATT Bearers support [EXPERIMENTAL]" depends on BT_L2CAP_ECRED diff --git a/subsys/bluetooth/host/Kconfig.l2cap b/subsys/bluetooth/host/Kconfig.l2cap index 2841e7d8a129..34e862378c5e 100644 --- a/subsys/bluetooth/host/Kconfig.l2cap +++ b/subsys/bluetooth/host/Kconfig.l2cap @@ -52,7 +52,7 @@ config BT_L2CAP_DYNAMIC_CHANNEL allowing the creation of dynamic L2CAP Channels. config BT_L2CAP_ECRED - bool "L2CAP Enhanced Credit Based Flow Control support" + bool "L2CAP Enhanced Credit Based Flow Control support [EXPERIMENTAL]" depends on BT_L2CAP_DYNAMIC_CHANNEL help This option enables support for LE Connection oriented Channels with diff --git a/subsys/bluetooth/host/adv.c b/subsys/bluetooth/host/adv.c index 0694c2ce54b3..64f8915b363d 100644 --- a/subsys/bluetooth/host/adv.c +++ b/subsys/bluetooth/host/adv.c @@ -272,6 +272,25 @@ struct bt_le_ext_adv *bt_hci_adv_lookup_handle(uint8_t handle) #endif /* CONFIG_BT_BROADCASTER */ #endif /* defined(CONFIG_BT_EXT_ADV) */ +struct bt_le_ext_adv *bt_adv_lookup_by_id(uint8_t id) +{ +#if defined(CONFIG_BT_EXT_ADV) + for (size_t i = 0; i < ARRAY_SIZE(adv_pool); i++) { + if (atomic_test_bit(adv_pool[i].flags, BT_ADV_CREATED) && + adv_pool[i].id == id) { + return &adv_pool[i]; + } + } +#else + if (atomic_test_bit(bt_dev.adv.flags, BT_ADV_CREATED) && bt_dev.adv.id == id) { + return &bt_dev.adv; + } +#endif + + return NULL; +} + + void bt_le_ext_adv_foreach(void (*func)(struct bt_le_ext_adv *adv, void *data), void *data) { @@ -1021,6 +1040,14 @@ int bt_le_adv_start_legacy(struct bt_le_ext_adv *adv, adv->id = param->id; bt_dev.adv_conn_id = adv->id; + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + err = bt_id_resolving_list_check_and_update(adv->id, param->peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + err = bt_id_set_adv_own_addr(adv, param->options, dir_adv, &set_param.own_addr_type); if (err) { @@ -1336,6 +1363,15 @@ int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, } adv->id = param->id; + + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + err = bt_id_resolving_list_check_and_update(adv->id, param->peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + err = le_ext_adv_param_set(adv, param, sd != NULL); if (err) { return err; @@ -1691,6 +1727,22 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, return -EALREADY; } + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + const bt_addr_le_t *peer; + + if (bt_addr_le_eq(&adv->target_addr, BT_ADDR_LE_ANY)) { + peer = NULL; + } else { + peer = &adv->target_addr; + } + + err = bt_id_resolving_list_check_and_update(adv->id, peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && atomic_test_bit(adv->flags, BT_ADV_CONNECTABLE)) { err = le_adv_start_add_conn(adv, &conn); diff --git a/subsys/bluetooth/host/adv.h b/subsys/bluetooth/host/adv.h index 65ad51135ce0..1bd15854db28 100644 --- a/subsys/bluetooth/host/adv.h +++ b/subsys/bluetooth/host/adv.h @@ -25,3 +25,4 @@ int bt_le_adv_set_enable_ext(struct bt_le_ext_adv *adv, int bt_le_adv_set_enable_legacy(struct bt_le_ext_adv *adv, bool enable); int bt_le_lim_adv_cancel_timeout(struct bt_le_ext_adv *adv); void bt_adv_reset_adv_pool(void); +struct bt_le_ext_adv *bt_adv_lookup_by_id(uint8_t id); diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index 98b310f4b4b0..7fac12a6fb97 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -328,6 +328,13 @@ static void att_disconnect(struct bt_att_chan *chan) } } +static void chan_sent_cb(struct bt_conn *conn, void *user_data, int err) +{ + struct net_buf *nb = user_data; + + net_buf_unref(nb); +} + /* In case of success the ownership of the buffer is transferred to the stack * which takes care of releasing it when it completes transmitting to the * controller. @@ -421,7 +428,15 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf) data->att_chan = chan; - err = bt_l2cap_send_pdu(&chan->chan, buf, NULL, NULL); + if (IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX)) { + err = bt_l2cap_send_pdu(&chan->chan, buf, chan_sent_cb, net_buf_ref(buf)); + if (err) { + net_buf_unref(buf); + } + } else { + err = bt_l2cap_send_pdu(&chan->chan, buf, NULL, NULL); + } + if (err) { if (err == -ENOBUFS) { LOG_ERR("Ran out of TX buffers or contexts."); diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index a7aca69fa9d9..6d8939eca36f 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -698,7 +698,17 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf, uint16_t frag_len = MIN(conn_mtu(conn), len); - __ASSERT_NO_MSG(buf->ref == 1); + /* If ATT sent callback is delayed until data transmission is done by BLE controller, the + * transmitted buffer may have an additional reference. The reference is used to extend + * lifetime of the net buffer until the data transmission is confirmed by ACK of the remote. + * + * send_buf function can be called multiple times, if buffer has to be fragmented over HCI. + * In that case, the callback is provided as an argument only for the last transmitted + * fragment. The `buf->ref == 1` check is skipped because it's impossible to properly + * validate number of references for the sent fragments if buffers may have the additional + * reference. + */ + __ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1)); if (buf->len > frag_len) { LOG_DBG("keep %p around", buf); diff --git a/subsys/bluetooth/host/cs.c b/subsys/bluetooth/host/cs.c index ec274f7ab9f9..6332c9282747 100644 --- a/subsys/bluetooth/host/cs.c +++ b/subsys/bluetooth/host/cs.c @@ -617,7 +617,7 @@ int bt_le_cs_start_test(const struct bt_le_cs_test_param *params) cp->override_parameters_length = override_parameters_length; - struct bt_hci_cmd_hdr *hdr = (struct bt_hci_cmd_hdr *)buf->data; + struct bt_hci_cmd_hdr *hdr = (struct bt_hci_cmd_hdr *)&buf->data[1]; hdr->param_len += override_parameters_length; diff --git a/subsys/bluetooth/host/hci_core.h b/subsys/bluetooth/host/hci_core.h index b6ebdba31a7e..74c2711b3e4c 100644 --- a/subsys/bluetooth/host/hci_core.h +++ b/subsys/bluetooth/host/hci_core.h @@ -500,7 +500,28 @@ struct bt_keys; void bt_id_add(struct bt_keys *keys); void bt_id_del(struct bt_keys *keys); -struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate); +/** @brief Find a conflict in the resolving list for a candidate IRK. + * + * @param candidate The candidate keys to check for conflicts. + * @param all If true, check all IRKs, otherwise check only added keys. + * + * @return The conflicting key if there is one, or NULL if no conflict was found. + */ +struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate, bool all); + +/** * @brief Find multiple conflicts in the resolving list for a candidate IRK. + * + * This function iterates over all keys (added and not added to the Resolving List). If there are + * multiple conflicts, this function will return true. Otherwise, it will return false. + * + * If @c firt_conflict is not NULL, it will be set to the first found conflict. + * + * @param candidate The candidate key to check for conflicts. + * @param first_conflict Pointer to store the first found conflict, if any. Can be NULL. + * + * @return True if there are multiple conflicts, otherwise it returns false. + */ +bool bt_id_find_conflict_multiple(struct bt_keys *candidate, struct bt_keys **first_conflict); int bt_setup_random_id_addr(void); int bt_setup_public_id_addr(void); diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c index 926175f8b33b..bba4aad19792 100644 --- a/subsys/bluetooth/host/id.c +++ b/subsys/bluetooth/host/id.c @@ -944,9 +944,33 @@ void bt_id_pending_keys_update(void) } } +static bool keys_conflict_check(const struct bt_keys *candidate, const struct bt_keys *resident) +{ + bool addr_conflict; + bool irk_conflict; + + addr_conflict = bt_addr_le_eq(&candidate->addr, &resident->addr); + + /* All-zero IRK is "no IRK", and does not conflict with other Zero-IRKs. */ + irk_conflict = (!bt_irk_eq(&candidate->irk, &(struct bt_irk){}) && + bt_irk_eq(&candidate->irk, &resident->irk)); + + if (addr_conflict || irk_conflict) { + LOG_DBG("Resident : addr %s and IRK %s", bt_addr_le_str(&resident->addr), + bt_hex(resident->irk.val, sizeof(resident->irk.val))); + LOG_DBG("Candidate: addr %s and IRK %s", bt_addr_le_str(&candidate->addr), + bt_hex(candidate->irk.val, sizeof(candidate->irk.val))); + + return true; + } + + return false; +} + struct bt_id_conflict { struct bt_keys *candidate; struct bt_keys *found; + bool check_all_irk; }; /* The Controller Resolve List is constrained by 7.8.38 "LE Add Device To @@ -958,8 +982,6 @@ struct bt_id_conflict { void find_rl_conflict(struct bt_keys *resident, void *user_data) { struct bt_id_conflict *conflict = user_data; - bool addr_conflict; - bool irk_conflict; __ASSERT_NO_MSG(conflict != NULL); __ASSERT_NO_MSG(conflict->candidate != NULL); @@ -972,30 +994,26 @@ void find_rl_conflict(struct bt_keys *resident, void *user_data) } /* Test against committed bonds only. */ - if ((resident->state & BT_KEYS_ID_ADDED) == 0) { + if (!conflict->check_all_irk && (resident->state & BT_KEYS_ID_ADDED) == 0) { + /* If the resident bond is not committed, we cannot have a conflict. */ return; } - addr_conflict = bt_addr_le_eq(&conflict->candidate->addr, &resident->addr); - - /* All-zero IRK is "no IRK", and does not conflict with other Zero-IRKs. */ - irk_conflict = (!bt_irk_eq(&conflict->candidate->irk, &(struct bt_irk){}) && - bt_irk_eq(&conflict->candidate->irk, &resident->irk)); - - if (addr_conflict || irk_conflict) { - LOG_DBG("Resident : addr %s and IRK %s", bt_addr_le_str(&resident->addr), - bt_hex(resident->irk.val, sizeof(resident->irk.val))); - LOG_DBG("Candidate: addr %s and IRK %s", bt_addr_le_str(&conflict->candidate->addr), - bt_hex(conflict->candidate->irk.val, sizeof(conflict->candidate->irk.val))); + if (resident->id == conflict->candidate->id) { + /* If the IDs are the same, we cannot have a conflict. */ + return; + } + if (keys_conflict_check(conflict->candidate, resident)) { conflict->found = resident; } } -struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate) +struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate, bool check_all_irk) { struct bt_id_conflict conflict = { .candidate = candidate, + .check_all_irk = check_all_irk, }; bt_keys_foreach_type(BT_KEYS_IRK, find_rl_conflict, &conflict); @@ -1003,6 +1021,59 @@ struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate) return conflict.found; } +struct bt_id_conflict_multiple { + struct bt_keys *candidate; + struct bt_keys *found; + bool found_multiple; +}; + +void find_rl_conflict_multiple(struct bt_keys *resident, void *user_data) +{ + struct bt_id_conflict_multiple *conflict = user_data; + + __ASSERT_NO_MSG(conflict != NULL); + __ASSERT_NO_MSG(conflict->candidate != NULL); + __ASSERT_NO_MSG(resident != NULL); + + if (conflict->found_multiple) { + /* If we already found enough conflicts, we can stop searching. */ + return; + } + + if (resident->id == conflict->candidate->id) { + /* If the IDs are the same, we cannot have a conflict. */ + return; + } + + if (keys_conflict_check(conflict->candidate, resident)) { + if (conflict->found) { + conflict->found_multiple = true; + + LOG_WRN("Found multiple conflicts for %s: addr %s and IRK %s", + bt_addr_le_str(&conflict->candidate->addr), + bt_addr_le_str(&resident->addr), + bt_hex(resident->irk.val, sizeof(resident->irk.val))); + } else { + conflict->found = resident; + } + } +} + +bool bt_id_find_conflict_multiple(struct bt_keys *candidate, struct bt_keys **first_conflict) +{ + struct bt_id_conflict_multiple conflict = { + .candidate = candidate, + }; + + bt_keys_foreach_type(BT_KEYS_IRK, find_rl_conflict_multiple, &conflict); + + if (first_conflict != NULL) { + *first_conflict = conflict.found; + } + + return conflict.found_multiple; +} + void bt_id_add(struct bt_keys *keys) { CHECKIF(keys == NULL) { @@ -1254,6 +1325,122 @@ void bt_id_del(struct bt_keys *keys) bt_le_ext_adv_foreach(adv_unpause_enabled, NULL); } } + +static int conflict_check_and_replace(uint8_t id, struct bt_keys *keys) +{ + /* For the given key check if it has conflicts with other keys in the Resolving List + * (such keys have BT_KEYS_ID_ADDED state and BT_KEYS_ID_CONFLICT flag set). If it does, we + * need to remove the conflicting key from the Resolving List and add the new key. + * + * If the key is not in the Resolving List, we can add the new key right away. + * + * If advertiser for the conflicting key is enabled, we cannot remove the key from the + * Resolving List, so we return an error. + */ + + struct bt_keys *conflict; + const struct bt_le_ext_adv *adv; + + if (!(keys->flags & BT_KEYS_ID_CONFLICT)) { + LOG_DBG("Key has no conflicts for id %u addr %s", id, bt_addr_le_str(&keys->addr)); + return 0; + } + + if (keys->state & BT_KEYS_ID_ADDED) { + LOG_DBG("Key is already added to resolving list for id %u addr %s", id, + bt_addr_le_str(&keys->addr)); + return 0; + } + + /* bt_id_find_conflict returns only keys added to the Resolving List (state is + * BT_KEYS_ID_ADDED). If the key has conflict, but no keys were added (for example, if the + * last added key was removed after bt_unpair()), then this function will return NULL. Then, + * we don't need to remove a conflicting key from the Resolving List. Otherwise, we need to + * remove the conflicting key from the Resolving List before adding the new key. + */ + conflict = bt_id_find_conflict(keys, false); + if (conflict != NULL) { + __ASSERT_NO_MSG((conflict->flags & BT_KEYS_ID_CONFLICT) != 0); + + LOG_DBG("Found conflicting key with id %u addr %s", conflict->id, + bt_addr_le_str(&conflict->addr)); + + adv = bt_adv_lookup_by_id(conflict->id); + if (adv && atomic_test_bit(adv->flags, BT_ADV_ENABLED)) { + LOG_WRN("Cannot remove the conflicting key from the Resolving List while" + " advertising"); + return -EPERM; + } + + /* Drop BT_KEYS_ID_PENDING_DEL flag if we were about to delete the keys since we + * delete it here. + */ + conflict->state &= ~BT_KEYS_ID_PENDING_DEL; + bt_id_del(conflict); + } + + bt_id_add(keys); + + return 0; +} + +struct bt_id_resolve { + uint8_t id; + int err; +}; + +static void check_and_add_keys_for_id(struct bt_keys *keys, void *data) +{ + struct bt_id_resolve *resolve = data; + + if (resolve->err) { + /* Skipping other keys because we got error. */ + return; + } + + if (resolve->id != keys->id) { + /* We are only interested in keys for the given id */ + return; + } + + resolve->err = conflict_check_and_replace(resolve->id, keys); +} + +int bt_id_resolving_list_check_and_update(uint8_t id, const bt_addr_le_t *peer) +{ + int err; + + if (peer == NULL) { + struct bt_id_resolve resolve = { + .id = id, + }; + + LOG_DBG("Updating resolving list for id %u without peer address", id); + + bt_keys_foreach_type(BT_KEYS_IRK, check_and_add_keys_for_id, &resolve); + err = resolve.err; + } else { + struct bt_keys *keys; + + LOG_DBG("Updating resolving list for id %u addr %s", id, bt_addr_le_str(peer)); + + keys = bt_keys_get_addr(id, peer); + if (!keys) { + LOG_DBG("No keys found for id %u addr %s", id, bt_addr_le_str(peer)); + return -ENOENT; + } + + err = conflict_check_and_replace(id, keys); + } + + if (err) { + LOG_ERR("Failed to update resolving list for id %u addr %s (err %d)", id, + peer ? bt_addr_le_str(peer) : "NULL", err); + return err; + } + + return err; +} #endif /* defined(CONFIG_BT_SMP) */ void bt_id_get(bt_addr_le_t *addrs, size_t *count) diff --git a/subsys/bluetooth/host/id.h b/subsys/bluetooth/host/id.h index 8824d3bb496b..cd66784a5037 100644 --- a/subsys/bluetooth/host/id.h +++ b/subsys/bluetooth/host/id.h @@ -60,3 +60,26 @@ void bt_id_pending_keys_update(void); void bt_id_pending_keys_update_set(struct bt_keys *keys, uint8_t flag); void bt_id_adv_limited_stopped(struct bt_le_ext_adv *adv); + +/** + * @brief Check and update the resolving list for a given identity. + * + * This function checks if the resolving list contains the keys for the given + * identity and peer address. If the keys are not present, it adds them to the + * resolving list. If the keys are present, it checks for conflicts with + * existing keys in the resolving list. If a conflict is found, it replaces + * the conflicting key with the new key. + * + * If the peer address is NULL, it updates the resolving list for all keys that belong to the given + * identity. + * + * If for any of the keys belonging to the given identity a conflict is found and the advertiser for + * that key is enabled, the function returns an error. + * + * @param id The identity ID to check and update. + * @param peer The peer address to check against the resolving list. + * + * @return 0 on success, or a negative error code on failure. + * @return -EPERM if a conflict is found and the advertiser for the conflicting key is enabled. + */ +int bt_id_resolving_list_check_and_update(uint8_t id, const bt_addr_le_t *peer); diff --git a/subsys/bluetooth/host/keys.c b/subsys/bluetooth/host/keys.c index 6341fc1e58e8..4ae1d5b7a96a 100644 --- a/subsys/bluetooth/host/keys.c +++ b/subsys/bluetooth/host/keys.c @@ -310,16 +310,57 @@ void bt_keys_add_type(struct bt_keys *keys, enum bt_keys_type type) keys->keys |= type; } +static void add_id_cb(struct k_work *work) +{ + bt_id_pending_keys_update(); +} + +static K_WORK_DEFINE(add_id_work, add_id_cb); + void bt_keys_clear(struct bt_keys *keys) { + struct bt_keys *conflict = NULL; + __ASSERT_NO_MSG(keys != NULL); LOG_DBG("%s (keys 0x%04x)", bt_addr_le_str(&keys->addr), keys->keys); + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS) && + (keys->flags & BT_KEYS_ID_CONFLICT) != 0) { + /* We need to check how many conflicting keys left. If there is only one conflicting + * key left, we can remove the BT_KEYS_ID_CONFLICT flag from it so that Host don't + * need to check and update the Resolving List whenever this is needed. The key + * should be re-added to the Resolving List. + */ + bool found_multiple; + + found_multiple = bt_id_find_conflict_multiple(keys, &conflict); + if (conflict) { + if (found_multiple || (conflict->state & BT_KEYS_ID_ADDED) != 0) { + /* If we found multiple conflicting keys or the conflicting key + * is already added to the ID list, we don't need to clear the + * conflict flag for it and re-add it to the Resolving List. + */ + conflict = NULL; + } else { + /* Clear the conflict flag for the conflicting key */ + conflict->flags &= ~BT_KEYS_ID_CONFLICT; + } + } + } + if (keys->state & BT_KEYS_ID_ADDED) { bt_id_del(keys); } + if (conflict) { + /* Re-add the conflicting key to the Resolving List if it was the last conflicting + * key. + */ + bt_id_pending_keys_update_set(conflict, BT_KEYS_ID_PENDING_ADD); + k_work_submit(&add_id_work); + } + if (IS_ENABLED(CONFIG_BT_SETTINGS)) { /* Delete stored keys from flash */ bt_settings_delete_keys(keys->id, &keys->addr); @@ -347,6 +388,28 @@ int bt_keys_store(struct bt_keys *keys) return 0; } +static void check_and_set_id_conflict_flag(struct bt_keys *keys) +{ + struct bt_keys *conflict; + + if (!IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + /* If auto-swap is not enabled, we don't need to check for conflicts */ + return; + } + + /* Use bt_id_find_conflict() to check if there are any conflicting keys for the given keys. + * If there is at least one, set the BT_KEYS_ID_CONFLICT flag for both the keys and the + * conflicting key. + */ + conflict = bt_id_find_conflict(keys, true); + if (conflict != NULL) { + LOG_DBG("Found conflicting key %p.", conflict); + + keys->flags |= BT_KEYS_ID_CONFLICT; + conflict->flags |= BT_KEYS_ID_CONFLICT; + } +} + static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, void *cb_arg) { @@ -427,6 +490,8 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, memcpy(keys->storage_start, val, len); } + check_and_set_id_conflict_flag(keys); + LOG_DBG("Successfully restored keys for %s", bt_addr_le_str(&addr)); #if defined(CONFIG_BT_KEYS_OVERWRITE_OLDEST) if (aging_counter_val < keys->aging_counter) { @@ -436,17 +501,17 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, return 0; } -static void add_id_cb(struct k_work *work) -{ - bt_id_pending_keys_update(); -} - -static K_WORK_DEFINE(add_id_work, add_id_cb); - static void id_add(struct bt_keys *keys, void *user_data) { __ASSERT_NO_MSG(keys != NULL); + if (keys->flags & BT_KEYS_ID_CONFLICT) { + /* If the keys have the conflict flag set, we don't want to add them to the ID list, + * as this will cause issues with resolving list. + */ + return; + } + bt_id_pending_keys_update_set(keys, BT_KEYS_ID_PENDING_ADD); k_work_submit(&add_id_work); } diff --git a/subsys/bluetooth/host/keys.h b/subsys/bluetooth/host/keys.h index b53635ce2c56..185fd610e779 100644 --- a/subsys/bluetooth/host/keys.h +++ b/subsys/bluetooth/host/keys.h @@ -45,6 +45,12 @@ enum { /* Bit 2 and 3 might accidentally exist in old stored keys */ BT_KEYS_SC = BIT(4), BT_KEYS_OOB = BIT(5), + /** Indicates that the keys are in conflict with existing keys. + * + * This is used to indicate that the keys being added conflict with + * existing keys from different identity. + */ + BT_KEYS_ID_CONFLICT = BIT(6), }; struct bt_ltk { diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 433eb8faef09..683aafdf5616 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -735,13 +735,17 @@ int bt_l2cap_send_pdu(struct bt_l2cap_le_chan *le_chan, struct net_buf *pdu, return -ENOTCONN; } - if (pdu->ref != 1) { + /* Allow for an additional buffer reference if callback is provided. This can be used to + * extend lifetime of the net buffer until the data transmission is confirmed by ACK of the + * remote. + */ + if (pdu->ref > 1 + (cb ? 1 : 0)) { /* The host may alter the buf contents when fragmenting. Higher * layers cannot expect the buf contents to stay intact. Extra * refs suggests a silent data corruption would occur if not for * this error. */ - LOG_ERR("Expecting 1 ref, got %d", pdu->ref); + LOG_ERR("Expecting up to %d refs, got %d", cb ? 2 : 1, pdu->ref); return -EINVAL; } diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index 3c4fc29fe243..916bb661bb98 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -909,7 +909,7 @@ static void smp_br_id_add_replace(struct bt_keys *keys) bt_id_del(keys); } - conflict = bt_id_find_conflict(keys); + conflict = bt_id_find_conflict(keys, false); if (conflict != NULL) { int err; @@ -919,7 +919,7 @@ static void smp_br_id_add_replace(struct bt_keys *keys) __ASSERT_NO_MSG(!err); } - __ASSERT_NO_MSG(!bt_id_find_conflict(keys)); + __ASSERT_NO_MSG(!bt_id_find_conflict(keys, false)); bt_id_add(keys); } @@ -4048,16 +4048,24 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) */ __ASSERT_NO_MSG(!(smp->remote_dist & BT_SMP_DIST_ID_KEY)); - conflict = bt_id_find_conflict(new_bond); + conflict = bt_id_find_conflict(new_bond, IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)); if (conflict) { LOG_DBG("New bond conflicts with a bond on id %d.", conflict->id); } - if (conflict && !IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { + if (conflict && !IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS) && + !IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { LOG_WRN("Refusing new pairing. The old bond must be unpaired first."); return BT_SMP_ERR_AUTH_REQUIREMENTS; } + if (conflict && IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + LOG_WRN("Conflict detected with %p. Don't add key to Resolve List.", conflict); + new_bond->flags |= BT_KEYS_ID_CONFLICT; + conflict->flags |= BT_KEYS_ID_CONFLICT; + return 0; + } + if (conflict && IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { bool trust_ok; int unpair_err; @@ -4074,7 +4082,7 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) __ASSERT_NO_MSG(!unpair_err); } - __ASSERT_NO_MSG(!bt_id_find_conflict(new_bond)); + __ASSERT_NO_MSG(!bt_id_find_conflict(new_bond, false)); bt_id_add(new_bond); return 0; } diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index b876e88dae69..7e4adf4c78ab 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -59,12 +59,16 @@ choice BT_MESH_ADV menuconfig BT_MESH_ADV_LEGACY bool "Legacy advertising" + depends on BT_LL_SW_SPLIT help Use legacy advertising commands for mesh sending. Legacy - advertising is significantly slower than the extended advertising, but - is supported by all controllers. + advertising is significantly slower than the extended advertising. - WARNING: The legacy advertiser can occasionally do more message + WARNING: This feature is not supported in NCS. The legacy advertiser will not work + with SDC, as attempting to start an advertisement during the scanner duty cycle + will result in an error. The Zephyr Link Layer can be used experimentally as an + alternative. + The legacy advertiser can occasionally do more message retransmissions than requested because of limitations of HCI interface API. @@ -210,6 +214,17 @@ config BT_MESH_ADV_EXT_FRIEND_SEPARATE messages as close to the start of the ReceiveWindow as possible, thus reducing the scanning time on the Low Power node. +config BT_MESH_ADV_EXT_ACCEPT_EXT_ADV_PACKETS + bool "Reject or accept extended advertising packets" + depends on BT_LL_SOFTDEVICE + help + Configure the scanner and initiator to either reject or accept extended + advertising packets by the SoftDevice Controller. This is set to false + by default, to prevent loss of scan time when receiving a pointer packet + while scanning for Bluetooth Mesh packets. Set to true if extended + advertising packets are to be received by the SoftDevice Controller for + purposes other than Bluetooth Mesh. + endif # BT_MESH_ADV_EXT endchoice @@ -1085,10 +1100,15 @@ menu "Firmware Update model configuration" config BT_MESH_DFU_FWID_MAXLEN int "DFU FWID max length" - default 16 + default 106 range 0 106 help - This value defines the maximum length of an image's firmware ID. + This value defines the maximum length of the vendor-specific version information + that the mesh stack can manage, describing the image. Please note that + only 106 octets size allows the device to be compliant with + the Bluetooth Mesh DFU specification. If smaller than 106 octets are set, + then the device will fail with managing firmware images that have + a longer vendor-specific version information. config BT_MESH_DFU_METADATA_MAXLEN int "DFU metadata max length" @@ -1700,7 +1720,7 @@ config BT_MESH_LPN_INIT_POLL_TIMEOUT config BT_MESH_LPN_SCAN_LATENCY int "Latency for enabling scanning" range 0 50 - default 15 + default 2 help Latency in milliseconds that it takes to enable scanning. This is in practice how much time in advance before the Receive Window diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index b056f74a5876..537cdacf924d 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -13,6 +13,9 @@ #include #include #include +#if defined(CONFIG_BT_LL_SOFTDEVICE) +#include +#endif #include "common/bt_str.h" @@ -149,6 +152,28 @@ static inline struct bt_mesh_ext_adv *gatt_adv_get(void) } } +static int set_adv_randomness(uint8_t handle, int rand_us) +{ +#if defined(CONFIG_BT_LL_SOFTDEVICE) + struct net_buf *buf; + sdc_hci_cmd_vs_set_adv_randomness_t *cmd_params; + + buf = bt_hci_cmd_create(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, sizeof(*cmd_params)); + if (!buf) { + LOG_ERR("Could not allocate command buffer"); + return -ENOMEM; + } + + cmd_params = net_buf_add(buf, sizeof(*cmd_params)); + cmd_params->adv_handle = handle; + cmd_params->rand_us = rand_us; + + return bt_hci_cmd_send_sync(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, buf, NULL); +#else + return 0; +#endif /* defined(CONFIG_BT_LL_SOFTDEVICE) */ +} + static int adv_start(struct bt_mesh_ext_adv *ext_adv, const struct bt_le_adv_param *param, struct bt_le_ext_adv_start_param *start, @@ -494,6 +519,18 @@ void bt_mesh_adv_init(void) K_PRIO_COOP(MESH_WORKQ_PRIORITY), NULL); k_thread_name_set(&bt_mesh_workq.thread, "BT MESH WQ"); } + +#if defined(CONFIG_BT_LL_SOFTDEVICE) + const sdc_hci_cmd_vs_scan_accept_ext_adv_packets_set_t cmd_params = { + .accept_ext_adv_packets = IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_ACCEPT_EXT_ADV_PACKETS), + }; + + int err = sdc_hci_cmd_vs_scan_accept_ext_adv_packets_set(&cmd_params); + + if (err) { + LOG_ERR("Failed to set accept_ext_adv_packets: %d", err); + } +#endif } static struct bt_mesh_ext_adv *adv_instance_find(struct bt_le_ext_adv *instance) @@ -542,6 +579,15 @@ int bt_mesh_adv_enable(void) if (err) { return err; } + + if (IS_ENABLED(CONFIG_BT_LL_SOFTDEVICE) && + IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) && + advs[i].tags == BT_MESH_ADV_TAG_BIT_FRIEND) { + err = set_adv_randomness(advs[i].instance->handle, 0); + if (err) { + LOG_ERR("Failed to set zero randomness: %d", err); + } + } } return 0; diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index 5683d23a87ad..2984efe0906c 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -49,6 +49,48 @@ enum IMAGE_INDEXES { IMAGE_INDEX_2 }; +#if USE_PARTITION_MANAGER +#include + +#if CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1 +/* Sysbuild */ +#ifdef CONFIG_MCUBOOT +/* lib is part of MCUboot -> operate on the primary application slot */ +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#else +/* TODO: Add firmware loader support */ +/* lib is part of the app -> operate on active slot */ +#if defined(CONFIG_NCS_IS_VARIANT_IMAGE) +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif /* CONFIG_MCUBOOT */ +#else +/* Legacy child/parent */ +#if CONFIG_BUILD_WITH_TFM + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) +#else + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) +#endif + +#ifdef CONFIG_MCUBOOT + /* lib is part of MCUboot -> operate on the primary application slot */ + #define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#else + /* lib is part of the App -> operate on active slot */ +#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS + #define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS + #define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID +#else + #error Missing partition definitions. +#endif +#endif /* CONFIG_MCUBOOT */ +#endif /* CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1 */ + +#else + #if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) /* For RAM LOAD mode, the active image must be fetched from the bootloader */ #define ACTIVE_SLOT_FLASH_AREA_ID boot_fetch_active_slot() @@ -58,6 +100,8 @@ enum IMAGE_INDEXES { #define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) #endif +#endif /* USE_PARTITION_MANAGER */ + /* * Raw (on-flash) representation of the v1 image header. */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index be4e558713f1..e167bc1e39b8 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,6 +20,16 @@ #endif #endif +#if USE_PARTITION_MANAGER +#include + +#ifdef CONFIG_NCS_IS_VARIANT_IMAGE +#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif + struct area_desc { const char *name; unsigned int id; @@ -93,6 +103,35 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ +#if USE_PARTITION_MANAGER +#ifdef PM_MCUBOOT_ID + if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { + shell_error(sh, "Cannot erase boot partition"); + return -EACCES; + } +#endif + +#ifdef PM_APP_ID + if (id == PM_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef PM_MCUBOOT_PRIMARY_APP_ID + if (id == PM_MCUBOOT_PRIMARY_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef ACTIVE_IMAGE_ID + if (id == ACTIVE_IMAGE_ID) { + shell_error(sh, "Cannot erase active partitions"); + return -EACCES; + } +#endif +#else #if FIXED_PARTITION_EXISTS(boot_partition) if (id == FIXED_PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -105,6 +144,7 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } +#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index 7cf8aaa44c7b..5abbf95f949e 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1103,7 +1103,12 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = DT_INST_PROP(inst, mount_point), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_FIXED_PARTITION_ID(FS_PARTITION(inst)), \ + .storage_dev = (void *) \ + COND_CODE_1(USE_PARTITION_MANAGER, \ + (COND_CODE_1(FIXED_PARTITION_EXISTS(littlefs_storage), \ + (FIXED_PARTITION_ID(littlefs_storage)), \ + (FIXED_PARTITION_ID(storage)))), \ + (DT_FIXED_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/fs/nvs/Kconfig b/subsys/fs/nvs/Kconfig index 48915c2f048e..21798932f521 100644 --- a/subsys/fs/nvs/Kconfig +++ b/subsys/fs/nvs/Kconfig @@ -29,6 +29,15 @@ config NVS_LOOKUP_CACHE_SIZE Number of entries in Non-volatile Storage lookup cache. It is recommended that it be a power of 2. +config NVS_LOOKUP_CACHE_FOR_SETTINGS + bool "Non-volatile Storage lookup cache optimized for settings" + depends on NVS_LOOKUP_CACHE + help + Use the lookup cache hash function that results in the least number of + collissions and, in turn, the best NVS performance provided that the NVS + is used as the settings backend only. This option should NOT be enabled + if the NVS is also written to directly, outside the settings layer. + config NVS_DATA_CRC bool "Non-volatile Storage CRC protection on the data" help diff --git a/subsys/fs/nvs/nvs.c b/subsys/fs/nvs/nvs.c index 2e553fdbf554..103b605d5fcc 100644 --- a/subsys/fs/nvs/nvs.c +++ b/subsys/fs/nvs/nvs.c @@ -13,6 +13,11 @@ #include #include "nvs_priv.h" +#ifdef CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS +#include +#include +#endif + #include LOG_MODULE_REGISTER(fs_nvs, CONFIG_NVS_LOG_LEVEL); @@ -21,6 +26,45 @@ static int nvs_ate_valid(struct nvs_fs *fs, const struct nvs_ate *entry); #ifdef CONFIG_NVS_LOOKUP_CACHE +#ifdef CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS + +static inline size_t nvs_lookup_cache_pos(uint16_t id) +{ + /* + * 1. The NVS settings backend uses up to (NVS_NAME_ID_OFFSET - 1) NVS IDs to + store keys and equal number of NVS IDs to store values. + * 2. For each key-value pair, the value is stored at NVS ID greater by exactly + * NVS_NAME_ID_OFFSET than NVS ID that holds the key. + * 3. The backend tries to minimize the range of NVS IDs used to store keys. + * That is, NVS IDs are allocated sequentially, and freed NVS IDs are reused + * before allocating new ones. + * + * Therefore, to assure the least number of collisions in the lookup cache, + * the least significant bit of the hash indicates whether the given NVS ID + * represents a key or a value, and remaining bits of the hash are set to + * the ordinal number of the key-value pair. Consequently, the hash function + * provides the following mapping: + * + * 1st settings key => hash 0 + * 1st settings value => hash 1 + * 2nd settings key => hash 2 + * 2nd settings value => hash 3 + * ... + */ + BUILD_ASSERT(IS_POWER_OF_TWO(NVS_NAMECNT_ID), "NVS_NAMECNT_ID is not power of 2"); + BUILD_ASSERT(IS_POWER_OF_TWO(NVS_NAME_ID_OFFSET), "NVS_NAME_ID_OFFSET is not power of 2"); + + uint16_t key_value_bit; + uint16_t key_value_ord; + + key_value_bit = (id >> LOG2(NVS_NAME_ID_OFFSET)) & 1; + key_value_ord = id & (NVS_NAME_ID_OFFSET - 1); + + return ((key_value_ord << 1) | key_value_bit) % CONFIG_NVS_LOOKUP_CACHE_SIZE; +} + +#else /* CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS */ + static inline size_t nvs_lookup_cache_pos(uint16_t id) { uint16_t hash; @@ -36,6 +80,8 @@ static inline size_t nvs_lookup_cache_pos(uint16_t id) return hash % CONFIG_NVS_LOOKUP_CACHE_SIZE; } +#endif /* CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS */ + static int nvs_lookup_cache_rebuild(struct nvs_fs *fs) { int rc; diff --git a/subsys/fs/zms/zms.c b/subsys/fs/zms/zms.c index 80b86a41cdcb..95c2ef82c3b4 100644 --- a/subsys/fs/zms/zms.c +++ b/subsys/fs/zms/zms.c @@ -13,8 +13,12 @@ #include #include "zms_priv.h" #ifdef CONFIG_ZMS_LOOKUP_CACHE_FOR_SETTINGS +#ifdef CONFIG_SETTINGS_ZMS_LEGACY +#include +#else #include #endif +#endif #include LOG_MODULE_REGISTER(fs_zms, CONFIG_ZMS_LOG_LEVEL); @@ -34,6 +38,39 @@ static inline size_t zms_lookup_cache_pos(uint32_t id) uint32_t hash = id; #ifdef CONFIG_ZMS_LOOKUP_CACHE_FOR_SETTINGS +#ifdef CONFIG_SETTINGS_ZMS_LEGACY + /* + * 1. The ZMS settings backend uses up to (ZMS_NAME_ID_OFFSET - 1) ZMS IDs to + store keys and equal number of ZMS IDs to store values. + * 2. For each key-value pair, the value is stored at ZMS ID greater by exactly + * ZMS_NAME_ID_OFFSET than ZMS ID that holds the key. + * 3. The backend tries to minimize the range of ZMS IDs used to store keys. + * That is, ZMS IDs are allocated sequentially, and freed ZMS IDs are reused + * before allocating new ones. + * + * Therefore, to assure the least number of collisions in the lookup cache, + * the least significant bit of the hash indicates whether the given ZMS ID + * represents a key or a value, and remaining bits of the hash are set to + * the ordinal number of the key-value pair. Consequently, the hash function + * provides the following mapping: + * + * 1st settings key => hash 0 + * 1st settings value => hash 1 + * 2nd settings key => hash 2 + * 2nd settings value => hash 3 + * ... + */ + BUILD_ASSERT(IS_POWER_OF_TWO(ZMS_NAMECNT_ID), "ZMS_NAMECNT_ID is not power of 2"); + BUILD_ASSERT(IS_POWER_OF_TWO(ZMS_NAME_ID_OFFSET), "ZMS_NAME_ID_OFFSET is not power of 2"); + + uint32_t key_value_bit; + uint32_t key_value_ord; + + key_value_bit = (id >> LOG2(ZMS_NAME_ID_OFFSET)) & 1; + key_value_ord = id & (ZMS_NAME_ID_OFFSET - 1); + + hash = ((key_value_ord << 1) | key_value_bit); +#else /* * 1. Settings subsystem is storing the name ID and the linked list node ID * with only one bit difference at BIT(0). @@ -58,6 +95,7 @@ static inline size_t zms_lookup_cache_pos(uint32_t id) key_value_ll = id & BIT(0); hash = (key_value_hash << 2) | (key_value_bit << 1) | key_value_ll; +#endif /* CONFIG_SETTINGS_ZMS_LEGACY */ #else /* 32-bit integer hash function found by https://github.com/skeeto/hash-prospector. */ hash ^= hash >> 16; diff --git a/subsys/ipc/ipc_service/backends/Kconfig.icbmsg b/subsys/ipc/ipc_service/backends/Kconfig.icbmsg index e31b5cadd77a..3a34c63c06c7 100644 --- a/subsys/ipc/ipc_service/backends/Kconfig.icbmsg +++ b/subsys/ipc/ipc_service/backends/Kconfig.icbmsg @@ -23,6 +23,14 @@ config IPC_SERVICE_BACKEND_ICBMSG_NUM_EP backend. The number of endpoints are applied to all the instances, so this value should be maximum number among all the instances. +config IPC_SERVICE_BACKEND_ICBMSG_EP_BOUND_WORK_Q_STACK_SIZE + int "Workqueue stack size" + default 1024 if NO_OPTIMIZATIONS + default 512 + help + Workqueue stack size for bounding processing + (this configuration is not optimized). + module = IPC_SERVICE_BACKEND_ICBMSG module-str = ICMSG backend with separate buffers module-help = Sets log level for ICMsg backend with buffers diff --git a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c index 46ecfe1233ff..312642aafeb9 100644 --- a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c +++ b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c @@ -118,7 +118,8 @@ LOG_MODULE_REGISTER(ipc_icbmsg, #define FLAG_EPT_COUNT_MASK 0xFFFF /** Workqueue stack size for bounding processing (this configuration is not optimized). */ -#define EP_BOUND_WORK_Q_STACK_SIZE (512U) +#define EP_BOUND_WORK_Q_STACK_SIZE \ + (CONFIG_IPC_SERVICE_BACKEND_ICBMSG_EP_BOUND_WORK_Q_STACK_SIZE) /** Workqueue priority for bounding processing. */ #define EP_BOUND_WORK_Q_PRIORITY (CONFIG_SYSTEM_WORKQUEUE_PRIORITY) diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index a74e46b85207..9996e1d74d9b 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,8 +13,35 @@ extern "C" { #endif +#if CONFIG_PARTITION_MANAGER_ENABLED + +#include "pm_config.h" + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) +#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE +#else +/* The current image is a child image in a different domain than the image + * which defined the required values. To reach the values of the parent domain + * we use the 'PM__' variant of the define. + */ +#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ + +#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ + +#else + +#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #define VDEV_STATUS_ADDR VDEV_START_ADDR #define VDEV_STATUS_SIZE 0x400 diff --git a/subsys/mgmt/mcumgr/CMakeLists.txt b/subsys/mgmt/mcumgr/CMakeLists.txt index 39d4a4ca8ce0..3bb21e16f798 100644 --- a/subsys/mgmt/mcumgr/CMakeLists.txt +++ b/subsys/mgmt/mcumgr/CMakeLists.txt @@ -16,3 +16,12 @@ add_subdirectory(transport) add_subdirectory_ifdef(CONFIG_SMP_CLIENT smp_client) zephyr_library_link_libraries(mgmt_mcumgr) + +if(CONFIG_MCUMGR_GRP_IMG_NRF5340_BOOTUTIL_HOOK) + zephyr_include_directories( + ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/bootutil/include + ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/zephyr/include + ) + + zephyr_library_sources(bootutil_hooks/nrf53_hooks.c) +endif() diff --git a/subsys/mgmt/mcumgr/Kconfig b/subsys/mgmt/mcumgr/Kconfig index 49bd17f46691..c45cb7f81d6b 100644 --- a/subsys/mgmt/mcumgr/Kconfig +++ b/subsys/mgmt/mcumgr/Kconfig @@ -6,6 +6,7 @@ menuconfig MCUMGR bool "mcumgr Support" depends on NET_BUF depends on ZCBOR + imply BOOT_IMAGE_ACCESS_HOOKS if SOC_NRF5340_CPUAPP && MCUMGR_GRP_IMG && MCUBOOT_NETWORK_CORE_IMAGE_NUMBER > -1 help This option enables the mcumgr management library. diff --git a/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c b/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c new file mode 100644 index 000000000000..b372ce4e4945 --- /dev/null +++ b/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include "bootutil/bootutil_public.h" + +int boot_read_swap_state_primary_slot_hook(int image_index, struct boot_swap_state *state) +{ + if (image_index == CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER) { + /* Pretend that primary slot of the network core update image is unpopulated */ + state->magic = BOOT_MAGIC_UNSET; + state->swap_type = BOOT_SWAP_TYPE_NONE; + state->image_num = image_index; + state->copy_done = BOOT_FLAG_UNSET; + state->image_ok = BOOT_FLAG_UNSET; + + /* Prevent bootutil from trying to obtain true info */ + return 0; + } + + return BOOT_HOOK_REGULAR; +} diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig b/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig index 0915d70e8706..d95f9b5849a5 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig @@ -219,6 +219,22 @@ config MCUMGR_GRP_IMG_SLOT_INFO_HOOKS This will enable the slot info function hooks which can be used to add additional information to responses. +config MCUMGR_GRP_IMG_QSPI_XIP_SPLIT_IMAGE + bool "QSPI XIP Split image mode" + depends on MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP + help + This option should not be selected by users and should automatically be selected by + sysbuild if needed. This enables selecting the correct slot when running a QSPI XIP + split image application in DirectXIP mode. + +config MCUMGR_GRP_IMG_NRF5340_BOOTUTIL_HOOK + bool "nRF5340 network core bootutil hook" + depends on SOC_NRF5340_CPUAPP && BOOT_IMAGE_ACCESS_HOOKS && MCUBOOT_NETWORK_CORE_IMAGE_NUMBER > -1 + default y + help + This option will enable a bootutil hook that populates the network core update image + slot with dummy data to allow for uploading a firmware update to the network core. + module = MCUMGR_GRP_IMG module-str = mcumgr_grp_img source "subsys/logging/Kconfig.template.log_config" diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/include/mgmt/mcumgr/grp/img_mgmt/img_mgmt_priv.h b/subsys/mgmt/mcumgr/grp/img_mgmt/include/mgmt/mcumgr/grp/img_mgmt/img_mgmt_priv.h index 133a1abf054f..d584467ee2bf 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/include/mgmt/mcumgr/grp/img_mgmt/img_mgmt_priv.h +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/include/mgmt/mcumgr/grp/img_mgmt/img_mgmt_priv.h @@ -18,6 +18,14 @@ extern "C" { #endif +#ifdef CONFIG_MCUBOOT_BOOTLOADER_USES_SHA512 +#define IMAGE_TLV_SHA IMAGE_TLV_SHA512 +#define IMAGE_SHA_LEN 64 +#else +#define IMAGE_TLV_SHA IMAGE_TLV_SHA256 +#define IMAGE_SHA_LEN 32 +#endif + /** * @brief Ensures the spare slot (slot 1) is fully erased. * diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index 035a765798ee..05e3a9c64889 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -43,6 +43,23 @@ #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) +#if USE_PARTITION_MANAGER +#include + +#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE +BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE); +#endif + +#if CONFIG_BUILD_WITH_TFM + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) +#else + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) +#endif + +#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ + (FIXED_PARTITION_OFFSET(label) == (PM_ADDRESS - PM_ADDRESS_OFFSET)) + +#else /* ! USE_PARTITION_MANAGER */ #ifndef CONFIG_FLASH_LOAD_OFFSET #error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \ to be able to figure out application running slot. @@ -50,6 +67,7 @@ #define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ (FIXED_PARTITION_OFFSET(label) == CONFIG_FLASH_LOAD_OFFSET) +#endif /* USE_PARTITION_MANAGER */ BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE, "struct image_header not required size"); @@ -217,6 +235,14 @@ int img_mgmt_active_slot(int image) /* Multi image does not support DirectXIP or RAM load currently */ #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER > 1 slot = (image << 1); + +#if defined(CONFIG_MCUMGR_GRP_IMG_QSPI_XIP_SPLIT_IMAGE) || \ + defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) || \ + defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT) + if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { + slot += 1; + } +#endif #elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) /* RAM load requires querying bootloader */ int rc; @@ -322,7 +348,7 @@ int img_mgmt_read_info(int image_slot, struct image_version *ver, uint8_t *hash, if (tlv.it_type == 0xff && tlv.it_len == 0xffff) { return IMG_MGMT_ERR_INVALID_TLV; } - if (tlv.it_type != IMAGE_TLV_SHA256 || tlv.it_len != IMAGE_HASH_LEN) { + if (tlv.it_type != IMAGE_TLV_SHA || tlv.it_len != IMAGE_SHA_LEN) { /* Non-hash TLV. Skip it. */ data_off += sizeof(tlv) + tlv.it_len; continue; @@ -336,10 +362,10 @@ int img_mgmt_read_info(int image_slot, struct image_version *ver, uint8_t *hash, data_off += sizeof(tlv); if (hash != NULL) { - if (data_off + IMAGE_HASH_LEN > data_end) { + if (data_off + IMAGE_SHA_LEN > data_end) { return IMG_MGMT_ERR_TLV_INVALID_SIZE; } - rc = img_mgmt_read(image_slot, data_off, hash, IMAGE_HASH_LEN); + rc = img_mgmt_read(image_slot, data_off, hash, IMAGE_SHA_LEN); if (rc != 0) { return rc; } @@ -382,13 +408,13 @@ int img_mgmt_find_by_hash(uint8_t *find, struct image_version *ver) { int i; - uint8_t hash[IMAGE_HASH_LEN]; + uint8_t hash[IMAGE_SHA_LEN]; for (i = 0; i < SLOTS_PER_IMAGE * CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER; i++) { if (img_mgmt_read_info(i, ver, hash, NULL) != 0) { continue; } - if (!memcmp(hash, find, IMAGE_HASH_LEN)) { + if (!memcmp(hash, find, IMAGE_SHA_LEN)) { return i; } } @@ -698,7 +724,7 @@ img_mgmt_upload_good_rsp(struct smp_streamer *ctxt) static int img_mgmt_upload_log(bool is_first, bool is_last, int status) { - uint8_t hash[IMAGE_HASH_LEN]; + uint8_t hash[IMAGE_SHA_LEN]; const uint8_t *hashp; int rc; diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c index 5333d651c9f9..5ab53dea2df9 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c @@ -426,8 +426,8 @@ static bool img_mgmt_state_encode_slot(struct smp_streamer *ctxt, uint32_t slot, zcbor_state_t *zse = ctxt->writer->zs; uint32_t flags; char vers_str[IMG_MGMT_VER_MAX_STR_LEN]; - uint8_t hash[IMAGE_HASH_LEN]; /* SHA256 hash */ - struct zcbor_string zhash = { .value = hash, .len = IMAGE_HASH_LEN }; + uint8_t hash[IMAGE_SHA_LEN]; + struct zcbor_string zhash = { .value = hash, .len = IMAGE_SHA_LEN}; struct image_version ver; bool ok; int rc = img_mgmt_read_info(slot, &ver, hash, &flags); @@ -733,14 +733,14 @@ img_mgmt_state_write(struct smp_streamer *ctxt) IMG_MGMT_ERR_INVALID_HASH); goto end; } - } else if (zhash.len != IMAGE_HASH_LEN) { + } else if (zhash.len != IMAGE_SHA_LEN) { /* The img_mgmt_find_by_hash does exact length compare * so just fail here. */ ok = smp_add_cmd_err(zse, MGMT_GROUP_ID_IMAGE, IMG_MGMT_ERR_INVALID_HASH); goto end; } else { - uint8_t hash[IMAGE_HASH_LEN]; + uint8_t hash[IMAGE_SHA_LEN]; memcpy(hash, zhash.value, zhash.len); diff --git a/subsys/net/ip/net_stats.c b/subsys/net/ip/net_stats.c index 3f9df8c8cf1c..5da625faeb6d 100644 --- a/subsys/net/ip/net_stats.c +++ b/subsys/net/ip/net_stats.c @@ -85,25 +85,25 @@ static inline void stats(struct net_if *iface) } #if defined(CONFIG_NET_STATISTICS_IPV6) - NET_INFO("IPv6 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d", + NET_INFO("IPv6 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u", GET_STAT(iface, ipv6.recv), GET_STAT(iface, ipv6.sent), GET_STAT(iface, ipv6.drop), GET_STAT(iface, ipv6.forwarded)); #if defined(CONFIG_NET_STATISTICS_IPV6_ND) - NET_INFO("IPv6 ND recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("IPv6 ND recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, ipv6_nd.recv), GET_STAT(iface, ipv6_nd.sent), GET_STAT(iface, ipv6_nd.drop)); #endif /* CONFIG_NET_STATISTICS_IPV6_ND */ #if defined(CONFIG_NET_STATISTICS_IPV6_PMTU) - NET_INFO("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("IPv6 PMTU recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, ipv6_pmtu.recv), GET_STAT(iface, ipv6_pmtu.sent), GET_STAT(iface, ipv6_pmtu.drop)); #endif /* CONFIG_NET_STATISTICS_IPV6_PMTU */ #if defined(CONFIG_NET_STATISTICS_MLD) - NET_INFO("IPv6 MLD recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("IPv6 MLD recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, ipv6_mld.recv), GET_STAT(iface, ipv6_mld.sent), GET_STAT(iface, ipv6_mld.drop)); @@ -111,70 +111,70 @@ static inline void stats(struct net_if *iface) #endif /* CONFIG_NET_STATISTICS_IPV6 */ #if defined(CONFIG_NET_STATISTICS_IPV4) - NET_INFO("IPv4 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d", + NET_INFO("IPv4 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u", GET_STAT(iface, ipv4.recv), GET_STAT(iface, ipv4.sent), GET_STAT(iface, ipv4.drop), GET_STAT(iface, ipv4.forwarded)); #endif /* CONFIG_NET_STATISTICS_IPV4 */ - NET_INFO("IP vhlerr %d\thblener\t%d\tlblener\t%d", + NET_INFO("IP vhlerr %u\thblener\t%u\tlblener\t%u", GET_STAT(iface, ip_errors.vhlerr), GET_STAT(iface, ip_errors.hblenerr), GET_STAT(iface, ip_errors.lblenerr)); - NET_INFO("IP fragerr %d\tchkerr\t%d\tprotoer\t%d", + NET_INFO("IP fragerr %u\tchkerr\t%u\tprotoer\t%u", GET_STAT(iface, ip_errors.fragerr), GET_STAT(iface, ip_errors.chkerr), GET_STAT(iface, ip_errors.protoerr)); #if defined(CONFIG_NET_STATISTICS_IPV4_PMTU) - NET_INFO("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("IPv4 PMTU recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, ipv4_pmtu.recv), GET_STAT(iface, ipv4_pmtu.sent), GET_STAT(iface, ipv4_pmtu.drop)); #endif /* CONFIG_NET_STATISTICS_IPV4_PMTU */ - NET_INFO("ICMP recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("ICMP recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, icmp.recv), GET_STAT(iface, icmp.sent), GET_STAT(iface, icmp.drop)); - NET_INFO("ICMP typeer %d\tchkerr\t%d", + NET_INFO("ICMP typeer %u\tchkerr\t%u", GET_STAT(iface, icmp.typeerr), GET_STAT(iface, icmp.chkerr)); #if defined(CONFIG_NET_STATISTICS_UDP) - NET_INFO("UDP recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("UDP recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, udp.recv), GET_STAT(iface, udp.sent), GET_STAT(iface, udp.drop)); - NET_INFO("UDP chkerr %d", + NET_INFO("UDP chkerr %u", GET_STAT(iface, udp.chkerr)); #endif #if defined(CONFIG_NET_STATISTICS_TCP) - NET_INFO("TCP bytes recv %u\tsent\t%d", + NET_INFO("TCP bytes recv %llu\tsent\t%llu", GET_STAT(iface, tcp.bytes.received), GET_STAT(iface, tcp.bytes.sent)); - NET_INFO("TCP seg recv %d\tsent\t%d\tdrop\t%d", + NET_INFO("TCP seg recv %u\tsent\t%u\tdrop\t%u", GET_STAT(iface, tcp.recv), GET_STAT(iface, tcp.sent), GET_STAT(iface, tcp.drop)); - NET_INFO("TCP seg resent %d\tchkerr\t%d\tackerr\t%d", + NET_INFO("TCP seg resent %u\tchkerr\t%u\tackerr\t%u", GET_STAT(iface, tcp.resent), GET_STAT(iface, tcp.chkerr), GET_STAT(iface, tcp.ackerr)); - NET_INFO("TCP seg rsterr %d\trst\t%d\tre-xmit\t%d", + NET_INFO("TCP seg rsterr %u\trst\t%u\tre-xmit\t%u", GET_STAT(iface, tcp.rsterr), GET_STAT(iface, tcp.rst), GET_STAT(iface, tcp.rexmit)); - NET_INFO("TCP conn drop %d\tconnrst\t%d", + NET_INFO("TCP conn drop %u\tconnrst\t%u", GET_STAT(iface, tcp.conndrop), GET_STAT(iface, tcp.connrst)); #endif - NET_INFO("Bytes received %u", GET_STAT(iface, bytes.received)); - NET_INFO("Bytes sent %u", GET_STAT(iface, bytes.sent)); - NET_INFO("Processing err %d", + NET_INFO("Bytes received %llu", GET_STAT(iface, bytes.received)); + NET_INFO("Bytes sent %llu", GET_STAT(iface, bytes.sent)); + NET_INFO("Processing err %u", GET_STAT(iface, processing_error)); #if NET_TC_COUNT > 1 @@ -183,7 +183,7 @@ static inline void stats(struct net_if *iface) NET_INFO("TC Priority\tSent pkts\tbytes"); for (i = 0; i < NET_TC_TX_COUNT; i++) { - NET_INFO("[%d] %s (%d)\t%d\t\t%d", i, + NET_INFO("[%d] %s (%u)\t%u\t\t%llu", i, priority2str(GET_STAT(iface, tc.sent[i].priority)), GET_STAT(iface, tc.sent[i].priority), @@ -197,7 +197,7 @@ static inline void stats(struct net_if *iface) NET_INFO("TC Priority\tRecv pkts\tbytes"); for (i = 0; i < NET_TC_RX_COUNT; i++) { - NET_INFO("[%d] %s (%d)\t%d\t\t%d", i, + NET_INFO("[%d] %s (%u)\t%u\t\t%llu", i, priority2str(GET_STAT(iface, tc.recv[i].priority)), GET_STAT(iface, tc.recv[i].priority), @@ -213,7 +213,7 @@ static inline void stats(struct net_if *iface) NET_INFO("Power management statistics:"); NET_INFO("Last suspend time: %u ms", GET_STAT(iface, pm.last_suspend_time)); - NET_INFO("Got suspended %d times", + NET_INFO("Got suspended %u times", GET_STAT(iface, pm.suspend_count)); NET_INFO("Average suspend time: %u ms", (uint32_t)(GET_STAT(iface, pm.overall_suspend_time) / diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 0b8257695dd9..af0db05855fa 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1562,8 +1562,8 @@ static void print_wifi_stats(struct net_if *iface, struct net_stats_wifi *data, PR("Statistics for Wi-Fi interface %p [%d]\n", iface, net_if_get_by_iface(iface)); - PR("Bytes received : %u\n", data->bytes.received); - PR("Bytes sent : %u\n", data->bytes.sent); + PR("Bytes received : %llu\n", data->bytes.received); + PR("Bytes sent : %llu\n", data->bytes.sent); PR("Packets received : %u\n", data->pkts.rx); PR("Packets sent : %u\n", data->pkts.tx); PR("Receive errors : %u\n", data->errors.rx); @@ -2865,11 +2865,11 @@ void parse_mode_args_to_params(const struct shell *sh, int argc, {"monitor", no_argument, 0, 'm'}, {"ap", no_argument, 0, 'a'}, {"softap", no_argument, 0, 'k'}, - {"get", no_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0}}; - while ((opt = getopt_long(argc, argv, "i:smtpakgh", + mode->oper = WIFI_MGMT_GET; + while ((opt = getopt_long(argc, argv, "i:smtpakh", long_options, &opt_index)) != -1) { state = getopt_state_get(); switch (opt) { @@ -2889,10 +2889,6 @@ void parse_mode_args_to_params(const struct shell *sh, int argc, mode->mode |= WIFI_SOFTAP_MODE; opt_num++; break; - case 'g': - mode->oper = WIFI_MGMT_GET; - opt_num++; - break; case 'i': mode->if_index = (uint8_t)atoi(state->optarg); /* Don't count iface as it's common for both get and set */ @@ -2908,7 +2904,7 @@ void parse_mode_args_to_params(const struct shell *sh, int argc, } } - if (opt_num == 0) { + if (opt_num != 0) { mode->oper = WIFI_MGMT_SET; } } @@ -4064,9 +4060,8 @@ SHELL_SUBCMD_ADD((wifi), mode, NULL, "[-a, --ap] : AP mode\n" "[-k, --softap] : Softap mode\n" "[-h, --help] : Help\n" - "[-g, --get] : Get current mode for a specific interface index\n" "Usage: Get operation example for interface index 1\n" - "wifi mode -g -i1\n" + "wifi mode -i1\n" "Set operation example for interface index 1 - set station+promiscuous\n" "wifi mode -i1 -sp.\n", cmd_wifi_mode, diff --git a/subsys/net/lib/http/http_client.c b/subsys/net/lib/http/http_client.c index fe00609322ed..01cf8fb134e4 100644 --- a/subsys/net/lib/http/http_client.c +++ b/subsys/net/lib/http/http_client.c @@ -517,9 +517,6 @@ static int http_wait_data(int sock, struct http_request *req, const k_timepoint_ } else if (fds[0].revents & ZSOCK_POLLNVAL) { ret = -EBADF; goto error; - } else if (fds[0].revents & ZSOCK_POLLHUP) { - /* Connection closed */ - goto closed; } else if (fds[0].revents & ZSOCK_POLLIN) { received = zsock_recv(sock, req->internal.response.recv_buf + offset, req->internal.response.recv_buf_len - offset, 0); @@ -593,6 +590,9 @@ static int http_wait_data(int sock, struct http_request *req, const k_timepoint_ req->internal.response.recv_buf + processed, offset); } + } else if (fds[0].revents & ZSOCK_POLLHUP) { + /* Connection closed */ + goto closed; } } while (!req->internal.response.message_complete); diff --git a/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c b/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c index ffb8bcdb6830..58f37857bb22 100644 --- a/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c +++ b/subsys/net/lib/mqtt/mqtt_transport_socket_tcp.c @@ -29,6 +29,26 @@ int mqtt_client_tcp_connect(struct mqtt_client *client) return -errno; } + NET_DBG("Created socket %d", client->transport.tcp.sock); + + if (client->transport.if_name != NULL) { + struct ifreq ifname = { 0 }; + + strncpy(ifname.ifr_name, client->transport.if_name, + sizeof(ifname.ifr_name) - 1); + + ret = zsock_setsockopt(client->transport.tcp.sock, SOL_SOCKET, + SO_BINDTODEVICE, &ifname, + sizeof(struct ifreq)); + if (ret < 0) { + NET_ERR("Failed to bind ot interface %s error (%d)", + ifname.ifr_name, -errno); + goto error; + } + + NET_DBG("Bound to interface %s", ifname.ifr_name); + } + #if defined(CONFIG_SOCKS) if (client->transport.proxy.addrlen != 0) { ret = setsockopt(client->transport.tcp.sock, @@ -41,8 +61,6 @@ int mqtt_client_tcp_connect(struct mqtt_client *client) } #endif - NET_DBG("Created socket %d", client->transport.tcp.sock); - size_t peer_addr_size = sizeof(struct sockaddr_in6); if (broker->sa_family == AF_INET) { diff --git a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c index a33cee5aecfd..617dec4b4d26 100644 --- a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c +++ b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c @@ -22,16 +22,39 @@ int mqtt_client_tls_connect(struct mqtt_client *client) { const struct sockaddr *broker = client->broker; struct mqtt_sec_config *tls_config = &client->transport.tls.config; + int type = SOCK_STREAM; int ret; + if (tls_config->set_native_tls) { + type |= SOCK_NATIVE_TLS; + } + client->transport.tls.sock = zsock_socket(broker->sa_family, - SOCK_STREAM, IPPROTO_TLS_1_2); + type, IPPROTO_TLS_1_2); if (client->transport.tls.sock < 0) { return -errno; } NET_DBG("Created socket %d", client->transport.tls.sock); + if (client->transport.if_name != NULL) { + struct ifreq ifname = { 0 }; + + strncpy(ifname.ifr_name, client->transport.if_name, + sizeof(ifname.ifr_name) - 1); + + ret = zsock_setsockopt(client->transport.tls.sock, SOL_SOCKET, + SO_BINDTODEVICE, &ifname, + sizeof(struct ifreq)); + if (ret < 0) { + NET_ERR("Failed to bind ot interface %s error (%d)", + ifname.ifr_name, -errno); + goto error; + } + + NET_DBG("Bound to interface %s", ifname.ifr_name); + } + #if defined(CONFIG_SOCKS) if (client->transport.proxy.addrlen != 0) { ret = setsockopt(client->transport.tls.sock, @@ -91,6 +114,16 @@ int mqtt_client_tls_connect(struct mqtt_client *client) } } + if (tls_config->session_cache == TLS_SESSION_CACHE_ENABLED) { + ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS, + TLS_SESSION_CACHE, + &tls_config->session_cache, + sizeof(tls_config->session_cache)); + if (ret < 0) { + goto error; + } + } + if (tls_config->cert_nocopy != TLS_CERT_NOCOPY_NONE) { ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS, TLS_CERT_NOCOPY, &tls_config->cert_nocopy, diff --git a/subsys/net/lib/shell/stats.c b/subsys/net/lib/shell/stats.c index 64256bc7473a..1c31f56ec8f1 100644 --- a/subsys/net/lib/shell/stats.c +++ b/subsys/net/lib/shell/stats.c @@ -50,8 +50,8 @@ static void print_eth_stats(struct net_if *iface, struct net_stats_eth *data, PR("Statistics for Ethernet interface %p [%d]\n", iface, net_if_get_by_iface(iface)); - PR("Bytes received : %u\n", data->bytes.received); - PR("Bytes sent : %u\n", data->bytes.sent); + PR("Bytes received : %llu\n", data->bytes.received); + PR("Bytes sent : %llu\n", data->bytes.sent); PR("Packets received : %u\n", data->pkts.rx); PR("Packets sent : %u\n", data->pkts.tx); PR("Bcast received : %u\n", data->broadcast.rx); @@ -315,13 +315,13 @@ static void print_tc_tx_stats(const struct shell *sh, struct net_if *iface) net_stats_t count = GET_STAT(iface, tc.sent[i].tx_time.count); if (count == 0) { - PR("[%d] %s (%d)\t%d\t\t%d\t-\n", i, + PR("[%d] %s (%u)\t%u\t\t%llu\t-\n", i, priority2str(GET_STAT(iface, tc.sent[i].priority)), GET_STAT(iface, tc.sent[i].priority), GET_STAT(iface, tc.sent[i].pkts), GET_STAT(iface, tc.sent[i].bytes)); } else { - PR("[%d] %s (%d)\t%d\t\t%d\t%u us%s\n", i, + PR("[%d] %s (%u)\t%u\t\t%llu\t%u us%s\n", i, priority2str(GET_STAT(iface, tc.sent[i].priority)), GET_STAT(iface, tc.sent[i].priority), GET_STAT(iface, tc.sent[i].pkts), @@ -336,7 +336,7 @@ static void print_tc_tx_stats(const struct shell *sh, struct net_if *iface) PR("TC Priority\tSent pkts\tbytes\n"); for (i = 0; i < NET_TC_TX_COUNT; i++) { - PR("[%d] %s (%d)\t%d\t\t%d\n", i, + PR("[%d] %s (%u)\t%u\t\t%llu\n", i, priority2str(GET_STAT(iface, tc.sent[i].priority)), GET_STAT(iface, tc.sent[i].priority), GET_STAT(iface, tc.sent[i].pkts), @@ -374,14 +374,14 @@ static void print_tc_rx_stats(const struct shell *sh, struct net_if *iface) net_stats_t count = GET_STAT(iface, tc.recv[i].rx_time.count); if (count == 0) { - PR("[%d] %s (%d)\t%d\t%d\t\t%d\t-\n", i, + PR("[%d] %s (%u)\t%u\t%u\t\t%llu\t-\n", i, priority2str(GET_STAT(iface, tc.recv[i].priority)), GET_STAT(iface, tc.recv[i].priority), GET_STAT(iface, tc.recv[i].pkts), GET_STAT(iface, tc.recv[i].dropped), GET_STAT(iface, tc.recv[i].bytes)); } else { - PR("[%d] %s (%d)\t%d\t%d\t\t%d\t%u us%s\n", i, + PR("[%d] %s (%u)\t%u\t%u\t\t%llu\t%u us%s\n", i, priority2str(GET_STAT(iface, tc.recv[i].priority)), GET_STAT(iface, tc.recv[i].priority), GET_STAT(iface, tc.recv[i].pkts), @@ -397,7 +397,7 @@ static void print_tc_rx_stats(const struct shell *sh, struct net_if *iface) PR("TC Priority\tRecv pkts\tDrop pkts\tbytes\n"); for (i = 0; i < NET_TC_RX_COUNT; i++) { - PR("[%d] %s (%d)\t%d\t%d\t\t%d\n", i, + PR("[%d] %s (%u)\t%u\t%u\t\t%llu\n", i, priority2str(GET_STAT(iface, tc.recv[i].priority)), GET_STAT(iface, tc.recv[i].priority), GET_STAT(iface, tc.recv[i].pkts), @@ -459,25 +459,25 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data) } #if defined(CONFIG_NET_STATISTICS_IPV6) && defined(CONFIG_NET_NATIVE_IPV6) - PR("IPv6 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n", + PR("IPv6 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u\n", GET_STAT(iface, ipv6.recv), GET_STAT(iface, ipv6.sent), GET_STAT(iface, ipv6.drop), GET_STAT(iface, ipv6.forwarded)); #if defined(CONFIG_NET_STATISTICS_IPV6_ND) - PR("IPv6 ND recv %d\tsent\t%d\tdrop\t%d\n", + PR("IPv6 ND recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_nd.recv), GET_STAT(iface, ipv6_nd.sent), GET_STAT(iface, ipv6_nd.drop)); #endif /* CONFIG_NET_STATISTICS_IPV6_ND */ #if defined(CONFIG_NET_STATISTICS_IPV6_PMTU) - PR("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d\n", + PR("IPv6 PMTU recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_pmtu.recv), GET_STAT(iface, ipv6_pmtu.sent), GET_STAT(iface, ipv6_pmtu.drop)); #endif /* CONFIG_NET_STATISTICS_IPV6_PMTU */ #if defined(CONFIG_NET_STATISTICS_MLD) - PR("IPv6 MLD recv %d\tsent\t%d\tdrop\t%d\n", + PR("IPv6 MLD recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv6_mld.recv), GET_STAT(iface, ipv6_mld.sent), GET_STAT(iface, ipv6_mld.drop)); @@ -485,86 +485,86 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data) #endif /* CONFIG_NET_STATISTICS_IPV6 */ #if defined(CONFIG_NET_STATISTICS_IPV4) && defined(CONFIG_NET_NATIVE_IPV4) - PR("IPv4 recv %d\tsent\t%d\tdrop\t%d\tforwarded\t%d\n", + PR("IPv4 recv %u\tsent\t%u\tdrop\t%u\tforwarded\t%u\n", GET_STAT(iface, ipv4.recv), GET_STAT(iface, ipv4.sent), GET_STAT(iface, ipv4.drop), GET_STAT(iface, ipv4.forwarded)); #endif /* CONFIG_NET_STATISTICS_IPV4 */ - PR("IP vhlerr %d\thblener\t%d\tlblener\t%d\n", + PR("IP vhlerr %u\thblener\t%u\tlblener\t%u\n", GET_STAT(iface, ip_errors.vhlerr), GET_STAT(iface, ip_errors.hblenerr), GET_STAT(iface, ip_errors.lblenerr)); - PR("IP fragerr %d\tchkerr\t%d\tprotoer\t%d\n", + PR("IP fragerr %u\tchkerr\t%u\tprotoer\t%u\n", GET_STAT(iface, ip_errors.fragerr), GET_STAT(iface, ip_errors.chkerr), GET_STAT(iface, ip_errors.protoerr)); #if defined(CONFIG_NET_STATISTICS_IPV4_PMTU) - PR("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d\n", + PR("IPv4 PMTU recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv4_pmtu.recv), GET_STAT(iface, ipv4_pmtu.sent), GET_STAT(iface, ipv4_pmtu.drop)); #endif /* CONFIG_NET_STATISTICS_IPV4_PMTU */ #if defined(CONFIG_NET_STATISTICS_ICMP) && defined(CONFIG_NET_NATIVE_IPV4) - PR("ICMP recv %d\tsent\t%d\tdrop\t%d\n", + PR("ICMP recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, icmp.recv), GET_STAT(iface, icmp.sent), GET_STAT(iface, icmp.drop)); - PR("ICMP typeer %d\tchkerr\t%d\n", + PR("ICMP typeer %u\tchkerr\t%u\n", GET_STAT(iface, icmp.typeerr), GET_STAT(iface, icmp.chkerr)); #endif #if defined(CONFIG_NET_STATISTICS_IGMP) - PR("IGMP recv %d\tsent\t%d\tdrop\t%d\n", + PR("IGMP recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, ipv4_igmp.recv), GET_STAT(iface, ipv4_igmp.sent), GET_STAT(iface, ipv4_igmp.drop)); #endif /* CONFIG_NET_STATISTICS_IGMP */ #if defined(CONFIG_NET_STATISTICS_UDP) && defined(CONFIG_NET_NATIVE_UDP) - PR("UDP recv %d\tsent\t%d\tdrop\t%d\n", + PR("UDP recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, udp.recv), GET_STAT(iface, udp.sent), GET_STAT(iface, udp.drop)); - PR("UDP chkerr %d\n", + PR("UDP chkerr %u\n", GET_STAT(iface, udp.chkerr)); #endif #if defined(CONFIG_NET_STATISTICS_TCP) && defined(CONFIG_NET_NATIVE_TCP) - PR("TCP bytes recv %u\tsent\t%d\tresent\t%d\n", + PR("TCP bytes recv %llu\tsent\t%llu\tresent\t%u\n", GET_STAT(iface, tcp.bytes.received), GET_STAT(iface, tcp.bytes.sent), GET_STAT(iface, tcp.resent)); - PR("TCP seg recv %d\tsent\t%d\tdrop\t%d\n", + PR("TCP seg recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, tcp.recv), GET_STAT(iface, tcp.sent), GET_STAT(iface, tcp.seg_drop)); - PR("TCP seg resent %d\tchkerr\t%d\tackerr\t%d\n", + PR("TCP seg resent %u\tchkerr\t%u\tackerr\t%u\n", GET_STAT(iface, tcp.rexmit), GET_STAT(iface, tcp.chkerr), GET_STAT(iface, tcp.ackerr)); - PR("TCP seg rsterr %d\trst\t%d\n", + PR("TCP seg rsterr %u\trst\t%u\n", GET_STAT(iface, tcp.rsterr), GET_STAT(iface, tcp.rst)); - PR("TCP conn drop %d\tconnrst\t%d\n", + PR("TCP conn drop %u\tconnrst\t%u\n", GET_STAT(iface, tcp.conndrop), GET_STAT(iface, tcp.connrst)); - PR("TCP pkt drop %d\n", GET_STAT(iface, tcp.drop)); + PR("TCP pkt drop %u\n", GET_STAT(iface, tcp.drop)); #endif #if defined(CONFIG_NET_STATISTICS_DNS) - PR("DNS recv %d\tsent\t%d\tdrop\t%d\n", + PR("DNS recv %u\tsent\t%u\tdrop\t%u\n", GET_STAT(iface, dns.recv), GET_STAT(iface, dns.sent), GET_STAT(iface, dns.drop)); #endif /* CONFIG_NET_STATISTICS_DNS */ #if defined(CONFIG_NET_STATISTICS_PKT_FILTER) - PR("Filter drop rx %d" - IF_ENABLED(CONFIG_NET_PKT_FILTER_IPV4_HOOK, ("\tIPv4\t%d")) - IF_ENABLED(CONFIG_NET_PKT_FILTER_IPV6_HOOK, ("\tIPv6\t%d")) - IF_ENABLED(CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK, ("\tlocal\t%d")) - "\ttx\t%d\n", + PR("Filter drop rx %u" + IF_ENABLED(CONFIG_NET_PKT_FILTER_IPV4_HOOK, ("\tIPv4\t%u")) + IF_ENABLED(CONFIG_NET_PKT_FILTER_IPV6_HOOK, ("\tIPv6\t%u")) + IF_ENABLED(CONFIG_NET_PKT_FILTER_LOCAL_IN_HOOK, ("\tlocal\t%u")) + "\ttx\t%u\n", GET_STAT(iface, pkt_filter.rx.drop), IF_ENABLED(CONFIG_NET_PKT_FILTER_IPV4_HOOK, (GET_STAT(iface, pkt_filter.rx.ipv4_drop),)) @@ -575,9 +575,9 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data) GET_STAT(iface, pkt_filter.tx.drop)); #endif /* CONFIG_NET_STATISTICS_DNS */ - PR("Bytes received %u\n", GET_STAT(iface, bytes.received)); - PR("Bytes sent %u\n", GET_STAT(iface, bytes.sent)); - PR("Processing err %d\n", GET_STAT(iface, processing_error)); + PR("Bytes received %llu\n", GET_STAT(iface, bytes.received)); + PR("Bytes sent %llu\n", GET_STAT(iface, bytes.sent)); + PR("Processing err %u\n", GET_STAT(iface, processing_error)); print_tc_tx_stats(sh, iface); print_tc_rx_stats(sh, iface); diff --git a/subsys/net/lib/sockets/getaddrinfo.c b/subsys/net/lib/sockets/getaddrinfo.c index 86ee417d929e..a53f3a005a47 100644 --- a/subsys/net/lib/sockets/getaddrinfo.c +++ b/subsys/net/lib/sockets/getaddrinfo.c @@ -433,7 +433,7 @@ int zsock_getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res) { - if (IS_ENABLED(CONFIG_NET_SOCKETS_OFFLOAD)) { + if (socket_offload_dns_is_enabled()) { return socket_offload_getaddrinfo(host, service, hints, res); } @@ -471,7 +471,7 @@ int zsock_getaddrinfo(const char *host, const char *service, void zsock_freeaddrinfo(struct zsock_addrinfo *ai) { - if (IS_ENABLED(CONFIG_NET_SOCKETS_OFFLOAD)) { + if (socket_offload_dns_is_enabled()) { socket_offload_freeaddrinfo(ai); return; } diff --git a/subsys/net/lib/sockets/socket_offload.c b/subsys/net/lib/sockets/socket_offload.c index b6c2ef4fd64a..3e4ea3b8bbec 100644 --- a/subsys/net/lib/sockets/socket_offload.c +++ b/subsys/net/lib/sockets/socket_offload.c @@ -12,7 +12,8 @@ LOG_MODULE_REGISTER(net_socket_offload, CONFIG_NET_SOCKETS_LOG_LEVEL); #include "sockets_internal.h" -const struct socket_dns_offload *dns_offload; +static const struct socket_dns_offload *dns_offload; +static bool dns_offload_enabled; void socket_offload_dns_register(const struct socket_dns_offload *ops) { @@ -20,6 +21,33 @@ void socket_offload_dns_register(const struct socket_dns_offload *ops) __ASSERT_NO_MSG(dns_offload == NULL); dns_offload = ops; + + socket_offload_dns_enable(true); +} + +int socket_offload_dns_deregister(const struct socket_dns_offload *ops) +{ + __ASSERT_NO_MSG(ops != NULL); + + if (dns_offload != ops) { + return -EINVAL; + } + + dns_offload = NULL; + + socket_offload_dns_enable(false); + + return 0; +} + +void socket_offload_dns_enable(bool enable) +{ + dns_offload_enabled = enable; +} + +bool socket_offload_dns_is_enabled(void) +{ + return (dns_offload != NULL) && dns_offload_enabled; } int socket_offload_getaddrinfo(const char *node, const char *service, diff --git a/subsys/net/lib/wifi_credentials/Kconfig b/subsys/net/lib/wifi_credentials/Kconfig index f50e210b080a..d0843d689a28 100644 --- a/subsys/net/lib/wifi_credentials/Kconfig +++ b/subsys/net/lib/wifi_credentials/Kconfig @@ -73,6 +73,32 @@ config WIFI_CREDENTIALS_CONNECT_STORED_CONNECTION_TIMEOUT help Wait period before falling back to the next entry in the list of stored SSIDs. + +if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + +config WIFI_CREDENTIALS_RUNTIME_CERTIFICATES + bool "Provide Wi-Fi enterprise security certificates at run-time" + select TLS_CREDENTIALS + select TLS_CREDENTIALS_SHELL + select BASE64 + default y if WIFI_SHELL_RUNTIME_CERTIFICATES + help + This option enables providing Wi-Fi enterprise security certificates at run-time. + Uses the TLS credentials subsystem to store and manage the certificates. + +if WIFI_CREDENTIALS_RUNTIME_CERTIFICATES + +config HEAP_MEM_POOL_ADD_SIZE_WIFI_CERT + int "Wi-Fi enterprise security certificates memory pool size" + # STA - 6 certs and each assume 1500 bytes + default 12000 + help + The size of the memory pool used by the Wi-Fi enterprise security certificates. + +endif # WIFI_CREDENTIALS_RUNTIME_CERTIFICATES + +endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + endif # WIFI_CREDENTIALS_CONNECT_STORED endif # WIFI_CREDENTIALS diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials_shell.c b/subsys/net/lib/wifi_credentials/wifi_credentials_shell.c index 4a51de48e121..c5b8c2a88a39 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials_shell.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials_shell.c @@ -22,10 +22,33 @@ #include +LOG_MODULE_REGISTER(wifi_credentials_shell, CONFIG_WIFI_CREDENTIALS_LOG_LEVEL); + #define MAX_BANDS_STR_LEN 64 #define MACSTR "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx" #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE +#ifdef CONFIG_WIFI_CREDENTIALS_RUNTIME_CERTIFICATES +#include +enum wifi_enterprise_cert_sec_tags { + WIFI_CERT_CA_SEC_TAG = 0x1020001, + WIFI_CERT_CLIENT_KEY_SEC_TAG, + WIFI_CERT_SERVER_KEY_SEC_TAG, + WIFI_CERT_CLIENT_SEC_TAG, + WIFI_CERT_SERVER_SEC_TAG, + /* Phase 2 */ + WIFI_CERT_CA_P2_SEC_TAG, + WIFI_CERT_CLIENT_KEY_P2_SEC_TAG, + WIFI_CERT_CLIENT_P2_SEC_TAG, +}; + +struct wifi_cert_data { + enum tls_credential_type type; + uint32_t sec_tag; + uint8_t **data; + size_t *len; +}; +#else static const char ca_cert_test[] = { #include '\0' @@ -52,25 +75,184 @@ static const char client_cert2_test[] = { static const char client_key2_test[] = { #include '\0'}; +#endif /* CONFIG_WIFI_CREDENTIALS_RUNTIME_CERTIFICATES */ #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE */ #if defined CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE -static int cmd_wifi_set_enterprise_creds(const struct shell *sh, struct net_if *iface) +#ifdef CONFIG_WIFI_CREDENTIALS_RUNTIME_CERTIFICATES + +struct wifi_enterprise_creds_params enterprise_creds_params; + +static int process_certificates(struct wifi_cert_data *certs, size_t cert_count) +{ + for (size_t i = 0; i < cert_count; i++) { + int err; + size_t len = 0; + uint8_t *cert_tmp; + + err = tls_credential_get(certs[i].sec_tag, certs[i].type, NULL, &len); + if (err != -EFBIG) { + LOG_ERR("Failed to get credential tag: %d length, err: %d", + certs[i].sec_tag, err); + return err; + } + + cert_tmp = k_malloc(len); + if (!cert_tmp) { + LOG_ERR("Failed to allocate memory for credential tag: %d", + certs[i].sec_tag); + return -ENOMEM; + } + + err = tls_credential_get(certs[i].sec_tag, certs[i].type, cert_tmp, &len); + if (err) { + LOG_ERR("Failed to get credential tag: %d", certs[i].sec_tag); + k_free(cert_tmp); + return err; + } + + *certs[i].data = cert_tmp; + *certs[i].len = len; + } + + return 0; +} + +static void set_enterprise_creds_params(struct wifi_enterprise_creds_params *params, + bool is_ap) +{ + struct wifi_cert_data certs_common[] = { + { + .type = TLS_CREDENTIAL_CA_CERTIFICATE, + .sec_tag = WIFI_CERT_CA_SEC_TAG, + .data = ¶ms->ca_cert, + .len = ¶ms->ca_cert_len, + }, + }; + + struct wifi_cert_data certs_sta[] = { + { + .type = TLS_CREDENTIAL_PRIVATE_KEY, + .sec_tag = WIFI_CERT_CLIENT_KEY_SEC_TAG, + .data = ¶ms->client_key, + .len = ¶ms->client_key_len, + }, + { + .type = TLS_CREDENTIAL_PUBLIC_CERTIFICATE, + .sec_tag = WIFI_CERT_CLIENT_SEC_TAG, + .data = ¶ms->client_cert, + .len = ¶ms->client_cert_len, + }, + { + .type = TLS_CREDENTIAL_CA_CERTIFICATE, + .sec_tag = WIFI_CERT_CA_P2_SEC_TAG, + .data = ¶ms->ca_cert2, + .len = ¶ms->ca_cert2_len, + }, + { + .type = TLS_CREDENTIAL_PRIVATE_KEY, + .sec_tag = WIFI_CERT_CLIENT_KEY_P2_SEC_TAG, + .data = ¶ms->client_key2, + .len = ¶ms->client_key2_len, + }, + { + .type = TLS_CREDENTIAL_PUBLIC_CERTIFICATE, + .sec_tag = WIFI_CERT_CLIENT_P2_SEC_TAG, + .data = ¶ms->client_cert2, + .len = ¶ms->client_cert2_len, + }, + }; + + memset(params, 0, sizeof(*params)); + + /* Process common certificates */ + if (process_certificates(certs_common, ARRAY_SIZE(certs_common)) != 0) { + goto cleanup; + } + + /* Process STA-specific certificates */ + if (!is_ap) { + if (process_certificates(certs_sta, ARRAY_SIZE(certs_sta)) != 0) { + goto cleanup; + } + } + + memcpy(&enterprise_creds_params, params, sizeof(*params)); + return; + +cleanup: + for (size_t i = 0; i < ARRAY_SIZE(certs_common); i++) { + if (certs_common[i].data) { + k_free(*certs_common[i].data); + *certs_common[i].data = NULL; + } + } + + if (!is_ap) { + for (size_t i = 0; i < ARRAY_SIZE(certs_sta); i++) { + if (certs_sta[i].data) { + k_free(*certs_sta[i].data); + *certs_sta[i].data = NULL; + } + } + } + +} + +static void clear_enterprise_creds_params(struct wifi_enterprise_creds_params *params) +{ + if (params == NULL) { + return; + } + + const uint8_t *certs[] = { + params->ca_cert, + params->client_cert, + params->client_key, + params->ca_cert2, + params->client_cert2, + params->client_key2, + }; + + for (size_t i = 0; i < ARRAY_SIZE(certs); i++) { + k_free((void *)certs[i]); + } + memset(params, 0, sizeof(*params)); +} +#else +static void set_enterprise_creds_params(struct wifi_enterprise_creds_params *params, + bool is_ap) +{ + params->ca_cert = (uint8_t *)ca_cert_test; + params->ca_cert_len = ARRAY_SIZE(ca_cert_test); + + if (!is_ap) { + params->client_cert = (uint8_t *)client_cert_test; + params->client_cert_len = ARRAY_SIZE(client_cert_test); + params->client_key = (uint8_t *)client_key_test; + params->client_key_len = ARRAY_SIZE(client_key_test); + params->ca_cert2 = (uint8_t *)ca_cert2_test; + params->ca_cert2_len = ARRAY_SIZE(ca_cert2_test); + params->client_cert2 = (uint8_t *)client_cert2_test; + params->client_cert2_len = ARRAY_SIZE(client_cert2_test); + params->client_key2 = (uint8_t *)client_key2_test; + params->client_key2_len = ARRAY_SIZE(client_key2_test); + + return; + } +} +#endif /* CONFIG_WIFI_CREDENTIALS_RUNTIME_CERTIFICATES */ + +static int wifi_set_enterprise_creds(const struct shell *sh, struct net_if *iface, + bool is_ap) { struct wifi_enterprise_creds_params params = {0}; - params.ca_cert = (uint8_t *)ca_cert_test; - params.ca_cert_len = ARRAY_SIZE(ca_cert_test); - params.client_cert = (uint8_t *)client_cert_test; - params.client_cert_len = ARRAY_SIZE(client_cert_test); - params.client_key = (uint8_t *)client_key_test; - params.client_key_len = ARRAY_SIZE(client_key_test); - params.ca_cert2 = (uint8_t *)ca_cert2_test; - params.ca_cert2_len = ARRAY_SIZE(ca_cert2_test); - params.client_cert2 = (uint8_t *)client_cert2_test; - params.client_cert2_len = ARRAY_SIZE(client_cert2_test); - params.client_key2 = (uint8_t *)client_key2_test; - params.client_key2_len = ARRAY_SIZE(client_key2_test); +#ifdef CONFIG_WIFI_SHELL_RUNTIME_CERTIFICATES + clear_enterprise_creds_params(&enterprise_creds_params); +#endif /* CONFIG_WIFI_SHELL_RUNTIME_CERTIFICATES */ + + set_enterprise_creds_params(¶ms, is_ap); if (net_mgmt(NET_REQUEST_WIFI_ENTERPRISE_CREDS, iface, ¶ms, sizeof(params))) { shell_warn(sh, "Set enterprise credentials failed\n"); @@ -340,7 +522,7 @@ static int cmd_add_network(const struct shell *sh, size_t argc, char *argv[]) } #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE - struct net_if *iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET)); + struct net_if *iface = net_if_get_wifi_sta(); /* Load the enterprise credentials if needed */ if (creds.header.type == WIFI_SECURITY_TYPE_EAP_TLS || @@ -348,7 +530,7 @@ static int cmd_add_network(const struct shell *sh, size_t argc, char *argv[]) creds.header.type == WIFI_SECURITY_TYPE_EAP_PEAP_GTC || creds.header.type == WIFI_SECURITY_TYPE_EAP_TTLS_MSCHAPV2 || creds.header.type == WIFI_SECURITY_TYPE_EAP_PEAP_TLS) { - cmd_wifi_set_enterprise_creds(sh, iface); + wifi_set_enterprise_creds(sh, iface, 0); } #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE */ @@ -368,6 +550,12 @@ static int cmd_delete_network(const struct shell *sh, size_t argc, char *argv[]) } shell_print(sh, "\tDeleting network ssid: \"%s\", ssid_len: %d", argv[1], strlen(argv[1])); + +#ifdef CONFIG_WIFI_SHELL_RUNTIME_CERTIFICATES + /* Clear the certificates */ + clear_enterprise_creds_params(&enterprise_creds_params); +#endif /* CONFIG_WIFI_SHELL_RUNTIME_CERTIFICATES */ + return wifi_credentials_delete_by_ssid(argv[1], strlen(argv[1])); } @@ -381,7 +569,11 @@ static int cmd_list_networks(const struct shell *sh, size_t argc, char *argv[]) static int cmd_auto_connect(const struct shell *sh, size_t argc, char *argv[]) { - struct net_if *iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET)); + struct net_if *iface = net_if_get_wifi_sta(); + +#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + wifi_set_enterprise_creds(sh, iface, 0); +#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE */ int rc = net_mgmt(NET_REQUEST_WIFI_CONNECT_STORED, iface, NULL, 0); if (rc) { diff --git a/subsys/usb/device/class/bluetooth.c b/subsys/usb/device/class/bluetooth.c index 33774eef90d7..7edd4792749b 100644 --- a/subsys/usb/device/class/bluetooth.c +++ b/subsys/usb/device/class/bluetooth.c @@ -154,20 +154,20 @@ static void hci_tx_thread(void *p1, void *p2, void *p3) type = net_buf_pull_u8(buf); switch (type) { - case BT_BUF_EVT: + case BT_HCI_H4_EVT: usb_transfer_sync( bluetooth_ep_data[HCI_INT_EP_IDX].ep_addr, buf->data, buf->len, USB_TRANS_WRITE | USB_TRANS_NO_ZLP); break; - case BT_BUF_ACL_IN: + case BT_HCI_H4_ACL: usb_transfer_sync( bluetooth_ep_data[HCI_IN_EP_IDX].ep_addr, buf->data, buf->len, USB_TRANS_WRITE); break; default: - LOG_ERR("Unknown type %u", type); + LOG_ERR("Unsupported type %u", type); break; } @@ -200,11 +200,11 @@ static uint16_t hci_acl_pkt_len(const uint8_t *data, size_t data_len) struct bt_hci_acl_hdr *acl_hdr; size_t hdr_len = sizeof(*acl_hdr); - if (data_len - 1 < hdr_len) { + if (data_len < hdr_len) { return 0; } - acl_hdr = (struct bt_hci_acl_hdr *)(data + 1); + acl_hdr = (struct bt_hci_acl_hdr *)data; return sys_le16_to_cpu(acl_hdr->len) + hdr_len; } @@ -250,7 +250,7 @@ static void acl_read_cb(uint8_t ep, int size, void *priv) LOG_DBG("len %u, chunk %u", buf->len, size); } - if (buf != NULL && pkt_len == buf->len) { + if (buf != NULL && pkt_len == buf->len - 1) { k_fifo_put(&rx_queue, buf); LOG_DBG("put"); buf = NULL; diff --git a/subsys/usb/device_next/class/bt_hci.c b/subsys/usb/device_next/class/bt_hci.c index 13665c78a1df..7a2dc6da5985 100644 --- a/subsys/usb/device_next/class/bt_hci.c +++ b/subsys/usb/device_next/class/bt_hci.c @@ -189,8 +189,12 @@ static void bt_hci_tx_sync_in(struct usbd_class_data *const c_data, } net_buf_add_mem(buf, bt_buf->data, bt_buf->len); - usbd_ep_enqueue(c_data, buf); - k_sem_take(&hci_data->sync_sem, K_FOREVER); + if (usbd_ep_enqueue(c_data, buf)) { + LOG_ERR("Failed to enqueue transfer"); + } else { + k_sem_take(&hci_data->sync_sem, K_FOREVER); + } + net_buf_unref(buf); } @@ -210,14 +214,14 @@ static void bt_hci_tx_thread(void *p1, void *p2, void *p3) type = net_buf_pull_u8(bt_buf); switch (type) { - case BT_BUF_EVT: + case BT_HCI_H4_EVT: ep = bt_hci_get_int_in(c_data); break; - case BT_BUF_ACL_IN: + case BT_HCI_H4_ACL: ep = bt_hci_get_bulk_in(c_data); break; default: - LOG_ERR("Unknown type %u", type); + LOG_ERR("Unsupported type %u", type); continue; } @@ -273,19 +277,43 @@ static int bt_hci_acl_out_start(struct usbd_class_data *const c_data) return ret; } -static uint16_t hci_acl_pkt_len(struct net_buf *const buf) +static uint16_t hci_pkt_get_len(const uint8_t h4_type, + const uint8_t *data, const size_t size) { - struct bt_hci_acl_hdr *acl_hdr; - size_t hdr_len; + size_t hdr_len = 0; + uint16_t len = 0; - hdr_len = sizeof(*acl_hdr); - if (buf->len - 1 < hdr_len) { - return 0; + switch (h4_type) { + case BT_HCI_H4_CMD: { + struct bt_hci_cmd_hdr *cmd_hdr; + + hdr_len = sizeof(*cmd_hdr); + cmd_hdr = (struct bt_hci_cmd_hdr *)data; + len = cmd_hdr->param_len + hdr_len; + break; } + case BT_HCI_H4_ACL: { + struct bt_hci_acl_hdr *acl_hdr; - acl_hdr = (struct bt_hci_acl_hdr *)(buf->data + 1); + hdr_len = sizeof(*acl_hdr); + acl_hdr = (struct bt_hci_acl_hdr *)data; + len = sys_le16_to_cpu(acl_hdr->len) + hdr_len; + break; + } + case BT_HCI_H4_ISO: { + struct bt_hci_iso_hdr *iso_hdr; + + hdr_len = sizeof(*iso_hdr); + iso_hdr = (struct bt_hci_iso_hdr *)data; + len = bt_iso_hdr_len(sys_le16_to_cpu(iso_hdr->len)) + hdr_len; + break; + } + default: + LOG_ERR("Unknown H4 buffer type"); + return 0; + } - return sys_le16_to_cpu(acl_hdr->len) + hdr_len; + return (size < hdr_len) ? 0 : len; } static int bt_hci_acl_out_cb(struct usbd_class_data *const c_data, @@ -305,7 +333,9 @@ static int bt_hci_acl_out_cb(struct usbd_class_data *const c_data, goto restart_out_transfer; } - hci_data->acl_len = hci_acl_pkt_len(hci_data->acl_buf); + hci_data->acl_len = hci_pkt_get_len(BT_HCI_H4_ACL, + buf->data, + buf->len); LOG_DBG("acl_len %u, chunk %u", hci_data->acl_len, buf->len); @@ -330,7 +360,11 @@ static int bt_hci_acl_out_cb(struct usbd_class_data *const c_data, LOG_INF("len %u, chunk %u", hci_data->acl_buf->len, buf->len); } - if (hci_data->acl_buf != NULL && hci_data->acl_len == hci_data->acl_buf->len) { + /* + * The buffer obtained from bt_buf_get_tx() stores the type at the top. + * Take this into account when comparing received data length. + */ + if (hci_data->acl_buf != NULL && hci_data->acl_len == hci_data->acl_buf->len - 1) { k_fifo_put(&bt_hci_rx_queue, hci_data->acl_buf); hci_data->acl_buf = NULL; hci_data->acl_len = 0; diff --git a/subsys/usb/device_next/class/usbd_hid.c b/subsys/usb/device_next/class/usbd_hid.c index fd10eba3c850..d5476a88ed69 100644 --- a/subsys/usb/device_next/class/usbd_hid.c +++ b/subsys/usb/device_next/class/usbd_hid.c @@ -65,6 +65,7 @@ struct hid_device_config { struct usbd_class_data *c_data; struct net_buf_pool *pool_out; struct net_buf_pool *pool_in; + struct usbd_desc_node *const if_desc_data; const struct usb_desc_header **fs_desc; const struct usb_desc_header **hs_desc; }; @@ -488,8 +489,21 @@ static void *usbd_hid_get_desc(struct usbd_class_data *const c_data, static int usbd_hid_init(struct usbd_class_data *const c_data) { + struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data); + const struct device *dev = usbd_class_get_private(c_data); + const struct hid_device_config *dcfg = dev->config; + struct usbd_hid_descriptor *const desc = dcfg->desc; + LOG_DBG("HID class %s init", c_data->name); + if (dcfg->if_desc_data != NULL && desc->if0.iInterface == 0) { + if (usbd_add_descriptor(uds_ctx, dcfg->if_desc_data)) { + LOG_ERR("Failed to add interface string descriptor"); + } else { + desc->if0.iInterface = usbd_str_desc_get_idx(dcfg->if_desc_data); + } + } + return 0; } @@ -750,6 +764,12 @@ static const struct hid_device_driver_api hid_device_api = { HID_OUT_POOL_DEFINE(n); \ USBD_HID_INTERFACE_DEFINE(n); \ \ + IF_ENABLED(DT_INST_NODE_HAS_PROP(n, label), ( \ + USBD_DESC_STRING_DEFINE(hid_if_desc_data_##n, \ + DT_INST_PROP(n, label), \ + USBD_DUT_STRING_INTERFACE); \ + )) \ + \ USBD_DEFINE_CLASS(hid_##n, \ &usbd_hid_api, \ (void *)DEVICE_DT_GET(DT_DRV_INST(n)), NULL); \ @@ -761,6 +781,9 @@ static const struct hid_device_driver_api hid_device_api = { .pool_out = HID_OUT_POOL_ADDR(n), \ .fs_desc = hid_fs_desc_##n, \ .hs_desc = hid_hs_desc_##n, \ + IF_ENABLED(DT_INST_NODE_HAS_PROP(n, label), ( \ + .if_desc_data = &hid_if_desc_data_##n, \ + )) \ }; \ \ static struct hid_device_data hid_data_##n; \ diff --git a/subsys/usb/device_next/usbd_ch9.c b/subsys/usb/device_next/usbd_ch9.c index c9f806960d75..3adb3574f0cb 100644 --- a/subsys/usb/device_next/usbd_ch9.c +++ b/subsys/usb/device_next/usbd_ch9.c @@ -683,12 +683,6 @@ static int sreq_get_dev_qualifier(struct usbd_context *const uds_ctx, struct usb_device_qualifier_descriptor q_desc = { .bLength = sizeof(struct usb_device_qualifier_descriptor), .bDescriptorType = USB_DESC_DEVICE_QUALIFIER, - .bcdUSB = d_desc->bcdUSB, - .bDeviceClass = d_desc->bDeviceClass, - .bDeviceSubClass = d_desc->bDeviceSubClass, - .bDeviceProtocol = d_desc->bDeviceProtocol, - .bMaxPacketSize0 = d_desc->bMaxPacketSize0, - .bNumConfigurations = d_desc->bNumConfigurations, .bReserved = 0U, }; size_t len; @@ -703,6 +697,17 @@ static int sreq_get_dev_qualifier(struct usbd_context *const uds_ctx, return 0; } + if (d_desc == NULL) { + return -EINVAL; + } + + q_desc.bcdUSB = d_desc->bcdUSB; + q_desc.bDeviceClass = d_desc->bDeviceClass; + q_desc.bDeviceSubClass = d_desc->bDeviceSubClass; + q_desc.bDeviceProtocol = d_desc->bDeviceProtocol; + q_desc.bMaxPacketSize0 = d_desc->bMaxPacketSize0; + q_desc.bNumConfigurations = d_desc->bNumConfigurations; + LOG_DBG("Get Device Qualifier"); len = MIN(setup->wLength, net_buf_tailroom(buf)); net_buf_add_mem(buf, &q_desc, MIN(len, q_desc.bLength)); diff --git a/subsys/usb/device_next/usbd_device.c b/subsys/usb/device_next/usbd_device.c index bb011e0731c7..fcb689a5c567 100644 --- a/subsys/usb/device_next/usbd_device.c +++ b/subsys/usb/device_next/usbd_device.c @@ -66,6 +66,11 @@ int usbd_device_set_bcd_usb(struct usbd_context *const uds_ctx, } desc = get_device_descriptor(uds_ctx, speed); + if (desc == NULL) { + ret = -EINVAL; + goto set_bcd_exit; + } + desc->bcdUSB = sys_cpu_to_le16(bcd); set_bcd_exit: @@ -167,6 +172,11 @@ int usbd_device_set_code_triple(struct usbd_context *const uds_ctx, } desc = get_device_descriptor(uds_ctx, speed); + if (desc == NULL) { + ret = -EINVAL; + goto set_code_triple_exit; + } + desc->bDeviceClass = base_class; desc->bDeviceSubClass = subclass; desc->bDeviceProtocol = protocol; diff --git a/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpuapp.conf index 0bcc82e646b1..025c842f70bb 100644 --- a/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpuapp.conf +++ b/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -1 +1,2 @@ CONFIG_SOC_NRF54H20_GPD=n +CONFIG_SSF_CLIENT_SYS_INIT=n diff --git a/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpurad.conf b/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpurad.conf index 0bcc82e646b1..025c842f70bb 100644 --- a/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpurad.conf +++ b/tests/arch/arm/arm_irq_vector_table/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -1 +1,2 @@ CONFIG_SOC_NRF54H20_GPD=n +CONFIG_SSF_CLIENT_SYS_INIT=n diff --git a/tests/arch/arm/arm_thread_swap/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/arch/arm/arm_thread_swap/boards/nrf54h20dk_nrf54h20_cpuapp.overlay deleted file mode 100644 index f9615d1b35ec..000000000000 --- a/tests/arch/arm/arm_thread_swap/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ - -&cpusec_cpuapp_ipc { - status = "disabled"; -}; - -&cpusec_bellboard { - status = "disabled"; -}; diff --git a/tests/arch/common/ramfunc/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/arch/common/ramfunc/boards/nrf54h20dk_nrf54h20_cpuapp.overlay deleted file mode 100644 index ad84324a3e94..000000000000 --- a/tests/arch/common/ramfunc/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -&cpuapp_ram0x_region { - nordic,access = ; -}; diff --git a/tests/bluetooth/controller/ctrl_api/testcase.yaml b/tests/bluetooth/controller/ctrl_api/testcase.yaml index 19bf6c9ab490..21f178bf9b2b 100644 --- a/tests/bluetooth/controller/ctrl_api/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_api/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_api.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_chmu/testcase.yaml b/tests/bluetooth/controller/ctrl_chmu/testcase.yaml index f7e8068d60ec..9c3ee6264335 100644 --- a/tests/bluetooth/controller/ctrl_chmu/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_chmu/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_chmu.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml b/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml index 99612a89bc31..2371d7063eb7 100644 --- a/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cis_create.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml b/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml index 956172a89b20..a98229ba45f3 100644 --- a/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cis_terminate.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_collision/testcase.yaml b/tests/bluetooth/controller/ctrl_collision/testcase.yaml index 6086a9a4ebc8..daa8f3bc6c3d 100644 --- a/tests/bluetooth/controller/ctrl_collision/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_collision/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_collision.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml b/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml index 5b0bda4b9088..fc4ecb0b647d 100644 --- a/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml @@ -7,11 +7,18 @@ common: tests: bluetooth.controller.ctrl_conn_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_conn_update.apm_test: type: unit - extra_args: CONF_FILE=prj_apm.conf + extra_args: + - CONF_FILE=prj_apm.conf + - SNIPPET="bt-ll-sw-split" + bluetooth.controller.ctrl_conn_update.no_param_req_test: type: unit - extra_args: CONF_FILE=prj_no_param_req.conf + extra_args: + - CONF_FILE=prj_no_param_req.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml b/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml index fd6ff51118d9..c6288aecc433 100644 --- a/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cte_req.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml b/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml index 9778af435b4a..c7d1174e12bf 100644 --- a/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml @@ -6,11 +6,17 @@ common: tests: bluetooth.controller.ctrl_data_length_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_data_length_update.test_nocodedphy: type: unit - extra_args: CONF_FILE=prj_nocoded.conf + extra_args: + - CONF_FILE=prj_nocoded.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_data_length_update.test_nophy: type: unit - extra_args: CONF_FILE=prj_nophy.conf + extra_args: + - CONF_FILE=prj_nophy.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml b/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml index d5bb2cb8b110..86dd5bfe4d30 100644 --- a/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_encrypt.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml b/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml index 257542f36120..087e49575ff7 100644 --- a/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_feature_exchange.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_hci/testcase.yaml b/tests/bluetooth/controller/ctrl_hci/testcase.yaml index c750ebc8dd8e..5e00c85f6f43 100644 --- a/tests/bluetooth/controller/ctrl_hci/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_hci/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_hci.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_invalid/testcase.yaml b/tests/bluetooth/controller/ctrl_invalid/testcase.yaml index 2d1741931e37..cee54e6b09ed 100644 --- a/tests/bluetooth/controller/ctrl_invalid/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_invalid/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_invalid.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml b/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml index b6a77528f32d..54178905da17 100644 --- a/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_le_ping.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml b/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml index 0991b0cdd43c..a9445cbf8c4d 100644 --- a/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_min_used_chans.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml b/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml index 1d7da169f1d8..d5c49d587a8f 100644 --- a/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml @@ -6,6 +6,10 @@ common: tests: bluetooth.controller.ctrl_phy_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_phy_update.test_reduced_buf: type: unit - extra_args: CONF_FILE=prj_rx_cnt.conf + extra_args: + - CONF_FILE=prj_rx_cnt.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml b/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml index cbf63aa1b575..cbc3c3faf720 100644 --- a/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_sca_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml b/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml index 778606d69549..ac5dd6e957eb 100644 --- a/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml @@ -4,3 +4,5 @@ common: tests: bluetooth.ctrl_sw_privacy.test: platform_allow: nrf52_bsim + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_terminate/testcase.yaml b/tests/bluetooth/controller/ctrl_terminate/testcase.yaml index cbe639401ea3..6b1409e9653e 100644 --- a/tests/bluetooth/controller/ctrl_terminate/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_terminate/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_terminate.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml b/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml index 614eb7fe94c0..363986bd3d35 100644 --- a/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml @@ -6,23 +6,35 @@ common: tests: bluetooth.controller.ctrl_tx_buffer_alloc.test_0_per_conn: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_1_per_conn: type: unit - extra_args: CONF_FILE=prj_1.conf + extra_args: + - CONF_FILE=prj_1.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_2_per_conn: type: unit - extra_args: CONF_FILE=prj_2.conf + extra_args: + - CONF_FILE=prj_2.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_3_per_conn: type: unit - extra_args: CONF_FILE=prj_3.conf + extra_args: + - CONF_FILE=prj_3.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_max_per_conn_alloc: type: unit - extra_args: CONF_FILE=prj_max.conf + extra_args: + - CONF_FILE=prj_max.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_max_common_alloc: type: unit - extra_args: CONF_FILE=prj_max_common.conf + extra_args: + - CONF_FILE=prj_max_common.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml b/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml index 295ad891a630..282b620b317a 100644 --- a/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml @@ -5,3 +5,5 @@ common: tests: bluetooth.ctrl_tx_queue.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml b/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml index 28aba1a752a8..48b18af93536 100644 --- a/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml @@ -6,7 +6,11 @@ common: tests: bluetooth.controller.ctrl_unsupported.default.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_unsupported.test: type: unit - extra_args: CONF_FILE=prj_unsupported.conf + extra_args: + - CONF_FILE=prj_unsupported.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml b/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml index af319a7a7191..be963df24a8a 100644 --- a/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml @@ -4,3 +4,5 @@ common: tests: bluetooth.ctrl_user_ext.test: platform_allow: nrf52_bsim + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_version/testcase.yaml b/tests/bluetooth/controller/ctrl_version/testcase.yaml index 6badcbc72547..5df86b9bca9f 100644 --- a/tests/bluetooth/controller/ctrl_version/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_version/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_version.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connection_cte_req/testcase.yaml b/tests/bluetooth/df/connection_cte_req/testcase.yaml index 768aba4a51f5..fbfe4b0d9a1a 100644 --- a/tests/bluetooth/df/connection_cte_req/testcase.yaml +++ b/tests/bluetooth/df/connection_cte_req/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.conection_cte_req: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml b/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml index 38a23b0950e3..a9986c5b0e53 100644 --- a/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml +++ b/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.conection_cte_tx_params: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml b/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml index 6aa5bb0f0c1c..844a7bbb524e 100644 --- a/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_chains: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml b/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml index f839b1910eb2..c8f08a908436 100644 --- a/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_rx: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml b/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml index 77d651d0cbc2..491cc0e7e599 100644 --- a/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_tx: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/host/id/mocks/adv.c b/tests/bluetooth/host/id/mocks/adv.c index 2c2d4f3f3c7a..a22123dea3da 100644 --- a/tests/bluetooth/host/id/mocks/adv.c +++ b/tests/bluetooth/host/id/mocks/adv.c @@ -15,3 +15,4 @@ DEFINE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_legacy, struct bt_le_ext_adv *, DEFINE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_ext, struct bt_le_ext_adv *, bool, const struct bt_le_ext_adv_start_param *); DEFINE_FAKE_VOID_FUNC(bt_le_ext_adv_foreach, bt_le_ext_adv_foreach_cb, void *); +DEFINE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_adv_lookup_by_id, uint8_t); diff --git a/tests/bluetooth/host/id/mocks/adv.h b/tests/bluetooth/host/id/mocks/adv.h index bfb744001596..1602ddf47185 100644 --- a/tests/bluetooth/host/id/mocks/adv.h +++ b/tests/bluetooth/host/id/mocks/adv.h @@ -18,7 +18,8 @@ typedef void (*bt_le_ext_adv_foreach_cb)(struct bt_le_ext_adv *adv, void *data); FAKE(bt_le_adv_lookup_legacy) \ FAKE(bt_le_ext_adv_get_index) \ FAKE(bt_le_adv_set_enable_ext) \ - FAKE(bt_le_ext_adv_foreach) + FAKE(bt_le_ext_adv_foreach) \ + FAKE(bt_adv_lookup_by_id) DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable, struct bt_le_ext_adv *, bool); DECLARE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_le_adv_lookup_legacy); @@ -27,3 +28,4 @@ DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_legacy, struct bt_le_ext_adv * DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_ext, struct bt_le_ext_adv *, bool, const struct bt_le_ext_adv_start_param *); DECLARE_FAKE_VOID_FUNC(bt_le_ext_adv_foreach, bt_le_ext_adv_foreach_cb, void *); +DECLARE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_adv_lookup_by_id, uint8_t); diff --git a/tests/bluetooth/host/id/mocks/keys.c b/tests/bluetooth/host/id/mocks/keys.c index f885ab875c0f..61f73569c469 100644 --- a/tests/bluetooth/host/id/mocks/keys.c +++ b/tests/bluetooth/host/id/mocks/keys.c @@ -10,3 +10,4 @@ DEFINE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_find_irk, uint8_t, const bt_addr_le_t *); DEFINE_FAKE_VOID_FUNC(bt_keys_foreach_type, enum bt_keys_type, bt_keys_foreach_type_cb, void *); +DEFINE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_get_addr, uint8_t, const bt_addr_le_t *); diff --git a/tests/bluetooth/host/id/mocks/keys.h b/tests/bluetooth/host/id/mocks/keys.h index b6901e315ab9..1912472b78de 100644 --- a/tests/bluetooth/host/id/mocks/keys.h +++ b/tests/bluetooth/host/id/mocks/keys.h @@ -15,7 +15,9 @@ typedef void (*bt_keys_foreach_type_cb)(struct bt_keys *keys, void *data); /* List of fakes used by this unit tester */ #define KEYS_FFF_FAKES_LIST(FAKE) \ FAKE(bt_keys_find_irk) \ - FAKE(bt_keys_foreach_type) + FAKE(bt_keys_foreach_type) \ + FAKE(bt_keys_get_addr) DECLARE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_find_irk, uint8_t, const bt_addr_le_t *); DECLARE_FAKE_VOID_FUNC(bt_keys_foreach_type, enum bt_keys_type, bt_keys_foreach_type_cb, void *); +DECLARE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_get_addr, uint8_t, const bt_addr_le_t *); diff --git a/tests/bluetooth/init/testcase.yaml b/tests/bluetooth/init/testcase.yaml index dd44257e0128..a5cc40cd39e7 100644 --- a/tests/bluetooth/init/testcase.yaml +++ b/tests/bluetooth/init/testcase.yaml @@ -74,7 +74,9 @@ tests: extra_args: CONF_FILE=prj_9.conf platform_allow: qemu_cortex_m3 bluetooth.init.test_ctlr: - extra_args: CONF_FILE=prj_ctlr.conf + extra_args: + - CONF_FILE=prj_ctlr.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -86,7 +88,9 @@ tests: - nrf51dk/nrf51822 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_4_0: - extra_args: CONF_FILE=prj_ctlr_4_0.conf + extra_args: + - CONF_FILE=prj_ctlr_4_0.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -95,7 +99,9 @@ tests: - nrf52dk/nrf52832 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_4_0_dbg: - extra_args: CONF_FILE=prj_ctlr_4_0_dbg.conf + extra_args: + - CONF_FILE=prj_ctlr_4_0_dbg.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -104,7 +110,9 @@ tests: - nrf52dk/nrf52832 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_tiny: - extra_args: CONF_FILE=prj_ctlr_tiny.conf + extra_args: + - CONF_FILE=prj_ctlr_tiny.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -116,6 +124,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr_dbg.conf - DTC_OVERLAY_FILE=pa_lna.overlay + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -126,6 +135,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr_5_x_dbg.conf - DTC_OVERLAY_FILE=pa_lna.overlay + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -137,6 +147,7 @@ tests: - CONF_FILE=prj_ctlr.conf - CONFIG_BT_CTLR_ADVANCED_FEATURES=y - CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER=y + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf52840dk/nrf52840 @@ -146,13 +157,16 @@ tests: bluetooth.init.test_ctlr_ticker: extra_args: - CONF_FILE=prj_ctlr_ticker.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_broadcaster: - extra_args: CONF_FILE=prj_ctlr_broadcaster.conf + extra_args: + - CONF_FILE=prj_ctlr_broadcaster.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -161,7 +175,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_peripheral: - extra_args: CONF_FILE=prj_ctlr_peripheral.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -170,7 +186,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_peripheral_priv: - extra_args: CONF_FILE=prj_ctlr_peripheral_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -179,7 +197,9 @@ tests: integration_platforms: - nrf52840dk/nrf52840 bluetooth.init.test_ctlr_observer: - extra_args: CONF_FILE=prj_ctlr_observer.conf + extra_args: + - CONF_FILE=prj_ctlr_observer.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -188,7 +208,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_central: - extra_args: CONF_FILE=prj_ctlr_central.conf + extra_args: + - CONF_FILE=prj_ctlr_central.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -198,7 +220,9 @@ tests: - nrf52dk/nrf52832 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_central_priv: - extra_args: CONF_FILE=prj_ctlr_central_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_central_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -208,7 +232,9 @@ tests: - nrf52dk/nrf52832 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_broadcaster_ext: - extra_args: CONF_FILE=prj_ctlr_broadcaster_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_broadcaster_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -217,7 +243,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_ext: - extra_args: CONF_FILE=prj_ctlr_peripheral_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -226,7 +254,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_ext_priv: - extra_args: CONF_FILE=prj_ctlr_peripheral_ext_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_ext_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -235,7 +265,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_oberver_ext: - extra_args: CONF_FILE=prj_ctlr_observer_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_observer_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -244,7 +276,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_ext: - extra_args: CONF_FILE=prj_ctlr_central_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_central_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -253,7 +287,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_ext_priv: - extra_args: CONF_FILE=prj_ctlr_central_ext_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_central_ext_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -262,7 +298,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_adv: - extra_args: CONF_FILE=prj_ctlr_per_adv.conf + extra_args: + - CONF_FILE=prj_ctlr_per_adv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -271,7 +309,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_adv_no_adi: - extra_args: CONF_FILE=prj_ctlr_per_adv_no_adi.conf + extra_args: + - CONF_FILE=prj_ctlr_per_adv_no_adi.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -280,7 +320,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync: - extra_args: CONF_FILE=prj_ctlr_per_sync.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -289,7 +331,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync_no_adi: - extra_args: CONF_FILE=prj_ctlr_per_sync_no_adi.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync_no_adi.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -298,7 +342,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync_no_filter: - extra_args: CONF_FILE=prj_ctlr_per_sync_no_filter.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync_no_filter.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -307,7 +353,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_iso: - extra_args: CONF_FILE=prj_ctlr_peripheral_iso.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_iso.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -316,7 +364,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_iso: - extra_args: CONF_FILE=prj_ctlr_central_iso.conf + extra_args: + - CONF_FILE=prj_ctlr_central_iso.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -335,7 +385,9 @@ tests: - DTC_OVERLAY_FILE=h5.overlay platform_allow: qemu_cortex_m3 bluetooth.init.test_llcp: - extra_args: CONF_FILE=prj_llcp.conf + extra_args: + - CONF_FILE=prj_llcp.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -347,6 +399,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr.conf - CONFIG_BT_RECV_WORKQ_BT=y + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 bluetooth.init.test_host_6_x: diff --git a/tests/bluetooth/mesh_shell/boards/qemu_x86.conf b/tests/bluetooth/mesh_shell/boards/qemu_x86.conf new file mode 100644 index 000000000000..bfb57193b782 --- /dev/null +++ b/tests/bluetooth/mesh_shell/boards/qemu_x86.conf @@ -0,0 +1,6 @@ +# nrf_security only supports Cortex-M via PSA crypto libraries. +# Enforcing usage of built-in Mbed TLS for native simulator. +CONFIG_NRF_SECURITY=n +CONFIG_MBEDTLS_ENABLE_HEAP=n +CONFIG_TRUSTED_STORAGE=n +CONFIG_SECURE_STORAGE=y diff --git a/tests/bluetooth/mesh_shell/prj.conf b/tests/bluetooth/mesh_shell/prj.conf index 2af600295680..aab2745d359f 100644 --- a/tests/bluetooth/mesh_shell/prj.conf +++ b/tests/bluetooth/mesh_shell/prj.conf @@ -14,7 +14,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT=y CONFIG_BT_OBSERVER=y diff --git a/tests/bluetooth/tester/Kconfig.sysbuild b/tests/bluetooth/tester/Kconfig.sysbuild index 69e4d5a97fbe..e14a6e1aa8e0 100644 --- a/tests/bluetooth/tester/Kconfig.sysbuild +++ b/tests/bluetooth/tester/Kconfig.sysbuild @@ -5,6 +5,7 @@ source "share/sysbuild/Kconfig" config NET_CORE_BOARD string + default "nrf54h20dk/nrf54h20/cpurad" if "$(BOARD)" = "nrf54h20dk" default "nrf5340dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340dk" default "nrf5340_audio_dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340_audio_dk" default "nrf5340bsim/nrf5340/cpunet" if $(BOARD_TARGET_STRING) = "NRF5340BSIM_NRF5340_CPUAPP" diff --git a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf index 5bb1c4d82846..51b0ef5fa8d4 100644 --- a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf +++ b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -22,3 +22,10 @@ CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_BTTESTER_LOG_LEVEL_DBG=y CONFIG_UART_INTERRUPT_DRIVEN=y + +# Enable PSA RNG +CONFIG_PSA_CRYPTO_DRIVER_OBERON=n +CONFIG_PSA_SSF_CRYPTO_CLIENT=y +CONFIG_SSF_PSA_CRYPTO_SERVICE_ENABLED=y +CONFIG_MBEDTLS_PSA_CRYPTO_C=y +CONFIG_NRF_SECURITY=y diff --git a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index e6d4f675f57a..4f9de686b7e5 100644 --- a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -12,3 +12,17 @@ status = "okay"; hw-flow-control; }; + +// Enable PSA RNG +/ { + chosen { + zephyr,entropy = &psa_rng; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; + + /delete-node/ prng; +}; diff --git a/tests/bluetooth/tester/overlay-mesh.conf b/tests/bluetooth/tester/overlay-mesh.conf index 04e6c074e214..9def34c62acf 100644 --- a/tests/bluetooth/tester/overlay-mesh.conf +++ b/tests/bluetooth/tester/overlay-mesh.conf @@ -19,9 +19,9 @@ CONFIG_BT_MESH_CFG_CLI=y CONFIG_BT_MESH_HEALTH_CLI=y CONFIG_BT_MESH_FRIEND=y CONFIG_BT_MESH_FRIEND_QUEUE_SIZE=32 -CONFIG_BT_MESH_RX_SEG_MAX=13 -CONFIG_BT_MESH_TX_SEG_MAX=8 -CONFIG_BT_MESH_TX_SEG_MSG_COUNT=3 +CONFIG_BT_MESH_RX_SEG_MAX=32 +CONFIG_BT_MESH_TX_SEG_MAX=32 +CONFIG_BT_MESH_TX_SEG_MSG_COUNT=10 CONFIG_BT_MESH_LPN_POLL_TIMEOUT=100 CONFIG_BT_MESH_PROVISIONER=y CONFIG_BT_MESH_CDB=y @@ -38,7 +38,6 @@ CONFIG_BT_MESH_LARGE_COMP_DATA_CLI=y CONFIG_BT_MESH_LARGE_COMP_DATA_SRV=y CONFIG_BT_MESH_SAR_CFG_SRV=y CONFIG_BT_MESH_SAR_CFG_CLI=y -CONFIG_BT_MESH_TX_SEG_MSG_COUNT=10 CONFIG_BT_MESH_RPR_SRV=y CONFIG_BT_MESH_RPR_CLI=y CONFIG_BT_MESH_RPR_AD_TYPES_MAX=2 diff --git a/tests/bluetooth/tester/sysbuild.cmake b/tests/bluetooth/tester/sysbuild.cmake index a9ddf1279471..b640a7d04936 100644 --- a/tests/bluetooth/tester/sysbuild.cmake +++ b/tests/bluetooth/tester/sysbuild.cmake @@ -2,8 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) - # For builds in the nrf5340, we build the netcore image with the controller - set(NET_APP hci_ipc) set(NET_APP_SRC_DIR ${ZEPHYR_BASE}/samples/bluetooth/${NET_APP}) @@ -13,6 +11,13 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) BOARD ${SB_CONFIG_NET_CORE_BOARD} ) + if(SB_CONFIG_SOC_NRF5340_CPUAPP) + set(${NET_APP}_SNIPPET + "bt-ll-sw-split" + CACHE INTERNAL "" + ) + endif() + set(${NET_APP}_EXTRA_CONF_FILE ${APP_DIR}/overlay-bt_ll_sw_split.conf CACHE INTERNAL "" diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..b7d64a9e6a08 --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1,40 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_ISR_STACK_SIZE=1024 +CONFIG_IDLE_STACK_SIZE=256 +CONFIG_MAIN_STACK_SIZE=1024 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 +CONFIG_IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE=512 +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y + +CONFIG_BT_BUF_EVT_RX_COUNT=16 +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_CMD_TX_SIZE=255 + +# Host +CONFIG_BT_BROADCASTER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_OBSERVER=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_EXT_ADV=y +CONFIG_BT_PER_ADV=y +CONFIG_BT_PER_ADV_SYNC=y + +# Controller +CONFIG_BT_LL_SW_SPLIT=n +CONFIG_BT_LL_SOFTDEVICE=y +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 + +# Enable PSA RNG +CONFIG_PSA_CRYPTO_DRIVER_OBERON=n +CONFIG_PSA_SSF_CRYPTO_CLIENT=y +CONFIG_SSF_PSA_CRYPTO_SERVICE_ENABLED=y +CONFIG_MBEDTLS_PSA_CRYPTO_C=y +CONFIG_NRF_SECURITY=y diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..e34567fe834a --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,13 @@ +// Enable PSA RNG +/ { + chosen { + zephyr,entropy = &psa_rng; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; + + /delete-node/ prng; +}; diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf b/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf new file mode 100644 index 000000000000..08b1aed9e7f6 --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf @@ -0,0 +1,23 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_HEAP_MEM_POOL_SIZE=4096 + +CONFIG_MAIN_STACK_SIZE=512 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_MAX_CONN=16 + + +# Workaround: Unable to allocate command buffer when using K_NO_WAIT since +# Host number of completed commands does not follow normal flow control. +CONFIG_BT_BUF_CMD_TX_COUNT=10 + +# Enable and adjust the below value as necessary +# CONFIG_BT_BUF_EVT_RX_COUNT=16 +# CONFIG_BT_BUF_EVT_RX_SIZE=255 +# CONFIG_BT_BUF_ACL_RX_SIZE=255 +# CONFIG_BT_BUF_ACL_TX_SIZE=251 +# CONFIG_BT_BUF_CMD_TX_SIZE=255 diff --git a/tests/boards/nrf/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/boards/nrf/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index bf5ba18d2044..970377c4d896 100644 --- a/tests/boards/nrf/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/boards/nrf/coresight_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -7,10 +7,6 @@ status = "okay"; }; -&cpuppr_ram3x_region { - status = "okay"; -}; - &cpuflpr_vpr { status = "okay"; }; diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay index 40c74354e30e..121ac01b7a7d 100644 --- a/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay @@ -7,33 +7,31 @@ &pinctrl { i2c0_default_alt: i2c0_default_alt { group1 { - psels = , - ; + psels = , + ; }; }; i2c0_sleep_alt: i2c0_sleep_alt { group1 { - psels = , - ; + psels = , + ; low-power-enable; }; }; i2c1_default_alt: i2c1_default_alt { group1 { -/* Temporary workaround as it is currently not possible - * to configure pins for TWIS with pinctrl. */ - psels = , - ; + psels = , + ; bias-pull-up; }; }; i2c1_sleep_alt: i2c1_sleep_alt { group1 { - psels = , - ; + psels = , + ; low-power-enable; }; }; diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay index 48577a5a8edf..2ccac66dc723 100644 --- a/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -8,32 +8,30 @@ i2c1_default_alt: i2c1_default_alt { group1 { psels = , - ; + ; }; }; i2c1_sleep_alt: i2c1_sleep_alt { group1 { psels = , - ; + ; low-power-enable; }; }; i2c2_default_alt: i2c2_default_alt { group1 { -/* Temporary workaround as it is currently not possible - * to configure pins for TWIS with pinctrl. */ - psels = , - ; + psels = , + ; bias-pull-up; }; }; i2c2_sleep_alt: i2c2_sleep_alt { group1 { - psels = , - ; + psels = , + ; low-power-enable; }; }; diff --git a/tests/boards/nrf/i2c/i2c_slave/src/main.c b/tests/boards/nrf/i2c/i2c_slave/src/main.c index 1de4b16bc2c6..403c85682908 100644 --- a/tests/boards/nrf/i2c/i2c_slave/src/main.c +++ b/tests/boards/nrf/i2c/i2c_slave/src/main.c @@ -21,8 +21,14 @@ #define I2C_S_INSTANCE 1 #elif CONFIG_NRFX_TWIS2 #define I2C_S_INSTANCE 2 +#elif CONFIG_NRFX_TWIS20 +#define I2C_S_INSTANCE 20 +#elif CONFIG_NRFX_TWIS21 +#define I2C_S_INSTANCE 21 #elif CONFIG_NRFX_TWIS22 #define I2C_S_INSTANCE 22 +#elif CONFIG_NRFX_TWIS30 +#define I2C_S_INSTANCE 30 #elif CONFIG_NRFX_TWIS131 #define I2C_S_INSTANCE 131 #else diff --git a/tests/boards/nrf/nrfs/Kconfig.sysbuild b/tests/boards/nrf/nrfs/Kconfig.sysbuild index f281257725fc..6cc7dc9575af 100644 --- a/tests/boards/nrf/nrfs/Kconfig.sysbuild +++ b/tests/boards/nrf/nrfs/Kconfig.sysbuild @@ -6,4 +6,3 @@ source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" config REMOTE_BOARD string default "$(BOARD)/nrf54h20/cpurad" if SOC_NRF54H20_CPUAPP - default "$(BOARD)/nrf54h20/cpuapp" if SOC_NRF54H20_CPURAD diff --git a/tests/boards/nrf/nrfs/prj.conf b/tests/boards/nrf/nrfs/prj.conf index c1a01949d601..ee3da6976c4e 100644 --- a/tests/boards/nrf/nrfs/prj.conf +++ b/tests/boards/nrf/nrfs/prj.conf @@ -19,3 +19,5 @@ CONFIG_LOG=y CONFIG_LOG_MODE_IMMEDIATE=n CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y + +CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y diff --git a/tests/boards/nrf/nrfs/testcase.yaml b/tests/boards/nrf/nrfs/testcase.yaml index 315c3cf7f375..d1974f00d7c0 100644 --- a/tests/boards/nrf/nrfs/testcase.yaml +++ b/tests/boards/nrf/nrfs/testcase.yaml @@ -1,10 +1,8 @@ common: platform_allow: - nrf54h20dk/nrf54h20/cpuapp - - nrf54h20dk/nrf54h20/cpurad integration_platforms: - nrf54h20dk/nrf54h20/cpuapp - - nrf54h20dk/nrf54h20/cpurad tags: - nrfs harness: ztest diff --git a/tests/boot/mcuboot_recovery_retention/sysbuild.conf b/tests/boot/mcuboot_recovery_retention/sysbuild.conf index 47f00ff3cff8..3b5b3c963800 100644 --- a/tests/boot/mcuboot_recovery_retention/sysbuild.conf +++ b/tests/boot/mcuboot_recovery_retention/sysbuild.conf @@ -1 +1,2 @@ SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/boot/test_mcuboot/sysbuild.conf b/tests/boot/test_mcuboot/sysbuild.conf index 47f00ff3cff8..3b5b3c963800 100644 --- a/tests/boot/test_mcuboot/sysbuild.conf +++ b/tests/boot/test_mcuboot/sysbuild.conf @@ -1 +1,2 @@ SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/crypto/mbedtls/CMakeLists.txt b/tests/crypto/mbedtls/CMakeLists.txt index 7ebdc9d76a9a..47670bead010 100644 --- a/tests/crypto/mbedtls/CMakeLists.txt +++ b/tests/crypto/mbedtls/CMakeLists.txt @@ -6,15 +6,5 @@ project(mbedtls) set(output_file ${PROJECT_BINARY_DIR}/mbedtls-check.timestamp) -add_custom_command( - COMMENT "Check Mbed TLS auto-generated files" - COMMAND - ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/modules/mbedtls/create_psa_files.py --check - OUTPUT - ${output_file} -) - -add_custom_target(check_mbedtls_auto_generated_files ALL DEPENDS ${output_file}) - FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) diff --git a/tests/crypto/secp256r1/mbedtls.conf b/tests/crypto/secp256r1/mbedtls.conf index bbc2eb0e6563..c4ea620de55f 100644 --- a/tests/crypto/secp256r1/mbedtls.conf +++ b/tests/crypto/secp256r1/mbedtls.conf @@ -1,6 +1,7 @@ CONFIG_MBEDTLS=y CONFIG_MBEDTLS_PSA_CRYPTO_C=y CONFIG_MBEDTLS_PSA_P256M_DRIVER_ENABLED=y +CONFIG_MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE=65 CONFIG_MBEDTLS_PSA_STATIC_KEY_SLOTS=y CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=2 diff --git a/tests/drivers/adc/adc_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay b/tests/drivers/adc/adc_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay deleted file mode 100644 index 0e01ff40bb9e..000000000000 --- a/tests/drivers/adc/adc_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright (c) 2025 Nordic Semiconductor - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "nrf54h20dk_nrf54h20_common.dtsi" diff --git a/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_common.dtsi b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_common.dtsi new file mode 100644 index 000000000000..d90e7fc93c17 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_common.dtsi @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2025 Nordic Semiconductor ASA + */ + +/ { + zephyr,user { + io-channels = <&adc 0>, <&adc 1>, <&adc 2>; + }; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1_2"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; + + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_2"; + zephyr,reference = "ADC_REF_EXTERNAL0"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; + + channel@2 { + reg = <2>; + zephyr,gain = "ADC_GAIN_2_3"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; +}; diff --git a/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp.overlay b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp.overlay index d9c1f965addb..cd9ca89b82a3 100644 --- a/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp.overlay +++ b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp.overlay @@ -1,43 +1,7 @@ /* * SPDX-License-Identifier: Apache-2.0 * - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA */ -/ { - zephyr,user { - io-channels = <&adc 0>, <&adc 1>, <&adc 2>; - }; -}; - -&adc { - #address-cells = <1>; - #size-cells = <0>; - - channel@0 { - reg = <0>; - zephyr,gain = "ADC_GAIN_1_2"; - zephyr,reference = "ADC_REF_INTERNAL"; - zephyr,acquisition-time = ; - zephyr,input-positive = ; - zephyr,resolution = <10>; - }; - - channel@1 { - reg = <1>; - zephyr,gain = "ADC_GAIN_2"; - zephyr,reference = "ADC_REF_EXTERNAL0"; - zephyr,acquisition-time = ; - zephyr,input-positive = ; - zephyr,resolution = <10>; - }; - - channel@2 { - reg = <2>; - zephyr,gain = "ADC_GAIN_1_2"; - zephyr,reference = "ADC_REF_INTERNAL"; - zephyr,acquisition-time = ; - zephyr,input-positive = ; - zephyr,resolution = <10>; - }; -}; +#include "nrf9280pdk_nrf9280_common.dtsi" diff --git a/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay new file mode 100644 index 000000000000..cd9ca89b82a3 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay @@ -0,0 +1,7 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2025 Nordic Semiconductor ASA + */ + +#include "nrf9280pdk_nrf9280_common.dtsi" diff --git a/tests/drivers/build_all/gpio/app.overlay b/tests/drivers/build_all/gpio/app.overlay index ccb794dd8477..367455b5f0db 100644 --- a/tests/drivers/build_all/gpio/app.overlay +++ b/tests/drivers/build_all/gpio/app.overlay @@ -413,6 +413,30 @@ ngpios = <16>; int-gpios = <&test_gpio 0 0>; }; + + test_i2c_npm1300: pmic@1d { + compatible = "nordic,npm1300"; + reg = <0x1d>; + + npm1300_gpio: gpio-controller { + compatible = "nordic,npm1300-gpio"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <5>; + }; + }; + + test_i2c_npm1304: pmic@1e { + compatible = "nordic,npm1304"; + reg = <0x1e>; + + npm1304_gpio: gpio-controller { + compatible = "nordic,npm1304-gpio"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <5>; + }; + }; }; nct3807_alert_1 { diff --git a/tests/drivers/build_all/led/app.overlay b/tests/drivers/build_all/led/app.overlay index e25825064a8a..6a48cc3d9054 100644 --- a/tests/drivers/build_all/led/app.overlay +++ b/tests/drivers/build_all/led/app.overlay @@ -168,6 +168,30 @@ x-powers,mode = "by-reg"; }; }; + + pmic@13 { + compatible = "nordic,npm1300"; + reg = <0x13>; + + leds { + compatible = "nordic,npm1300-led"; + nordic,led0-mode = "error"; + nordic,led1-mode = "charging"; + nordic,led2-mode = "host"; + }; + }; + + pmic@14 { + compatible = "nordic,npm1304"; + reg = <0x14>; + + leds { + compatible = "nordic,npm1304-led"; + nordic,led0-mode = "error"; + nordic,led1-mode = "charging"; + nordic,led2-mode = "host"; + }; + }; }; }; }; diff --git a/tests/drivers/build_all/regulator/i2c.dtsi b/tests/drivers/build_all/regulator/i2c.dtsi index ea81c2c3886f..4c8cb31958a5 100644 --- a/tests/drivers/build_all/regulator/i2c.dtsi +++ b/tests/drivers/build_all/regulator/i2c.dtsi @@ -143,3 +143,17 @@ npm2100@8 { LDOSW {}; }; }; + +npm1304@9 { + compatible = "nordic,npm1304"; + reg = <0x9>; + + regulators { + compatible = "nordic,npm1304-regulator"; + + BUCK1 {}; + BUCK2 {}; + LDO1 {}; + LDO2 {}; + }; +}; diff --git a/tests/drivers/build_all/regulator/testcase.yaml b/tests/drivers/build_all/regulator/testcase.yaml index 30d494aca231..b662f0ac2050 100644 --- a/tests/drivers/build_all/regulator/testcase.yaml +++ b/tests/drivers/build_all/regulator/testcase.yaml @@ -3,9 +3,7 @@ tests: drivers.regulator.build: - tags: - - drivers - - regulator + tags: drivers regulator build_only: true platform_allow: - native_sim diff --git a/tests/drivers/build_all/sensor/i2c.dtsi b/tests/drivers/build_all/sensor/i2c.dtsi index 6ebced542043..64edbec396a2 100644 --- a/tests/drivers/build_all/sensor/i2c.dtsi +++ b/tests/drivers/build_all/sensor/i2c.dtsi @@ -1331,3 +1331,32 @@ test_i2c_bh1730: bh1730@b4 { compatible = "rohm,bh1730"; reg = <0xb4>; }; + +test_i2c_npm1300: npm1300@b5 { + compatible = "nordic,npm1300"; + reg = <0xb5>; + + charger { + compatible = "nordic,npm1300-charger"; + vbus-limit-microamp = <1000000>; + thermistor-ohms = <10000>; + thermistor-beta = <3380>; + term-microvolt = <4150000>; + current-microamp = <150000>; + dischg-limit-microamp = <1000000>; + }; +}; + +test_i2c_npm1304: npm1304@b6 { + compatible = "nordic,npm1304"; + reg = <0xb6>; + + charger { + compatible = "nordic,npm1304-charger"; + vbus-limit-microamp = <1000000>; + thermistor-ohms = <10000>; + thermistor-beta = <3380>; + term-microvolt = <4150000>; + current-microamp = <10000>; + }; +}; diff --git a/tests/drivers/build_all/watchdog/i2c_devices.overlay b/tests/drivers/build_all/watchdog/i2c_devices.overlay index fcecf91a1228..0c709d30b06c 100644 --- a/tests/drivers/build_all/watchdog/i2c_devices.overlay +++ b/tests/drivers/build_all/watchdog/i2c_devices.overlay @@ -41,6 +41,24 @@ compatible = "nordic,npm2100-wdt"; }; }; + + npm1300_pmic: pmic@2 { + compatible = "nordic,npm1300"; + reg = <0x2>; + + npm1300_wdt: watchdog { + compatible = "nordic,npm1300-wdt"; + }; + }; + + npm1304_pmic: pmic@3 { + compatible = "nordic,npm1304"; + reg = <0x3>; + + npm1304_wdt: watchdog { + compatible = "nordic,npm1304-wdt"; + }; + }; }; }; }; diff --git a/tests/drivers/clock_control/clock_control_api/boards/nrf54l09pdk_nrf54l09_cpuapp.conf b/tests/drivers/clock_control/clock_control_api/boards/nrf54l09pdk_nrf54l09_cpuapp.conf index 11d42321cbc3..377287fb194c 100644 --- a/tests/drivers/clock_control/clock_control_api/boards/nrf54l09pdk_nrf54l09_cpuapp.conf +++ b/tests/drivers/clock_control/clock_control_api/boards/nrf54l09pdk_nrf54l09_cpuapp.conf @@ -1 +1 @@ -CONFIG_TEST_NRF_HF_STARTUP_TIME_US=1000 +CONFIG_TEST_NRF_HF_STARTUP_TIME_US=2000 diff --git a/tests/drivers/clock_control/clock_control_api/boards/nrf54l20pdk_nrf54l20_cpuapp.conf b/tests/drivers/clock_control/clock_control_api/boards/nrf54l20pdk_nrf54l20_cpuapp.conf index 11d42321cbc3..377287fb194c 100644 --- a/tests/drivers/clock_control/clock_control_api/boards/nrf54l20pdk_nrf54l20_cpuapp.conf +++ b/tests/drivers/clock_control/clock_control_api/boards/nrf54l20pdk_nrf54l20_cpuapp.conf @@ -1 +1 @@ -CONFIG_TEST_NRF_HF_STARTUP_TIME_US=1000 +CONFIG_TEST_NRF_HF_STARTUP_TIME_US=2000 diff --git a/tests/drivers/clock_control/clock_control_api/testcase.yaml b/tests/drivers/clock_control/clock_control_api/testcase.yaml index 847e4d41ddf7..d624b61fe7c3 100644 --- a/tests/drivers/clock_control/clock_control_api/testcase.yaml +++ b/tests/drivers/clock_control/clock_control_api/testcase.yaml @@ -38,4 +38,4 @@ tests: - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 - extra_args: CONF_FILE="nrf_lfclk_rc.conf" + extra_args: EXTRA_CONF_FILE="nrf_lfclk_rc.conf" diff --git a/tests/drivers/clock_control/nrf_clock_control/src/main.c b/tests/drivers/clock_control/nrf_clock_control/src/main.c index 87778bbaae59..8db19d382003 100644 --- a/tests/drivers/clock_control/nrf_clock_control/src/main.c +++ b/tests/drivers/clock_control/nrf_clock_control/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include struct test_clk_context { const struct device *clk_dev; @@ -16,6 +17,7 @@ struct test_clk_context { size_t clk_specs_size; }; +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL) const struct nrf_clock_spec test_clk_specs_hsfll[] = { { .frequency = MHZ(128), @@ -33,6 +35,7 @@ const struct nrf_clock_spec test_clk_specs_hsfll[] = { .precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT, }, }; +#endif #if CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP const struct nrf_clock_spec test_clk_specs_fll16m[] = { @@ -99,6 +102,7 @@ static const struct test_clk_context cpurad_hsfll_test_clk_contexts[] = { }; #endif +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL) const struct nrf_clock_spec test_clk_specs_global_hsfll[] = { { .frequency = MHZ(320), @@ -121,7 +125,9 @@ static const struct test_clk_context global_hsfll_test_clk_contexts[] = { .clk_specs_size = ARRAY_SIZE(test_clk_specs_global_hsfll), }, }; +#endif +#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK) const struct nrf_clock_spec test_clk_specs_lfclk[] = { { .frequency = 32768, @@ -147,6 +153,44 @@ static const struct test_clk_context lfclk_test_clk_contexts[] = { .clk_specs_size = ARRAY_SIZE(test_clk_specs_lfclk), }, }; +#endif + +#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL) + +#define AUXPLL_COMPAT nordic_nrf_auxpll +#define AUXPLL_NODE DT_INST(0, AUXPLL_COMPAT) +#define AUXPLL_FREQ DT_PROP(AUXPLL_NODE, nordic_frequency) + +/* Gets selected AUXPLL DIV and selects the expected frequency */ +#if AUXPLL_FREQ == NRF_AUXPLL_FREQUENCY_DIV_MIN +#define AUXPLL_FREQ_OUT 80000000 +#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_AUDIO_44K1 +#define AUXPLL_FREQ_OUT 11289591 +#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_USB_24M +#define AUXPLL_FREQ_OUT 24000000 +#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_AUDIO_48K +#define AUXPLL_FREQ_OUT 12287963 +#else +/*No use case for NRF_AUXPLL_FREQ_DIV_MAX or others yet*/ +#error "Unsupported AUXPLL frequency selection" +#endif + +const struct nrf_clock_spec test_clk_specs_auxpll[] = { + { + .frequency = AUXPLL_FREQ_OUT, + .accuracy = 0, + .precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT, + }, +}; + +static const struct test_clk_context auxpll_test_clk_contexts[] = { + { + .clk_dev = DEVICE_DT_GET(AUXPLL_NODE), + .clk_specs = test_clk_specs_auxpll, + .clk_specs_size = ARRAY_SIZE(test_clk_specs_auxpll), + }, +}; +#endif static void test_request_release_clock_spec(const struct device *clk_dev, const struct nrf_clock_spec *clk_spec) @@ -266,18 +310,23 @@ ZTEST(nrf2_clock_control, test_cpurad_hsfll_control) } #endif -ZTEST(nrf2_clock_control, test_lfclk_control) -{ - TC_PRINT("LFCLK test\n"); - test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts)); -} + +#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL) ZTEST(nrf2_clock_control, test_global_hsfll_control) { TC_PRINT("Global HSFLL test\n"); test_clock_control_request(global_hsfll_test_clk_contexts, ARRAY_SIZE(global_hsfll_test_clk_contexts)); } +#endif + +#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK) +ZTEST(nrf2_clock_control, test_lfclk_control) +{ + TC_PRINT("LFCLK test\n"); + test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts)); +} ZTEST(nrf2_clock_control, test_safe_request_cancellation) { @@ -303,6 +352,16 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation) TC_PRINT("Clock control safe cancellation return value: %d\n", ret); zassert_between_inclusive(ret, ONOFF_STATE_ON, ONOFF_STATE_TO_ON); } +#endif + +#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL) +ZTEST(nrf2_clock_control, test_auxpll_control) +{ + TC_PRINT("AUXPLL control test\n"); + test_clock_control_request(auxpll_test_clk_contexts, + ARRAY_SIZE(auxpll_test_clk_contexts)); +} +#endif static void *setup(void) { diff --git a/tests/drivers/flash/negative_tests/sysbuild.conf b/tests/drivers/flash/negative_tests/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/drivers/flash/negative_tests/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/drivers/i2c/i2c_target_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/i2c/i2c_target_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 2fc033d534a6..9390af2b5cd1 100644 --- a/tests/drivers/i2c/i2c_target_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/drivers/i2c/i2c_target_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -9,6 +9,23 @@ * SCL = P1.2 and P1.3 */ +/ { + zephyr,user { + sda0-gpios = <&gpio2 8 0>; + scl0-gpios = <&gpio1 2 0>; + sda1-gpios = <&gpio2 9 0>; + scl1-gpios = <&gpio1 3 0>; + }; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + &pinctrl { i2c130_default: i2c130_default { group1 { diff --git a/tests/drivers/i2c/i2c_target_api/src/main.c b/tests/drivers/i2c/i2c_target_api/src/main.c index 5c1540e3e79a..b249daae90bd 100644 --- a/tests/drivers/i2c/i2c_target_api/src/main.c +++ b/tests/drivers/i2c/i2c_target_api/src/main.c @@ -16,6 +16,7 @@ #include #include +#include #include @@ -166,6 +167,62 @@ static int run_program_read(const struct device *i2c, uint8_t addr, return 0; } +ZTEST(i2c_eeprom_target, test_deinit) +{ + const struct device *const i2c_0 = DEVICE_DT_GET(DT_BUS(NODE_EP0)); + const struct device *const i2c_1 = DEVICE_DT_GET(DT_BUS(NODE_EP1)); + const struct gpio_dt_spec sda_pin_0 = + GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), sda0_gpios, {}); + const struct gpio_dt_spec scl_pin_0 = + GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), scl0_gpios, {}); + const struct gpio_dt_spec sda_pin_1 = + GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), sda1_gpios, {}); + const struct gpio_dt_spec scl_pin_1 = + GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), scl1_gpios, {}); + int ret; + + if (i2c_0 == i2c_1) { + TC_PRINT(" gpio loopback required for test\n"); + ztest_test_skip(); + } + + if (scl_pin_0.port == NULL || sda_pin_0.port == NULL || + scl_pin_1.port == NULL || sda_pin_1.port == NULL) { + TC_PRINT(" bus gpios not specified in zephyr,path\n"); + ztest_test_skip(); + } + + ret = device_deinit(i2c_0); + if (ret == -ENOTSUP) { + TC_PRINT(" device deinit not supported\n"); + ztest_test_skip(); + } + + zassert_ok(ret); + + ret = device_deinit(i2c_1); + if (ret == -ENOTSUP) { + TC_PRINT(" device deinit not supported\n"); + zassert_ok(device_init(i2c_0)); + ztest_test_skip(); + } + + zassert_ok(gpio_pin_configure_dt(&sda_pin_0, GPIO_INPUT)); + zassert_ok(gpio_pin_configure_dt(&sda_pin_1, GPIO_OUTPUT_INACTIVE)); + zassert_ok(gpio_pin_configure_dt(&scl_pin_0, GPIO_INPUT)); + zassert_ok(gpio_pin_configure_dt(&scl_pin_1, GPIO_OUTPUT_INACTIVE)); + zassert_equal(gpio_pin_get_dt(&sda_pin_0), 0); + zassert_equal(gpio_pin_get_dt(&scl_pin_0), 0); + zassert_ok(gpio_pin_set_dt(&sda_pin_1, 1)); + zassert_ok(gpio_pin_set_dt(&scl_pin_1, 1)); + zassert_equal(gpio_pin_get_dt(&sda_pin_0), 1); + zassert_equal(gpio_pin_get_dt(&scl_pin_0), 1); + zassert_ok(gpio_pin_configure_dt(&sda_pin_1, GPIO_INPUT)); + zassert_ok(gpio_pin_configure_dt(&scl_pin_1, GPIO_INPUT)); + zassert_ok(device_init(i2c_0)); + zassert_ok(device_init(i2c_1)); +} + ZTEST(i2c_eeprom_target, test_eeprom_target) { const struct device *const eeprom_0 = DEVICE_DT_GET(NODE_EP0); diff --git a/tests/drivers/i2s/i2s_additional/CMakeLists.txt b/tests/drivers/i2s/i2s_additional/CMakeLists.txt new file mode 100644 index 000000000000..490a0ddb7d68 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(i2s_additional) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/i2s/i2s_additional/Kconfig b/tests/drivers/i2s/i2s_additional/Kconfig new file mode 100644 index 000000000000..3c80dba48532 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/Kconfig @@ -0,0 +1,168 @@ +# +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +mainmenu "I2S Additional Test" + +source "Kconfig.zephyr" + +config I2S_TEST_USE_GPIO_LOOPBACK + bool "Use GPIO loopback" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + Use wiring between the data-out and data-in pins for looping back + data. This option is intended to be used for devices that do not + provide the internal loopback functionality. + +config I2S_TEST_ALLOWED_DATA_OFFSET + int "Allowed offset in received data" + default 2 if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + default 0 + help + Maximum allowed offset between sent and received samples. Non-zero + value of this option may be needed when GPIO loopback is used. + +config I2S_TEST_WORD_SIZE_8_BIT_UNSUPPORTED + bool "8 bit word size is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_WORD_SIZE_16_BIT_UNSUPPORTED + bool "16 bit word size is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_WORD_SIZE_24_BIT_UNSUPPORTED + bool "24 bit word size is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED + bool "32 bit word size is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_WORD_SIZE_48_BIT_UNSUPPORTED + bool "48 bit word size is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_ONE_CHANNEL_UNSUPPORTED + bool "Single audio channel is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_FOUR_CHANNELS_UNSUPPORTED + bool "Four audio channels are not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED + bool "Eight audio channels are not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_FORMAT_I2S_UNSUPPORTED + bool "I2S_FMT_DATA_FORMAT_I2S is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_FORMAT_LEFT_JUSTIFIED_UNSUPPORTED + bool "I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_FORMAT_RIGHT_JUSTIFIED_UNSUPPORTED + bool "I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED + bool "I2S_FMT_DATA_FORMAT_PCM_LONG is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED + bool "I2S_FMT_DATA_FORMAT_PCM_SHORT is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_ORDER_MSB_UNSUPPORTED + bool "I2S_FMT_DATA_ORDER_MSB is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_DATA_ORDER_LSB_UNSUPPORTED + bool "I2S_FMT_DATA_ORDER_LSB is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_BIT_CLK_INV_UNSUPPORTED + bool "I2S_FMT_BIT_CLK_INV is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_FRAME_CLK_INV_UNSUPPORTED + bool "I2S_FMT_FRAME_CLK_INV is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_BLOCK_SIZE_6_UNSUPPORTED + bool "Block_size of 6 is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_OPTIONS_BIT_CLK_CONT_UNSUPPORTED + bool "I2S_OPT_BIT_CLK_CONT is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_OPTIONS_BIT_CLK_GATED_UNSUPPORTED + bool "I2S_OPT_BIT_CLK_GATED is not supported by the driver" + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_OPTIONS_LOOPBACK_UNSUPPORTED + bool "I2S_OPT_LOOPBACK is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. + +config I2S_TEST_OPTIONS_PINGPONG_UNSUPPORTED + bool "I2S_OPT_PINGPONG is not supported by the driver" + default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED + help + When set to 'y', test will check that i2s_configure() returns -EINVAL. + When set to 'n', test will do the transmission. diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.conf b/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.conf new file mode 100644 index 000000000000..8ed6ee234db2 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.conf @@ -0,0 +1 @@ +CONFIG_I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED=y diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.overlay b/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000..ca21135bca4f --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + aliases { + i2s-node0 = &i2s0; + }; +}; + +&pinctrl { + i2s0_default_alt: i2s0_default_alt { + group1 { + psels = , + , + , + ; + }; + }; +}; + +&i2s0 { + status = "okay"; + pinctrl-0 = <&i2s0_default_alt>; + pinctrl-names = "default"; +}; diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 000000000000..a4c595b1bcdb --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + aliases { + i2s-node0 = &i2s0; + }; +}; + +&pinctrl { + i2s0_default_alt: i2s0_default_alt { + group1 { + psels = , + , + , + ; + }; + }; +}; + +&uart1 { + status = "disabled"; +}; + +&i2s0 { + status = "okay"; + pinctrl-0 = <&i2s0_default_alt>; + pinctrl-names = "default"; +}; diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp_aclk.overlay b/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp_aclk.overlay new file mode 100644 index 000000000000..e262ca8d8a87 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf5340dk_nrf5340_cpuapp_aclk.overlay @@ -0,0 +1,9 @@ +/* Drive i2s peripheral from ACLK. */ + +&clock { + hfclkaudio-frequency = <11289600>; +}; + +&i2s0 { + clock-source = "ACLK"; +}; diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/i2s/i2s_additional/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..7734b5cf284f --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* i2s-node0 is the transmitter/receiver */ + +/ { + aliases { + i2s-node0 = &tdm130; + }; +}; + +&pinctrl { + tdm130_default_alt: tdm130_default_alt { + group1 { + psels = , + , + , + ; + }; + }; +}; + +&tdm130 { + status = "okay"; + pinctrl-0 = <&tdm130_default_alt>; + pinctrl-names = "default"; + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/drivers/i2s/i2s_additional/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/drivers/i2s/i2s_additional/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..c8ede4b8c2b1 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* i2s-node0 is the transmitter/receiver */ + +/ { + aliases { + i2s-node0 = &i2s20; + }; +}; + +&pinctrl { + i2s20_default_alt: i2s20_default_alt { + group1 { + psels = , + , + , + ; + }; + }; +}; + +&i2s20 { + status = "okay"; + pinctrl-0 = <&i2s20_default_alt>; + pinctrl-names = "default"; +}; diff --git a/tests/drivers/i2s/i2s_additional/prj.conf b/tests/drivers/i2s/i2s_additional/prj.conf new file mode 100644 index 000000000000..99ff252406a1 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/prj.conf @@ -0,0 +1,2 @@ +CONFIG_I2S=y +CONFIG_ZTEST=y diff --git a/tests/drivers/i2s/i2s_additional/src/main.c b/tests/drivers/i2s/i2s_additional/src/main.c new file mode 100644 index 000000000000..e8852850cee5 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/src/main.c @@ -0,0 +1,850 @@ +/* + * Copyright (c) 2017 comsuisse AG + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(i2s_add, LOG_LEVEL_INF); + +#define I2S_DEV_NODE DT_ALIAS(i2s_node0) + +#define WORD_SIZE 16U +#define NUMBER_OF_CHANNELS 2 +#define FRAME_CLK_FREQ 44100 + +#define NUM_BLOCKS 20 +#define TIMEOUT 1000 + +#define SAMPLES_COUNT 64 + +/* The data_l represent a sine wave */ +static int16_t data_l[SAMPLES_COUNT] = { + 3211, 6392, 9511, 12539, 15446, 18204, 20787, 23169, + 25329, 27244, 28897, 30272, 31356, 32137, 32609, 32767, + 32609, 32137, 31356, 30272, 28897, 27244, 25329, 23169, + 20787, 18204, 15446, 12539, 9511, 6392, 3211, 0, + -3212, -6393, -9512, -12540, -15447, -18205, -20788, -23170, + -25330, -27245, -28898, -30273, -31357, -32138, -32610, -32767, + -32610, -32138, -31357, -30273, -28898, -27245, -25330, -23170, + -20788, -18205, -15447, -12540, -9512, -6393, -3212, -1, +}; + +/* The data_r represent a sine wave shifted by 90 deg to data_l sine wave */ +static int16_t data_r[SAMPLES_COUNT] = { + 32609, 32137, 31356, 30272, 28897, 27244, 25329, 23169, + 20787, 18204, 15446, 12539, 9511, 6392, 3211, 0, + -3212, -6393, -9512, -12540, -15447, -18205, -20788, -23170, + -25330, -27245, -28898, -30273, -31357, -32138, -32610, -32767, + -32610, -32138, -31357, -30273, -28898, -27245, -25330, -23170, + -20788, -18205, -15447, -12540, -9512, -6393, -3212, -1, + 3211, 6392, 9511, 12539, 15446, 18204, 20787, 23169, + 25329, 27244, 28897, 30272, 31356, 32137, 32609, 32767, +}; + +#define BLOCK_SIZE (2 * sizeof(data_l)) + +#ifdef CONFIG_NOCACHE_MEMORY + #define MEM_SLAB_CACHE_ATTR __nocache +#else + #define MEM_SLAB_CACHE_ATTR +#endif /* CONFIG_NOCACHE_MEMORY */ + +/* + * NUM_BLOCKS is the number of blocks used by the test. Some of the drivers, + * permanently keep ownership of a few RX buffers. Add a two more + * RX blocks to satisfy this requirement + */ +static char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32)) + _k_mem_slab_buf_rx_0_mem_slab[(NUM_BLOCKS + 2) * WB_UP(BLOCK_SIZE)]; +STRUCT_SECTION_ITERABLE(k_mem_slab, rx_0_mem_slab) = + Z_MEM_SLAB_INITIALIZER(rx_0_mem_slab, _k_mem_slab_buf_rx_0_mem_slab, + WB_UP(BLOCK_SIZE), NUM_BLOCKS + 2); + +static char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32)) + _k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)]; +STRUCT_SECTION_ITERABLE(k_mem_slab, tx_0_mem_slab) = + Z_MEM_SLAB_INITIALIZER(tx_0_mem_slab, _k_mem_slab_buf_tx_0_mem_slab, + WB_UP(BLOCK_SIZE), NUM_BLOCKS); + +static const struct device *dev_i2s; + +static const struct i2s_config default_i2s_cfg = { + .word_size = WORD_SIZE, + .channels = NUMBER_OF_CHANNELS, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = FRAME_CLK_FREQ, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, +#if defined(CONFIG_I2S_TEST_USE_GPIO_LOOPBACK) + .options = I2S_OPT_FRAME_CLK_MASTER | I2S_OPT_BIT_CLK_MASTER, +#else + .options = I2S_OPT_FRAME_CLK_MASTER | I2S_OPT_BIT_CLK_MASTER | I2S_OPT_LOOPBACK, +#endif + .mem_slab = &tx_0_mem_slab, +}; + +#if (CONFIG_I2S_TEST_ALLOWED_DATA_OFFSET > 0) +/* Data offset may differ when test uses I2S with different configuration. */ +static int offset; +static int16_t word_size_bytes; +static int16_t sample_in_bytes; +#endif + +/* Fill in TX buffer with test samples. */ +static void fill_buf(int16_t *tx_block, uint8_t word_size) +{ + + /* Technically, this is correct for word_size of 16 bits only + * (incorrect for word_size of 8, 24 and 32 bit). + * However, tests checks if received bytes are identical to + * the transmitted ones. Meaning of transmitted data is irrelevant. + */ + if (word_size == 24) { + int8_t *tx_block_8bit = (int8_t *) tx_block; + int8_t *data_l_8bit = (int8_t *) &data_l; + int8_t *data_r_8bit = (int8_t *) &data_r; + int16_t tx_cnt = 0; + int16_t l_cnt = 0; + int16_t r_cnt = 0; + + while (tx_cnt < BLOCK_SIZE) { + tx_block_8bit[tx_cnt++] = data_l_8bit[l_cnt++]; + tx_block_8bit[tx_cnt++] = data_l_8bit[l_cnt++]; + tx_block_8bit[tx_cnt++] = data_l_8bit[l_cnt++]; + tx_block_8bit[tx_cnt++] = 0; + tx_block_8bit[tx_cnt++] = data_r_8bit[r_cnt++]; + tx_block_8bit[tx_cnt++] = data_r_8bit[r_cnt++]; + tx_block_8bit[tx_cnt++] = data_r_8bit[r_cnt++]; + tx_block_8bit[tx_cnt++] = 0; + } + } else { + for (int i = 0; i < SAMPLES_COUNT; i++) { + tx_block[2 * i] = data_l[i]; + tx_block[2 * i + 1] = data_r[i]; + } + } +} + +static int verify_buf(int16_t *rx_block, uint8_t word_size, uint8_t channels) +{ + int sample_no = SAMPLES_COUNT; + bool same = true; + +/* Find offset. + * This doesn't handle correctly situation when + * word_size is 8 bit and offset is odd. + */ +#if (CONFIG_I2S_TEST_ALLOWED_DATA_OFFSET > 0) + /* Offset -1 means that offset has to be detected. */ + if (offset < 0) { + LOG_HEXDUMP_DBG(rx_block, BLOCK_SIZE, "Received"); + + /* When word_size is: + * 8 bit, it occupies 8/8 = 1 byte, + * 16 bit, it occupies 16/8 = 2 bytes, + * 24 bit, it occupies 4 bytes, + * 32 bit, it occupies 32/8 = 4 bytes, + * in TX/RX buffers. + */ + word_size_bytes = (word_size == 24) ? 4 : word_size / 8; + LOG_DBG("word_size_bytes = %u", word_size_bytes); + + /* Offset is in 'samples'. + * + * One 'sample' is data for all channels: + * two channels, 8 bit word -> sample is 2 bytes + * two channels, 16 bit word -> sample is 4 bytes + * two channels, 24 bit word -> sample is 8 bytes (24 bit extended to 32 bit) + * two channels, 32 bit word -> sample is 8 bytes + */ + sample_in_bytes = channels * word_size_bytes; + LOG_DBG("sample_in_bytes = %u", sample_in_bytes); + + do { + ++offset; + if (offset > CONFIG_I2S_TEST_ALLOWED_DATA_OFFSET) { + TC_PRINT("Allowed data offset (%d) exceeded\n", + CONFIG_I2S_TEST_ALLOWED_DATA_OFFSET); + return -TC_FAIL; + } + } while (rx_block[offset * sample_in_bytes / 2] != data_l[0]); + TC_PRINT("Using data offset: %d (%u bytes)\n", offset, + offset * sample_in_bytes); + } + + /* Divided by 2 because rx_block is uint16 */ + rx_block += (offset * sample_in_bytes / 2); + sample_no -= (offset * word_size_bytes / 2); + LOG_DBG("sample_no = %u", sample_no); +#endif + + /* Compare received data with sent values. */ + if (word_size == 24) { + int8_t *rx_block_8bit = (int8_t *) rx_block; + int8_t *data_l_8bit = (int8_t *) &data_l; + int8_t *data_r_8bit = (int8_t *) &data_r; + int16_t rx_cnt = 0; + int16_t temp = 0; + int8_t expected = 0; + + while (rx_cnt < (BLOCK_SIZE - offset * sample_in_bytes)) { +/* Map byte number from RX array to channel array + * + * rx_cnt | l_index | r_index || rx_cnt/8 | rx_cnt%4 | (rx_cnt/8)*3+(rx_cnt%4) + * 0 | 0 | || 0 | 0 | 0*3+0 = 0 data_l + * 1 | 1 | || 0 | 1 | 0*3+1 = 1 data_l + * 2 | 2 | || 0 | 2 | 0*3+2 = 2 data_l + * 3 | - | || 0 | 3 | 0*3+3 = 3 ignore + * 4 | | 0 || 0 | 0 | 0*3+0 = 0 data_r + * 5 | | 1 || 0 | 1 | 0*3+1 = 1 data_r + * 6 | | 2 || 0 | 2 | 0*3+2 = 2 data_r + * 7 | | - || 0 | 3 | 0*3+3 = 3 ignore + * + * 8 | 3 | || 1 | 0 | 1*3+0 = 3 data_l + * 9 | 4 | || 1 | 1 | 1*3+1 = 4 data_l + * 10 | 5 | || 1 | 2 | 1*3+2 = 5 data_l + * 11 | - | || 1 | 3 | 1*3+3 = 6 ignore + * 12 | | 3 || 1 | 0 | 1*3+0 = 3 data_r + * 13 | | 4 || 1 | 1 | 1*3+1 = 4 data_r + * 14 | | 5 || 1 | 2 | 1*3+2 = 5 data_r + * 15 | | - || 1 | 3 | 1*3+3 = 6 ignore + * + * 16 | 6 | || 2 | 0 | 2*3+0 = 6 data_l + * ... + */ + temp = ((rx_cnt / 8) * 3) + (rx_cnt % 4); + + if ((rx_cnt % 8) < 4) { + /* Compare with left channel. */ + expected = data_l_8bit[temp]; + } else { + /* Compare with right channel. */ + expected = data_r_8bit[temp]; + } + + if ((rx_cnt % 4) == 3) { + /* Ignore every fourth byte */ + } else { + /* Compare received data with expected value. */ + if (rx_block_8bit[rx_cnt] != expected) { + TC_PRINT("Index %d, expected 0x%x, actual 0x%x\n", + rx_cnt, expected, rx_block_8bit[rx_cnt]); + same = false; + } + } + /* Move to next received byte. */ + rx_cnt++; + } + + } else { + for (int i = 0; i < sample_no; i++) { + if (rx_block[2 * i] != data_l[i]) { + TC_PRINT("data_l, index %d, expected 0x%x, actual 0x%x\n", + i, data_l[i], rx_block[2 * i]); + same = false; + } + if (rx_block[2 * i + 1] != data_r[i]) { + TC_PRINT("data_r, index %d, expected 0x%x, actual 0x%x\n", + i, data_r[i], rx_block[2 * i + 1]); + same = false; + } + } + } + + if (!same) { + return -TC_FAIL; + } else { + return TC_PASS; + } +} + +static int configure_stream(const struct device *dev, enum i2s_dir dir, + struct i2s_config *i2s_cfg) +{ + int ret; + + if (dir == I2S_DIR_TX) { + /* Configure the Transmit port as Master */ + i2s_cfg->options = I2S_OPT_FRAME_CLK_MASTER + | I2S_OPT_BIT_CLK_MASTER; + } else if (dir == I2S_DIR_RX) { + /* Configure the Receive port as Slave */ + i2s_cfg->options = I2S_OPT_FRAME_CLK_SLAVE + | I2S_OPT_BIT_CLK_SLAVE; + } else { /* dir == I2S_DIR_BOTH */ + i2s_cfg->options = I2S_OPT_FRAME_CLK_MASTER + | I2S_OPT_BIT_CLK_MASTER; + } + + if (dir == I2S_DIR_TX || dir == I2S_DIR_BOTH) { + i2s_cfg->mem_slab = &tx_0_mem_slab; + ret = i2s_configure(dev, I2S_DIR_TX, i2s_cfg); + if (ret < 0) { + TC_PRINT("Failed to configure I2S TX stream (%d)\n", + ret); + return -TC_FAIL; + } + } + + if (dir == I2S_DIR_RX || dir == I2S_DIR_BOTH) { + i2s_cfg->mem_slab = &rx_0_mem_slab; + ret = i2s_configure(dev, I2S_DIR_RX, i2s_cfg); + if (ret < 0) { + TC_PRINT("Failed to configure I2S RX stream (%d)\n", + ret); + return -TC_FAIL; + } + } + + return TC_PASS; +} + +static void i2s_dir_both_transfer_long(struct i2s_config *i2s_cfg) +{ + void *rx_block[NUM_BLOCKS]; + void *tx_block[NUM_BLOCKS]; + size_t rx_size; + int tx_idx; + int rx_idx = 0; + int num_verified; + int ret; + + /* Configure I2S Dir Both transfer. */ + ret = configure_stream(dev_i2s, I2S_DIR_BOTH, i2s_cfg); + zassert_equal(ret, TC_PASS); + + /* Prepare TX data blocks */ + for (tx_idx = 0; tx_idx < NUM_BLOCKS; tx_idx++) { + ret = k_mem_slab_alloc(&tx_0_mem_slab, &tx_block[tx_idx], + K_FOREVER); + zassert_equal(ret, 0); + fill_buf((uint16_t *)tx_block[tx_idx], i2s_cfg->word_size); + } + + LOG_HEXDUMP_DBG(tx_block[0], BLOCK_SIZE, "transmitted"); + + tx_idx = 0; + + /* Prefill TX queue */ + ret = i2s_write(dev_i2s, tx_block[tx_idx++], BLOCK_SIZE); + zassert_equal(ret, 0); + + ret = i2s_write(dev_i2s, tx_block[tx_idx++], BLOCK_SIZE); + zassert_equal(ret, 0); + + ret = i2s_trigger(dev_i2s, I2S_DIR_BOTH, I2S_TRIGGER_START); + zassert_equal(ret, 0, "RX/TX START trigger failed\n"); + + while (tx_idx < NUM_BLOCKS) { + ret = i2s_write(dev_i2s, tx_block[tx_idx++], BLOCK_SIZE); + zassert_equal(ret, 0); + + ret = i2s_read(dev_i2s, &rx_block[rx_idx++], &rx_size); + zassert_equal(ret, 0, "Got unexpected %d", ret); + zassert_equal(rx_size, BLOCK_SIZE); + } + + /* All data written, drain TX queue and stop both streams. */ + ret = i2s_trigger(dev_i2s, I2S_DIR_BOTH, I2S_TRIGGER_DRAIN); + zassert_equal(ret, 0, "RX/TX DRAIN trigger failed"); + + ret = i2s_read(dev_i2s, &rx_block[rx_idx++], &rx_size); + zassert_equal(ret, 0); + zassert_equal(rx_size, BLOCK_SIZE); + + ret = i2s_read(dev_i2s, &rx_block[rx_idx++], &rx_size); + zassert_equal(ret, 0); + zassert_equal(rx_size, BLOCK_SIZE); + + TC_PRINT("%d TX blocks sent\n", tx_idx); + TC_PRINT("%d RX blocks received\n", rx_idx); + + /* Verify received data */ + num_verified = 0; + for (rx_idx = 0; rx_idx < NUM_BLOCKS; rx_idx++) { + ret = verify_buf((uint16_t *)rx_block[rx_idx], + i2s_cfg->word_size, i2s_cfg->channels); + if (ret != 0) { + TC_PRINT("%d RX block invalid\n", rx_idx); + } else { + num_verified++; + } + k_mem_slab_free(&rx_0_mem_slab, rx_block[rx_idx]); + } + zassert_equal(num_verified, NUM_BLOCKS, "Invalid RX blocks received"); +} + +/** @brief Test I2S transfer with word_size_8bit + */ +ZTEST(i2s_additional, test_01a_word_size_08bit) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.word_size = 8; + +#if defined(CONFIG_I2S_TEST_WORD_SIZE_8_BIT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with word_size_16bit + */ +ZTEST(i2s_additional, test_01b_word_size_16bit) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.word_size = 16; + +#if defined(CONFIG_I2S_TEST_WORD_SIZE_16_BIT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with word_size_24bit + */ +ZTEST(i2s_additional, test_01c_word_size_24bit) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.word_size = 24; + +#if defined(CONFIG_I2S_TEST_WORD_SIZE_24_BIT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with word_size_32bit + */ +ZTEST(i2s_additional, test_01d_word_size_32bit) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.word_size = 32; + +#if defined(CONFIG_I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with word_size_48bit + */ +ZTEST(i2s_additional, test_01e_word_size_48bit) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.word_size = 48; + +#if defined(CONFIG_I2S_TEST_WORD_SIZE_48_BIT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with one channel. + */ +ZTEST(i2s_additional, test_02a_one_channel) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.channels = 1; + +#if defined(CONFIG_I2S_TEST_ONE_CHANNEL_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with four channels. + */ +ZTEST(i2s_additional, test_02b_four_channels) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.channels = 4; + +#if defined(CONFIG_I2S_TEST_FOUR_CHANNELS_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else /* CONFIG_I2S_TEST_FOUR_CHANNELS_UNSUPPORTED */ + + /* Select format that supports four channels. */ +#if !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED) + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_LONG; + TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_LONG\n"); +#elif !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED) + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_SHORT; + TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_SHORT\n"); +#else +#error "Don't know what format supports four channels." +#endif + + i2s_dir_both_transfer_long(&i2s_cfg); +#endif /* CONFIG_I2S_TEST_FOUR_CHANNELS_UNSUPPORTED */ +} + +/** @brief Test I2S transfer with eight channels. + */ +ZTEST(i2s_additional, test_02c_eight_channels) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.channels = 8; + +#if defined(CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else /* CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED */ + + /* Select format that supports eight channels. */ +#if !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED) + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_LONG; + TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_LONG\n"); +#elif !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED) + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_SHORT; + TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_SHORT\n"); +#else +#error "Don't know what format supports eight channels." +#endif + + i2s_dir_both_transfer_long(&i2s_cfg); +#endif /* CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED */ +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_I2S + */ +ZTEST(i2s_additional, test_03a_format_i2s) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S; + +#if defined(CONFIG_I2S_TEST_DATA_FORMAT_I2S_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED + */ +ZTEST(i2s_additional, test_03b_format_left_justified) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format = I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED; + +#if defined(CONFIG_I2S_TEST_DATA_FORMAT_LEFT_JUSTIFIED_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED + */ +ZTEST(i2s_additional, test_03c_format_right_justified) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format = I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED; + +#if defined(CONFIG_I2S_TEST_DATA_FORMAT_RIGHT_JUSTIFIED_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_PCM_LONG + */ +ZTEST(i2s_additional, test_03d_format_pcm_long) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_LONG; + +#if defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_PCM_SHORT + */ +ZTEST(i2s_additional, test_03e_format_pcm_short) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_SHORT; + +#if defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_ORDER_MSB + */ +ZTEST(i2s_additional, test_04a_format_data_order_MSB) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format |= I2S_FMT_DATA_ORDER_MSB; + +#if defined(CONFIG_I2S_TEST_DATA_ORDER_MSB_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_DATA_ORDER_LSB + */ +ZTEST(i2s_additional, test_04b_format_data_order_LSB) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format |= I2S_FMT_DATA_ORDER_LSB; + +#if defined(CONFIG_I2S_TEST_DATA_ORDER_LSB_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_BIT_CLK_INV + */ +ZTEST(i2s_additional, test_05a_format_bit_clk_inv) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format |= I2S_FMT_BIT_CLK_INV; + +#if defined(CONFIG_I2S_TEST_BIT_CLK_INV_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with format I2S_FMT_FRAME_CLK_INV + */ +ZTEST(i2s_additional, test_05b_format_frame_clk_inv) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.format |= I2S_FMT_FRAME_CLK_INV; + +#if defined(CONFIG_I2S_TEST_FRAME_CLK_INV_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with block_size set to 6. + */ +ZTEST(i2s_additional, test_06_block_size_6) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.block_size = 6; + +#if defined(CONFIG_I2S_TEST_BLOCK_SIZE_6_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with I2S_OPT_BIT_CLK_CONT. + */ +ZTEST(i2s_additional, test_07a_options_bit_clk_cont) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.options |= I2S_OPT_BIT_CLK_CONT; + +#if defined(CONFIG_I2S_TEST_OPTIONS_BIT_CLK_CONT_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with I2S_OPT_BIT_CLK_GATED. + */ +ZTEST(i2s_additional, test_07b_options_bit_clk_gated) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.options |= I2S_OPT_BIT_CLK_GATED; + +#if defined(CONFIG_I2S_TEST_OPTIONS_BIT_CLK_GATED_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Check error when I2S is configured with unsupported + * combination of bit CLK and frame CLK options. + */ +ZTEST(i2s_additional, test_08_options_bit_frame_clk_mixed) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + int ret; + + i2s_cfg.options = I2S_OPT_FRAME_CLK_MASTER | I2S_OPT_BIT_CLK_SLAVE; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); + + i2s_cfg.options = I2S_OPT_FRAME_CLK_SLAVE | I2S_OPT_BIT_CLK_MASTER; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +} + +/** @brief Test I2S transfer with I2S_OPT_LOOPBACK. + */ +ZTEST(i2s_additional, test_09a_options_loopback) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.options |= I2S_OPT_LOOPBACK; + +#if defined(CONFIG_I2S_TEST_OPTIONS_LOOPBACK_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +/** @brief Test I2S transfer with I2S_OPT_PINGPONG. + */ +ZTEST(i2s_additional, test_09b_options_pingpong) +{ + struct i2s_config i2s_cfg = default_i2s_cfg; + + i2s_cfg.options |= I2S_OPT_PINGPONG; + +#if defined(CONFIG_I2S_TEST_OPTIONS_LOOPBACK_UNSUPPORTED) + int ret; + + ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg); + zassert_equal(ret, -EINVAL, "Unexpected result %d", ret); +#else + i2s_dir_both_transfer_long(&i2s_cfg); +#endif +} + +static void *suite_setup(void) +{ + /* Check I2S Device. */ + dev_i2s = DEVICE_DT_GET_OR_NULL(I2S_DEV_NODE); + zassert_not_null(dev_i2s, "I2S device not found"); + zassert(device_is_ready(dev_i2s), "I2S device not ready"); + + LOG_HEXDUMP_DBG(&data_l, 2 * SAMPLES_COUNT, "data_l"); + LOG_HEXDUMP_DBG(&data_r, 2 * SAMPLES_COUNT, "data_r"); + TC_PRINT("===================================================================\n"); + + return 0; +} + +static void before(void *not_used) +{ + ARG_UNUSED(not_used); + +#if (CONFIG_I2S_TEST_ALLOWED_DATA_OFFSET > 0) + /* Data offset may differ when test uses I2S + * with different configuration. + * Force offset callculation for every test. + */ + offset = -1; +#endif +} + +ZTEST_SUITE(i2s_additional, NULL, suite_setup, before, NULL, NULL); diff --git a/tests/drivers/i2s/i2s_additional/testcase.yaml b/tests/drivers/i2s/i2s_additional/testcase.yaml new file mode 100644 index 000000000000..c45a5482b7f4 --- /dev/null +++ b/tests/drivers/i2s/i2s_additional/testcase.yaml @@ -0,0 +1,39 @@ +common: + tags: + - drivers + - i2s + depends_on: + - i2s + - gpio + filter: CONFIG_I2S_TEST_USE_GPIO_LOOPBACK + harness: ztest + +tests: + drivers.i2s.additional.gpio_loopback: + harness_config: + fixture: gpio_loopback + platform_allow: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15dk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15dk/nrf54l15/cpuapp + + drivers.i2s.additional.gpio_loopback.54h: + harness_config: + fixture: i2s_loopback + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + + drivers.i2s.additional.gpio_loopback.aclk: + harness_config: + fixture: gpio_loopback + extra_args: EXTRA_DTC_OVERLAY_FILE="boards/nrf5340dk_nrf5340_cpuapp_aclk.overlay" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: + - nrf5340dk/nrf5340/cpuapp diff --git a/tests/drivers/i2s/i2s_api/testcase.yaml b/tests/drivers/i2s/i2s_api/testcase.yaml index 1932607d6552..5b36b91c8fe7 100644 --- a/tests/drivers/i2s/i2s_api/testcase.yaml +++ b/tests/drivers/i2s/i2s_api/testcase.yaml @@ -10,6 +10,7 @@ tests: - mcx_n9xx_evk/mcxn947/cpu0 - mimxrt595_evk/mimxrt595s/cm33 - mimxrt685_evk/mimxrt685s/cm33 + - nrf54h20dk/nrf54h20/cpuapp drivers.i2s.gpio_loopback: depends_on: - i2s @@ -24,5 +25,17 @@ tests: - mcx_n9xx_evk/mcxn947/cpu0 - mimxrt595_evk/mimxrt595s/cm33 - mimxrt685_evk/mimxrt685s/cm33 + - nrf54h20dk/nrf54h20/cpuapp harness_config: fixture: gpio_loopback + drivers.i2s.gpio_loopback.nrf54h: + depends_on: i2s + tags: + - drivers + - userspace + harness_config: + fixture: i2s_loopback + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp diff --git a/tests/drivers/i2s/i2s_speed/testcase.yaml b/tests/drivers/i2s/i2s_speed/testcase.yaml index 6bc15a413645..56065f5ef628 100644 --- a/tests/drivers/i2s/i2s_speed/testcase.yaml +++ b/tests/drivers/i2s/i2s_speed/testcase.yaml @@ -5,6 +5,8 @@ tests: - drivers - i2s filter: not CONFIG_I2S_TEST_USE_GPIO_LOOPBACK + platform_exclude: + - nrf54h20dk/nrf54h20/cpuapp drivers.i2s.speed.gpio_loopback: depends_on: - i2s @@ -13,6 +15,8 @@ tests: - drivers - i2s filter: CONFIG_I2S_TEST_USE_GPIO_LOOPBACK + platform_exclude: + - nrf54h20dk/nrf54h20/cpuapp harness: ztest harness_config: fixture: gpio_loopback @@ -29,3 +33,14 @@ tests: fixture: gpio_loopback extra_args: EXTRA_DTC_OVERLAY_FILE="boards/nrf5340dk_nrf5340_cpuapp_aclk.overlay" platform_allow: nrf5340dk/nrf5340/cpuapp + drivers.i2s.speed.gpio_loopback.nrf54h: + depends_on: i2s + tags: + - drivers + - i2s + harness_config: + fixture: i2s_loopback + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp diff --git a/tests/drivers/spi/spi_loopback/Kconfig b/tests/drivers/spi/spi_loopback/Kconfig index f3d89bf7317e..b1d81eb13aa1 100644 --- a/tests/drivers/spi/spi_loopback/Kconfig +++ b/tests/drivers/spi/spi_loopback/Kconfig @@ -11,6 +11,10 @@ config SPI_LARGE_BUFFER_SIZE int "Large buffer size" default 8192 +config SPI_IDEAL_TRANSFER_DURATION_SCALING + int "Scaling factor to compare ideal and measured SPI transfer duration" + default 8 + if SOC_SERIES_STM32H7X config SPI_LOOPBACK_16BITS_FRAMES diff --git a/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_common.dtsi b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_common.dtsi index 33170beda44e..5111257a557d 100644 --- a/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_common.dtsi +++ b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_common.dtsi @@ -4,6 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + +/ { + zephyr,user { + miso-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; + }; +}; + &pinctrl { spi130_default: spi130_default { group1 { diff --git a/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.conf new file mode 100644 index 000000000000..ad922ab8d26f --- /dev/null +++ b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -0,0 +1 @@ +CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12 diff --git a/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpurad.conf b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..ad922ab8d26f --- /dev/null +++ b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12 diff --git a/tests/drivers/spi/spi_loopback/src/spi.c b/tests/drivers/spi/spi_loopback/src/spi.c index f00a720677a3..fd2302a4ec0b 100644 --- a/tests/drivers/spi/spi_loopback/src/spi.c +++ b/tests/drivers/spi/spi_loopback/src/spi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,8 @@ static int spec_idx; */ struct spi_dt_spec spec_copies[5]; - +const struct gpio_dt_spec miso_pin = GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), miso_gpios, {}); +const struct gpio_dt_spec mosi_pin = GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), mosi_gpios, {}); /* ******************** @@ -327,7 +329,7 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed) /* Fail if transfer is faster than theoretically possible */ zassert_true(time_spent_us >= minimum_transfer_time_us, - "Transfer faster than theoretically possible"); + "Transfer faster than theoretically possible"); /* handle overflow for print statement */ latency_measurement = time_spent_us - expected_transfer_time_us; @@ -337,7 +339,9 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed) TC_PRINT("Latency measurement: %llu us\n", latency_measurement); /* Allow some overhead, but not too much */ - zassert_true(time_spent_us <= expected_transfer_time_us * 8, "Very high latency"); + zassert_true(time_spent_us <= + expected_transfer_time_us * CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING, + "Very high latency"); spi_loopback_compare_bufs(buffer_tx, buffer_rx, BUF_SIZE, buffer_print_tx, buffer_print_rx); @@ -691,7 +695,8 @@ ZTEST(spi_loopback, test_spi_word_size_32) sizeof(buffer_tx_32), &spec_copies[4], 32); } -static K_THREAD_STACK_DEFINE(thread_stack[3], 512); +static K_THREAD_STACK_DEFINE(thread_stack[3], CONFIG_ZTEST_STACK_SIZE + + CONFIG_TEST_EXTRA_STACK_SIZE); static struct k_thread thread[3]; static K_SEM_DEFINE(thread_sem, 0, 3); @@ -804,6 +809,35 @@ ZTEST(spi_loopback, test_spi_concurrent_transfer_different_spec) test_spi_concurrent_transfer_helper(specs); } +ZTEST(spi_loopback, test_spi_deinit) +{ + struct spi_dt_spec *spec = loopback_specs[0]; + const struct device *dev = spec->bus; + int ret; + + if (miso_pin.port == NULL || mosi_pin.port == NULL) { + TC_PRINT(" zephyr,user miso-gpios or mosi-gpios are not defined\n"); + ztest_test_skip(); + } + + ret = device_deinit(dev); + if (ret == -ENOTSUP) { + TC_PRINT(" device deinit not supported\n"); + ztest_test_skip(); + } + + zassert_ok(ret); + zassert_ok(gpio_pin_configure_dt(&miso_pin, GPIO_INPUT)); + zassert_ok(gpio_pin_configure_dt(&mosi_pin, GPIO_OUTPUT_INACTIVE)); + zassert_equal(gpio_pin_get_dt(&miso_pin), 0); + zassert_ok(gpio_pin_set_dt(&mosi_pin, 1)); + zassert_equal(gpio_pin_get_dt(&miso_pin), 1); + zassert_ok(gpio_pin_set_dt(&mosi_pin, 0)); + zassert_equal(gpio_pin_get_dt(&miso_pin), 0); + zassert_ok(gpio_pin_configure_dt(&mosi_pin, GPIO_INPUT)); + zassert_ok(device_init(dev)); +} + #if (CONFIG_SPI_ASYNC) static struct k_poll_signal async_sig = K_POLL_SIGNAL_INITIALIZER(async_sig); static struct k_poll_event async_evt = diff --git a/tests/drivers/timer/nrf_grtc_timer/src/main.c b/tests/drivers/timer/nrf_grtc_timer/src/main.c index f53188841bdb..cede54f026f1 100644 --- a/tests/drivers/timer/nrf_grtc_timer/src/main.c +++ b/tests/drivers/timer/nrf_grtc_timer/src/main.c @@ -28,6 +28,7 @@ ZTEST(nrf_grtc_timer, test_get_ticks) { k_timeout_t t = K_MSEC(1); + uint64_t grtc_start_value = z_nrf_grtc_timer_startup_value_get(); uint64_t exp_ticks = z_nrf_grtc_timer_read() + t.ticks * CYC_PER_TICK; int64_t ticks; @@ -51,6 +52,7 @@ ZTEST(nrf_grtc_timer, test_get_ticks) curr_tick2 = sys_clock_tick_get(); } while (curr_tick != curr_tick2); + curr_tick += (grtc_start_value / CYC_PER_TICK); t = Z_TIMEOUT_TICKS(Z_TICK_ABS(curr_tick - K_MSEC(1).ticks)); exp_ticks = curr_grtc_tick - K_MSEC(1).ticks * CYC_PER_TICK; @@ -69,6 +71,7 @@ ZTEST(nrf_grtc_timer, test_get_ticks) curr_tick2 = sys_clock_tick_get(); } while (curr_tick != curr_tick2); + curr_tick += (grtc_start_value / CYC_PER_TICK); t = Z_TIMEOUT_TICKS(Z_TICK_ABS(curr_tick + K_MSEC(10).ticks)); exp_ticks = curr_grtc_tick + K_MSEC(10).ticks * CYC_PER_TICK; ticks = z_nrf_grtc_timer_get_ticks(t); diff --git a/tests/drivers/uart/uart_async_dual/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/drivers/uart/uart_async_dual/boards/nrf54h20dk_nrf54h20_cpuapp.conf index 74cc8d7691e1..6dffc1fe4e19 100644 --- a/tests/drivers/uart/uart_async_dual/boards/nrf54h20dk_nrf54h20_cpuapp.conf +++ b/tests/drivers/uart/uart_async_dual/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -1,2 +1,3 @@ CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y +CONFIG_CLOCK_CONTROL=y diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf deleted file mode 100644 index 45e31e2fae42..000000000000 --- a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Disable dcache -CONFIG_DCACHE=n diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay b/tests/drivers/watchdog/wdt_basic_api/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay similarity index 100% rename from tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp_iron.overlay rename to tests/drivers/watchdog/wdt_basic_api/boards/nrf9280pdk_nrf9280_cpuapp_iron.overlay diff --git a/tests/kconfig/functions/Kconfig b/tests/kconfig/functions/Kconfig index 50868eb7b6ae..1e46730c98a0 100644 --- a/tests/kconfig/functions/Kconfig +++ b/tests/kconfig/functions/Kconfig @@ -6,60 +6,60 @@ config KCONFIG_ARITHMETIC_ADD_10 default $(add, 10) config KCONFIG_ARITHMETIC_ADD_10_3 - int - default $(add, 10, 3) + hex + default $(add_hex, 10, 3) config KCONFIG_ARITHMETIC_ADD_10_3_2 int - default $(add, 10, 3, 2) + default $(add, 0xa, 3, 0b10) config KCONFIG_ARITHMETIC_SUB_10 int default $(sub, 10) config KCONFIG_ARITHMETIC_SUB_10_3 - int - default $(sub, 10, 3) + hex + default $(sub_hex, 10, 3) config KCONFIG_ARITHMETIC_SUB_10_3_2 int - default $(sub, 10, 3, 2) + default $(sub, 0xa, 3, 0b10) config KCONFIG_ARITHMETIC_MUL_10 int default $(mul, 10) config KCONFIG_ARITHMETIC_MUL_10_3 - int - default $(mul, 10, 3) + hex + default $(mul_hex, 10, 3) config KCONFIG_ARITHMETIC_MUL_10_3_2 int - default $(mul, 10, 3, 2) + default $(mul, 0xa, 3, 0b10) config KCONFIG_ARITHMETIC_DIV_10 int default $(div, 10) config KCONFIG_ARITHMETIC_DIV_10_3 - int - default $(div, 10, 3) + hex + default $(div_hex, 10, 3) config KCONFIG_ARITHMETIC_DIV_10_3_2 int - default $(div, 10, 3, 2) + default $(div, 0xa, 3, 0b10) config KCONFIG_ARITHMETIC_MOD_10 int default $(mod, 10) config KCONFIG_ARITHMETIC_MOD_10_3 - int - default $(mod, 10, 3) + hex + default $(mod_hex, 10, 3) config KCONFIG_ARITHMETIC_MOD_10_3_2 int - default $(mod, 10, 3, 2) + default $(mod, 0xa, 3, 0b10) config KCONFIG_ARITHMETIC_INC_1 int @@ -67,11 +67,11 @@ config KCONFIG_ARITHMETIC_INC_1 config KCONFIG_ARITHMETIC_INC_1_1 string - default "$(inc, 1, 1)" + default "$(inc_hex, 1, 1)" config KCONFIG_ARITHMETIC_INC_INC_1_1 string - default "$(inc, $(inc, 1, 1))" + default "$(inc, $(inc_hex, 0x1, 0b1))" config KCONFIG_ARITHMETIC_DEC_1 int @@ -79,38 +79,38 @@ config KCONFIG_ARITHMETIC_DEC_1 config KCONFIG_ARITHMETIC_DEC_1_1 string - default "$(dec, 1, 1)" + default "$(dec_hex, 1, 1)" config KCONFIG_ARITHMETIC_DEC_DEC_1_1 string - default "$(dec, $(dec, 1, 1))" + default "$(dec, $(dec_hex, 0x1, 0b1))" config KCONFIG_ARITHMETIC_ADD_INC_1_1 int - default $(add, $(inc, 1, 1)) + default $(add, $(inc_hex, 1, 1)) config KCONFIG_MIN_10 int default $(min, 10) config KCONFIG_MIN_10_3 - int - default $(min, 10, 3) + hex + default $(min_hex, 10, 3) config KCONFIG_MIN_10_3_2 int - default $(min, 10, 3, 2) + default $(min, 0xa, 3, 0b10) config KCONFIG_MAX_10 int default $(max, 10) config KCONFIG_MAX_10_3 - int - default $(max, 10, 3) + hex + default $(max_hex, 10, 3) config KCONFIG_MAX_10_3_2 int - default $(max, 10, 3, 2) + default $(max, 0xa, 3, 0b10) source "Kconfig.zephyr" diff --git a/tests/kconfig/functions/src/main.c b/tests/kconfig/functions/src/main.c index 39962c2a4f8c..7492e3b5b93a 100644 --- a/tests/kconfig/functions/src/main.c +++ b/tests/kconfig/functions/src/main.c @@ -27,10 +27,10 @@ ZTEST(test_kconfig_functions, test_arithmetic) zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MOD_10_3, 10 % 3); zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MOD_10_3_2, 10 % 3 % 2); zassert_equal(CONFIG_KCONFIG_ARITHMETIC_INC_1, 1 + 1); - zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_INC_1_1, "2,2"); + zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_INC_1_1, "0x2,0x2"); zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_INC_INC_1_1, "3,3"); zassert_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_1, 1 - 1); - zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_1_1, "0,0"); + zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_1_1, "0x0,0x0"); zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_DEC_1_1, "-1,-1"); zassert_equal(CONFIG_KCONFIG_ARITHMETIC_ADD_INC_1_1, (1 + 1) + (1 + 1)); } diff --git a/tests/kernel/gen_isr_table/src/main.c b/tests/kernel/gen_isr_table/src/main.c index d6b92731fc53..d3e3291573a7 100644 --- a/tests/kernel/gen_isr_table/src/main.c +++ b/tests/kernel/gen_isr_table/src/main.c @@ -31,6 +31,11 @@ extern uintptr_t _irq_vector_table[]; #define ISR3_OFFSET 15 #define ISR5_OFFSET 16 #define TRIG_CHECK_SIZE 17 +#elif defined(CONFIG_SOC_NRF9280_CPUPPR) +#define ISR1_OFFSET 14 +#define ISR3_OFFSET 15 +#define ISR5_OFFSET 16 +#define TRIG_CHECK_SIZE 17 #else #error "Target not supported" #endif diff --git a/tests/kernel/interrupt/src/nested_irq.c b/tests/kernel/interrupt/src/nested_irq.c index 3e6a798e6042..6bfc81b8965c 100644 --- a/tests/kernel/interrupt/src/nested_irq.c +++ b/tests/kernel/interrupt/src/nested_irq.c @@ -56,7 +56,8 @@ */ #define IRQ0_PRIO IRQ_DEFAULT_PRIORITY #define IRQ1_PRIO 0x0 -#elif defined(CONFIG_SOC_SERIES_NRF54LX) && defined(CONFIG_RISCV_CORE_NORDIC_VPR) +#elif (defined(CONFIG_SOC_SERIES_NRF54LX) || defined(CONFIG_SOC_NRF54H20_CPUFLPR)) && \ + defined(CONFIG_RISCV_CORE_NORDIC_VPR) #define IRQ0_LINE 16 #define IRQ1_LINE 17 @@ -66,6 +67,12 @@ #define IRQ0_LINE 14 #define IRQ1_LINE 15 +#define IRQ0_PRIO 1 +#define IRQ1_PRIO 2 +#elif defined(CONFIG_SOC_NRF9280_CPUPPR) +#define IRQ0_LINE 14 +#define IRQ1_LINE 15 + #define IRQ0_PRIO 1 #define IRQ1_PRIO 2 #else diff --git a/tests/kernel/pipe/deprecated/pipe/CMakeLists.txt b/tests/kernel/pipe/deprecated/pipe/CMakeLists.txt index 2624f4be400f..ac8bc4dee462 100644 --- a/tests/kernel/pipe/deprecated/pipe/CMakeLists.txt +++ b/tests/kernel/pipe/deprecated/pipe/CMakeLists.txt @@ -1,7 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_C_FLAGS "-D__deprecated=\"/* deprecated */\" -D__DEPRECATED_MACRO=\"/* deprecated_macro*/\"") find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(pipe) diff --git a/tests/kernel/pipe/deprecated/pipe_api/prj.conf b/tests/kernel/pipe/deprecated/pipe_api/prj.conf index 02d8fd3dd565..df3270adfdf8 100644 --- a/tests/kernel/pipe/deprecated/pipe_api/prj.conf +++ b/tests/kernel/pipe/deprecated/pipe_api/prj.conf @@ -6,3 +6,4 @@ CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y CONFIG_PIPES=y CONFIG_DEPRECATION_TEST=y +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/sched/schedule_api/prj.conf b/tests/kernel/sched/schedule_api/prj.conf index a5ceef694331..8b649a3b7fca 100644 --- a/tests/kernel/sched/schedule_api/prj.conf +++ b/tests/kernel/sched/schedule_api/prj.conf @@ -7,3 +7,4 @@ CONFIG_MAX_THREAD_BYTES=6 CONFIG_TEST_USERSPACE=y CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/sched/schedule_api/prj_multiq.conf b/tests/kernel/sched/schedule_api/prj_multiq.conf index c8dd4bf786bc..84c9d80ac619 100644 --- a/tests/kernel/sched/schedule_api/prj_multiq.conf +++ b/tests/kernel/sched/schedule_api/prj_multiq.conf @@ -7,3 +7,4 @@ CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y CONFIG_NUM_COOP_PRIORITIES=30 CONFIG_NUM_PREEMPT_PRIORITIES=40 +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/timer/cycle64/testcase.yaml b/tests/kernel/timer/cycle64/testcase.yaml index f1a65dbb00a0..1598c07337be 100644 --- a/tests/kernel/timer/cycle64/testcase.yaml +++ b/tests/kernel/timer/cycle64/testcase.yaml @@ -14,7 +14,7 @@ tests: tags: - kernel - timer - filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER + filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER and not CONFIG_NRF_GRTC_TIMER arch_exclude: posix timeout: 140 slow: true @@ -22,5 +22,13 @@ tests: tags: - kernel - timer - filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER + filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER and not CONFIG_NRF_GRTC_TIMER arch_allow: posix + kernel.timer.cycle64.grtc: + tags: + - kernel + - timer + filter: CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER and CONFIG_NRF_GRTC_TIMER + arch_exclude: posix + timeout: 8600 + slow: true diff --git a/tests/kernel/workq/work/src/main.c b/tests/kernel/workq/work/src/main.c index ce327cee4052..11ae39db2a84 100644 --- a/tests/kernel/workq/work/src/main.c +++ b/tests/kernel/workq/work/src/main.c @@ -8,11 +8,6 @@ * about the use of that API. */ #include -#undef __deprecated -#define __deprecated -#undef __DEPRECATED_MACRO -#define __DEPRECATED_MACRO - #include #define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) diff --git a/tests/kernel/workq/work_queue/src/main.c b/tests/kernel/workq/work_queue/src/main.c index b14d28787171..f97f202bcee9 100644 --- a/tests/kernel/workq/work_queue/src/main.c +++ b/tests/kernel/workq/work_queue/src/main.c @@ -10,11 +10,6 @@ * about the use of that API. */ #include -#undef __deprecated -#define __deprecated -#undef __DEPRECATED_MACRO -#define __DEPRECATED_MACRO - #include #include #include diff --git a/tests/lib/newlib/heap_listener/prj.conf b/tests/lib/newlib/heap_listener/prj.conf index e5a5dc6df4c1..7282777ff1ca 100644 --- a/tests/lib/newlib/heap_listener/prj.conf +++ b/tests/lib/newlib/heap_listener/prj.conf @@ -1,3 +1,4 @@ CONFIG_ZTEST=y CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=n CONFIG_NEWLIB_LIBC_HEAP_LISTENER=y diff --git a/tests/net/ipv6/prj.conf b/tests/net/ipv6/prj.conf index 51cfa883727d..c8dda7728952 100644 --- a/tests/net/ipv6/prj.conf +++ b/tests/net/ipv6/prj.conf @@ -33,6 +33,7 @@ CONFIG_NET_IF_MAX_IPV6_COUNT=2 CONFIG_NET_IPV6_PE=y CONFIG_NET_IPV6_PE_FILTER_PREFIX_COUNT=2 CONFIG_NET_IPV6_PE_PREFER_PUBLIC_ADDRESSES=n +CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y # Increase the stack a bit for mps2/an385 CONFIG_NET_RX_STACK_SIZE=1700 diff --git a/tests/subsys/fs/fcb/sysbuild.conf b/tests/subsys/fs/fcb/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/subsys/fs/fcb/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/subsys/fs/littlefs/sysbuild.conf b/tests/subsys/fs/littlefs/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/subsys/fs/littlefs/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/subsys/ipc/ipc_sessions/testcase.yaml b/tests/subsys/ipc/ipc_sessions/testcase.yaml index f76a61b8d68e..a4d34a394dd8 100644 --- a/tests/subsys/ipc/ipc_sessions/testcase.yaml +++ b/tests/subsys/ipc/ipc_sessions/testcase.yaml @@ -20,6 +20,7 @@ tests: - nrf54h20dk/nrf54h20/cpuapp extra_args: - CONFIG_IPC_TEST_SKIP_CORE_RESET=y + - CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y sample.ipc.ipc_sessions.nrf54h20dk_cpuapp_cpuppr: platform_allow: - nrf54h20dk/nrf54h20/cpuapp diff --git a/tests/subsys/secure_storage/psa/its/testcase.yaml b/tests/subsys/secure_storage/psa/its/testcase.yaml index 05f1c1b9a6ac..74bcec135863 100644 --- a/tests/subsys/secure_storage/psa/its/testcase.yaml +++ b/tests/subsys/secure_storage/psa/its/testcase.yaml @@ -28,6 +28,7 @@ tests: extra_args: - EXTRA_DTC_OVERLAY_FILE=zms.overlay - EXTRA_CONF_FILE=overlay-secure_storage.conf;overlay-store_zms.conf;overlay-transform_default.conf + - SB_CONFIG_PARTITION_MANAGER=n secure_storage.psa.its.secure_storage.store.settings: filter: CONFIG_SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS diff --git a/west.yml b/west.yml index 72255ca8b119..d3a70e368671 100644 --- a/west.yml +++ b/west.yml @@ -37,7 +37,7 @@ manifest: remote: babblesim repo-path: base path: tools/bsim/components - revision: d562cd57317d33531ee3655d84660c57b8dc64c9 + revision: 2cfac3dca2071452ae481d115d8541880568753d groups: - babblesim - name: babblesim_ext_2G4_channel_NtNcable @@ -79,7 +79,7 @@ manifest: remote: babblesim repo-path: ext_2G4_libPhyComv1 path: tools/bsim/components/ext_2G4_libPhyComv1 - revision: 15ae0f87fa049e04cbec48a866f3bc37d903f950 + revision: e18e41e8e3fa9f996559ed98b9238a5702dcdd36 groups: - babblesim - name: babblesim_ext_2G4_modem_BLE_simple @@ -100,7 +100,7 @@ manifest: remote: babblesim repo-path: ext_2G4_phy_v1 path: tools/bsim/components/ext_2G4_phy_v1 - revision: dbfd6b068f3bde8e56dcea58b4e686a8efc01cbe + revision: 8964ed1eb94606c2ea555340907bdc5171793e65 groups: - babblesim - name: babblesim_ext_libCryptov1 @@ -112,7 +112,7 @@ manifest: - babblesim - name: bsim repo-path: babblesim-manifest - revision: 193b8ba94cdc6ecbc3bb7fe80b87dee456e5eab0 + revision: 2ba22a0608ad9f46da1b96ee5121af357053c791 path: tools/bsim groups: - babblesim @@ -200,7 +200,7 @@ manifest: groups: - hal - name: hal_nordic - revision: 4eafaa44a55a557595e529f8cbdfc8dc1248da36 + revision: 71308dc6d8c021887ce5d98a36cafe9517375a91 path: modules/hal/nordic groups: - hal @@ -325,10 +325,10 @@ manifest: groups: - tools - name: nrf_hw_models - revision: c6296f600a6851bd652f207ab4908d339e1ce705 + revision: 968d55ff22579080466bf2f482596dd6e35361c6 path: modules/bsim_hw_models/nrf_hw_models - name: nrf_wifi - revision: 0cd7f28d34a5279cd839940c199658a294165722 + revision: 7cb2f44f46dfc86e4f97477ee90022944e138dd8 path: modules/lib/nrf_wifi - name: open-amp revision: f7f4d083c7909a39d86e217376c69b416ec4faf3