|
| 1 | +/* |
| 2 | + * Copyright (c) 2018 Nordic Semiconductor ASA. |
| 3 | + * Copyright (c) 2025 Raytac Corporation. |
| 4 | + * |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + */ |
| 7 | + |
| 8 | +#include <zephyr/init.h> |
| 9 | +#include <hal/nrf_power.h> |
| 10 | + |
| 11 | +static int board_raytac_mdbt50q_cx_40_dongle_nrf52840_init(void) |
| 12 | +{ |
| 13 | + |
| 14 | + /* if the nrf52840dongle_nrf52840 board is powered from USB |
| 15 | + * (high voltage mode), GPIO output voltage is set to 1.8 volts by |
| 16 | + * default and that is not enough to turn the green and blue LEDs on. |
| 17 | + * Increase GPIO voltage to 3.0 volts. |
| 18 | + */ |
| 19 | + if ((nrf_power_mainregstatus_get(NRF_POWER) == |
| 20 | + NRF_POWER_MAINREGSTATUS_HIGH) && |
| 21 | + ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == |
| 22 | + (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos))) { |
| 23 | + |
| 24 | + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; |
| 25 | + while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { |
| 26 | + ; |
| 27 | + } |
| 28 | + |
| 29 | + NRF_UICR->REGOUT0 = |
| 30 | + (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | |
| 31 | + (UICR_REGOUT0_VOUT_3V0 << UICR_REGOUT0_VOUT_Pos); |
| 32 | + |
| 33 | + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; |
| 34 | + while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { |
| 35 | + ; |
| 36 | + } |
| 37 | + |
| 38 | + /* a reset is required for changes to take effect */ |
| 39 | + NVIC_SystemReset(); |
| 40 | + } |
| 41 | + |
| 42 | + return 0; |
| 43 | +} |
| 44 | + |
| 45 | +SYS_INIT(board_raytac_mdbt50q_cx_40_dongle_nrf52840_init, PRE_KERNEL_1, |
| 46 | + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); |
0 commit comments