1 /*
2  * Copyright (c) 2019 - 2025, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef NRFX_POWER_COMPAT_H__
35 #define NRFX_POWER_COMPAT_H__
36 
37 /**
38  * POWER compatibility layer.
39  *
40  * The following definitions allow using of common code involving the POWER peripheral
41  * driver for different SoCs, regardless of whether certain regulator registers
42  * are located in the POWER peripheral or in separate peripherals like USBREG and REGULATORS.
43  */
44 
45 #if defined(REGULATORS_PRESENT)
46 #include <hal/nrf_regulators.h>
47 
48 #if NRF_REGULATORS_HAS_POF
49 
50 typedef nrf_regulators_pof_thr_t nrf_power_pof_thr_t;
51 #define NRF_POWER_POFTHR_V17     NRF_REGULATORS_POF_THR_1V7
52 #define NRF_POWER_POFTHR_V18     NRF_REGULATORS_POF_THR_1V8
53 #define NRF_POWER_POFTHR_V19     NRF_REGULATORS_POF_THR_1V9
54 #define NRF_POWER_POFTHR_V20     NRF_REGULATORS_POF_THR_2V0
55 #define NRF_POWER_POFTHR_V21     NRF_REGULATORS_POF_THR_2V1
56 #define NRF_POWER_POFTHR_V22     NRF_REGULATORS_POF_THR_2V2
57 #define NRF_POWER_POFTHR_V23     NRF_REGULATORS_POF_THR_2V3
58 #define NRF_POWER_POFTHR_V24     NRF_REGULATORS_POF_THR_2V4
59 #define NRF_POWER_POFTHR_V25     NRF_REGULATORS_POF_THR_2V5
60 #define NRF_POWER_POFTHR_V26     NRF_REGULATORS_POF_THR_2V6
61 #define NRF_POWER_POFTHR_V27     NRF_REGULATORS_POF_THR_2V7
62 #define NRF_POWER_POFTHR_V28     NRF_REGULATORS_POF_THR_2V8
63 
64 #if NRF_REGULATORS_HAS_POF_VDDH
65 
66 typedef nrf_regulators_pof_thr_vddh_t nrf_power_pof_thrvddh_t;
67 #define NRF_POWER_POFTHRVDDH_V27     NRF_REGULATORS_POF_THR_VDDH_2V7
68 #define NRF_POWER_POFTHRVDDH_V28     NRF_REGULATORS_POF_THR_VDDH_2V8
69 #define NRF_POWER_POFTHRVDDH_V29     NRF_REGULATORS_POF_THR_VDDH_2V9
70 #define NRF_POWER_POFTHRVDDH_V30     NRF_REGULATORS_POF_THR_VDDH_3V0
71 #define NRF_POWER_POFTHRVDDH_V31     NRF_REGULATORS_POF_THR_VDDH_3V1
72 #define NRF_POWER_POFTHRVDDH_V32     NRF_REGULATORS_POF_THR_VDDH_3V2
73 #define NRF_POWER_POFTHRVDDH_V33     NRF_REGULATORS_POF_THR_VDDH_3V3
74 #define NRF_POWER_POFTHRVDDH_V34     NRF_REGULATORS_POF_THR_VDDH_3V4
75 #define NRF_POWER_POFTHRVDDH_V35     NRF_REGULATORS_POF_THR_VDDH_3V5
76 #define NRF_POWER_POFTHRVDDH_V36     NRF_REGULATORS_POF_THR_VDDH_3V6
77 #define NRF_POWER_POFTHRVDDH_V37     NRF_REGULATORS_POF_THR_VDDH_3V7
78 #define NRF_POWER_POFTHRVDDH_V38     NRF_REGULATORS_POF_THR_VDDH_3V8
79 #define NRF_POWER_POFTHRVDDH_V39     NRF_REGULATORS_POF_THR_VDDH_3V9
80 #define NRF_POWER_POFTHRVDDH_V40     NRF_REGULATORS_POF_THR_VDDH_4V0
81 #define NRF_POWER_POFTHRVDDH_V41     NRF_REGULATORS_POF_THR_VDDH_4V1
82 #define NRF_POWER_POFTHRVDDH_V42     NRF_REGULATORS_POF_THR_VDDH_4V2
83 
84 #endif // NRF_REGULATORS_HAS_POF_VDDH
85 
86 #endif // NRF_REGULATORS_HAS_POF
87 
88 #endif // defined(REGULATORS_PRESENT)
89 
90 #if defined(USBREG_PRESENT)
91 #include "nrfx_usbreg.h"
92 
93 typedef nrfx_usbreg_event_handler_t nrfx_power_usb_event_handler_t;
94 typedef nrfx_usbreg_config_t        nrfx_power_usbevt_config_t;
95 
96 typedef nrfx_usbreg_evt_t           nrfx_power_usb_evt_t;
97 #define NRFX_POWER_USB_EVT_DETECTED NRFX_USBREG_EVT_DETECTED
98 #define NRFX_POWER_USB_EVT_REMOVED  NRFX_USBREG_EVT_REMOVED
99 #define NRFX_POWER_USB_EVT_READY    NRFX_USBREG_EVT_READY
100 
101 typedef nrfx_usbreg_state_t               nrfx_power_usb_state_t;
102 #define NRFX_POWER_USB_STATE_DISCONNECTED NRFX_USBREG_STATE_DISCONNECTED
103 #define NRFX_POWER_USB_STATE_CONNECTED    NRFX_USBREG_STATE_CONNECTED
104 #define NRFX_POWER_USB_STATE_READY        NRFX_USBREG_STATE_READY
105 
106 #define nrfx_power_usb_handler_get nrfx_usbreg_handler_get
107 #define nrfx_power_usbevt_init     nrfx_usbreg_init
108 #define nrfx_power_usbevt_enable   nrfx_usbreg_enable
109 #define nrfx_power_usbevt_disable  nrfx_usbreg_disable
110 #define nrfx_power_usbevt_uninit   nrfx_usbreg_uninit
111 #define nrfx_power_usbstatus_get   nrfx_usbreg_usbstatus_get
112 
113 #endif // defined(USBREG_PRESENT)
114 
115 #endif // NRFX_POWER_COMPAT_H__
116