Zephyr Project API 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
kinetis_sim.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, 2025-2026 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
8#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_
9
10#define KINETIS_SIM_CORESYS_CLK 0
11#define KINETIS_SIM_PLATFORM_CLK 1
12#define KINETIS_SIM_BUS_CLK 2
13#define KINETIS_SIM_FAST_PERIPHERAL_CLK 5
14#define KINETIS_SIM_LPO_CLK 19
15#define KINETIS_SIM_DMAMUX_CLK KINETIS_SIM_BUS_CLK
16#define KINETIS_SIM_DMA_CLK KINETIS_SIM_CORESYS_CLK
17#define KINETIS_SIM_SIM_SOPT7 7
18#define KINETIS_SIM_OSCERCLK 8
19#define KINETIS_SIM_MCGIRCLK 12
20#define KINETIS_SIM_MCGPCLK 18
21
22#define KINETIS_SIM_PLLFLLSEL_MCGFLLCLK 0
23#define KINETIS_SIM_PLLFLLSEL_MCGPLLCLK 1
24#define KINETIS_SIM_PLLFLLSEL_IRC48MHZ 3
25
26#define KINETIS_SIM_ER32KSEL_OSC32KCLK 0
27#define KINETIS_SIM_ER32KSEL_RTC 2
28#define KINETIS_SIM_ER32KSEL_LPO1KHZ 3
29
30#define KINETIS_SIM_ENET_CLK 4321
31#define KINETIS_SIM_ENET_1588_CLK 4322
32
33#define KINETIS_SIM_CMP_CLK 4323
34#define KINETIS_SIM_VREF_CLK 4324
35
36/*
37 * SIM clock specifier encoding.
38 *
39 * Each SIM clock reference is a 3-cell specifier <id offset bits>:
40 *
41 * id - 32-bit encoded value containing gate and rate information
42 * offset - gate register offset (explicit, for readability and
43 * consumers such as ADC16 that read it directly)
44 * bits - gate bit index or mask (explicit, same reason)
45 *
46 * Layout of the `id` cell (32-bit):
47 * [31:19] gate_offset (13 bits) - SCGC register offset; 0 = no gate
48 * [18:14] gate_bit (5 bits) - bit position within SCGC register
49 * [13:9] clock_name (5 bits) - KINETIS_SIM_*_CLK for get_rate
50 * [8:6] mux_val (3 bits) - mux source value for configure
51 * [5:1] mux_shift (5 bits) - mux bit shift in mux register
52 * [0] has_mux (1 bit) - 1 = configure mux on .configure call
53 *
54 * All known clock name values (0-19) and gate offsets (up to 0x1040)
55 * fit within their respective fields.
56 */
57
59#define KINETIS_SIM_CLOCK_ID(name, gate_offset, gate_bit) \
60 ((((gate_offset) & 0x1FFFU) << 19) | \
61 (((gate_bit) & 0x1FU) << 14) | \
62 (((name) & 0x1FU) << 9))
63
64#define KINETIS_SIM_CLOCK_ID_MUX(name, gate_offset, gate_bit, mux_shift, mux_val) \
65 (KINETIS_SIM_CLOCK_ID(name, gate_offset, gate_bit) | \
66 (((mux_val) & 0x7U) << 6) | \
67 (((mux_shift) & 0x1FU) << 1) | 0x1U)
69
71/* Decoders used by the driver and soc.c */
72#define KINETIS_SIM_CLOCK_DECODE_GATE_OFFSET(val) (((val) >> 19) & 0x1FFFU)
73#define KINETIS_SIM_CLOCK_DECODE_GATE_BIT(val) (((val) >> 14) & 0x1FU)
74#define KINETIS_SIM_CLOCK_DECODE_NAME(val) (((val) >> 9) & 0x1FU)
75#define KINETIS_SIM_CLOCK_DECODE_MUX_VAL(val) (((val) >> 6) & 0x7U)
76#define KINETIS_SIM_CLOCK_DECODE_MUX_SHIFT(val) (((val) >> 1) & 0x1FU)
77#define KINETIS_SIM_CLOCK_HAS_MUX(val) ((val) & 0x1U)
79
92#define KINETIS_SIM_CLOCK(name, offset, bits) \
93 KINETIS_SIM_CLOCK_ID(name, offset, bits) offset bits
94
108#define KINETIS_SIM_CLOCK_MUX(name, offset, bits, mux_shift, mux_val) \
109 KINETIS_SIM_CLOCK_ID_MUX(name, offset, bits, mux_shift, mux_val) offset bits
110
111#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_KINETIS_SIM_H_ */