Skip to content

Commit 8053a87

Browse files
committed
[nrf fromlist] drivers: clock_control: nrf: Move NRF_PERIPH_GET_FREQUENCY
Move macro from nrf_clock_control.h to soc_nrf_common.h. Clock control header fetches many dependencies (e.g. onoff.h) so move macro to more low level header. Upstream PR #: 85870 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 884d063 commit 8053a87

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

drivers/counter/counter_nrfx_timer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
#include <soc.h>
67
#include <zephyr/drivers/counter.h>
78
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
89
#include <zephyr/devicetree.h>

include/zephyr/drivers/clock_control/nrf_clock_control.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -343,25 +343,6 @@ void nrf_clock_control_hfxo_release(void);
343343

344344
#endif /* defined(CONFIG_CLOCK_CONTROL_NRF2) */
345345

346-
/** @brief Get clock frequency that is used for the given node.
347-
*
348-
* Macro checks if node has clock property and if yes then if clock has clock_frequency property
349-
* then it is returned. If it has supported_clock_frequency property with the list of supported
350-
* frequencies then the last one is returned with assumption that they are ordered and the last
351-
* one is the highest. If node does not have clock then 16 MHz is returned which is the default
352-
* frequency.
353-
*
354-
* @param node Devicetree node.
355-
*
356-
* @return Frequency of the clock that is used for the node.
357-
*/
358-
#define NRF_PERIPH_GET_FREQUENCY(node) \
359-
COND_CODE_1(DT_CLOCKS_HAS_IDX(node, 0), \
360-
(COND_CODE_1(DT_NODE_HAS_PROP(DT_CLOCKS_CTLR(node), clock_frequency), \
361-
(DT_PROP(DT_CLOCKS_CTLR(node), clock_frequency)), \
362-
(DT_PROP_LAST(DT_CLOCKS_CTLR(node), supported_clock_frequency)))), \
363-
(NRFX_MHZ_TO_HZ(16)))
364-
365346
#ifdef __cplusplus
366347
}
367348
#endif

soc/nordic/common/soc_nrf_common.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,25 @@
236236
DT_PINCTRL_HAS_NAME(node_id, sleep), \
237237
DT_NODE_PATH(node_id) " defined without sleep state")
238238

239+
/** @brief Get clock frequency that is used for the given node.
240+
*
241+
* Macro checks if node has clock property and if yes then if clock has clock_frequency property
242+
* then it is returned. If it has supported_clock_frequency property with the list of supported
243+
* frequencies then the last one is returned with assumption that they are ordered and the last
244+
* one is the highest. If node does not have clock then 16 MHz is returned which is the default
245+
* frequency.
246+
*
247+
* @param node Devicetree node.
248+
*
249+
* @return Frequency of the clock that is used for the node.
250+
*/
251+
#define NRF_PERIPH_GET_FREQUENCY(node) \
252+
COND_CODE_1(DT_CLOCKS_HAS_IDX(node, 0), \
253+
(COND_CODE_1(DT_NODE_HAS_PROP(DT_CLOCKS_CTLR(node), clock_frequency), \
254+
(DT_PROP(DT_CLOCKS_CTLR(node), clock_frequency)), \
255+
(DT_PROP_LAST(DT_CLOCKS_CTLR(node), supported_clock_frequency)))), \
256+
(NRFX_MHZ_TO_HZ(16)))
257+
239258
#endif /* !_ASMLANGUAGE */
240259

241260
#endif

0 commit comments

Comments
 (0)