blob: 84e76f77e7d0fa3f01ff2a16ac2ee523e47c9320 [file] [log] [blame]
Ghennadi Procopciuc9dee8e42024-06-12 09:25:17 +03001// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright 2020-2021, 2023-2024 NXP
4 */
5#ifndef S32CC_CLK_REGS_H
6#define S32CC_CLK_REGS_H
7
8#include <lib/utils_def.h>
9
10#define FXOSC_BASE_ADDR (0x40050000UL)
Ghennadi Procopciucb390c4d2024-06-12 14:21:39 +030011#define ARMPLL_BASE_ADDR (0x40038000UL)
Ghennadi Procopciuc22f94742024-08-06 11:48:11 +030012#define PERIPHPLL_BASE_ADDR (0x4003C000UL)
Ghennadi Procopciucf21d3ae2024-08-05 16:48:49 +030013#define ARM_DFS_BASE_ADDR (0x40054000UL)
Ghennadi Procopciuc90c90002024-08-05 16:50:52 +030014#define CGM0_BASE_ADDR (0x40030000UL)
Ghennadi Procopciuca080f782024-06-12 14:44:47 +030015#define CGM1_BASE_ADDR (0x40034000UL)
Ghennadi Procopciuc9dee8e42024-06-12 09:25:17 +030016
17/* FXOSC */
18#define FXOSC_CTRL(FXOSC) ((FXOSC) + 0x0UL)
19#define FXOSC_CTRL_OSC_BYP BIT_32(31U)
20#define FXOSC_CTRL_COMP_EN BIT_32(24U)
21#define FXOSC_CTRL_EOCV_OFFSET 16U
22#define FXOSC_CTRL_EOCV_MASK GENMASK_32(23U, FXOSC_CTRL_EOCV_OFFSET)
23#define FXOSC_CTRL_EOCV(VAL) (FXOSC_CTRL_EOCV_MASK & \
24 ((uint32_t)(VAL) << FXOSC_CTRL_EOCV_OFFSET))
25#define FXOSC_CTRL_GM_SEL_OFFSET 4U
26#define FXOSC_CTRL_GM_SEL_MASK GENMASK_32(7U, FXOSC_CTRL_GM_SEL_OFFSET)
27#define FXOSC_CTRL_GM_SEL(VAL) (FXOSC_CTRL_GM_SEL_MASK & \
28 ((uint32_t)(VAL) << FXOSC_CTRL_GM_SEL_OFFSET))
29#define FXOSC_CTRL_OSCON BIT_32(0U)
30
31#define FXOSC_STAT(FXOSC) ((FXOSC) + 0x4UL)
32#define FXOSC_STAT_OSC_STAT BIT_32(31U)
33
Ghennadi Procopciucb390c4d2024-06-12 14:21:39 +030034/* PLL */
35#define PLLDIG_PLLCR(PLL) ((PLL) + 0x0UL)
36#define PLLDIG_PLLCR_PLLPD BIT_32(31U)
37
38#define PLLDIG_PLLSR(PLL) ((PLL) + 0x4UL)
39#define PLLDIG_PLLSR_LOCK BIT_32(2U)
40
41#define PLLDIG_PLLDV(PLL) ((PLL) + 0x8UL)
42#define PLLDIG_PLLDV_RDIV_OFFSET 12U
43#define PLLDIG_PLLDV_RDIV_MASK GENMASK_32(14U, PLLDIG_PLLDV_RDIV_OFFSET)
44#define PLLDIG_PLLDV_RDIV_SET(VAL) (PLLDIG_PLLDV_RDIV_MASK & \
45 ((VAL) << PLLDIG_PLLDV_RDIV_OFFSET))
46#define PLLDIG_PLLDV_MFI_MASK GENMASK_32(7U, 0U)
47#define PLLDIG_PLLDV_MFI(DIV) (PLLDIG_PLLDV_MFI_MASK & (DIV))
48
49#define PLLDIG_PLLFD(PLL) ((PLL) + 0x10UL)
50#define PLLDIG_PLLFD_SMDEN BIT_32(30U)
51#define PLLDIG_PLLFD_MFN_MASK GENMASK_32(14U, 0U)
52#define PLLDIG_PLLFD_MFN_SET(VAL) (PLLDIG_PLLFD_MFN_MASK & (VAL))
53
54#define PLLDIG_PLLCLKMUX(PLL) ((PLL) + 0x20UL)
55
56#define PLLDIG_PLLODIV(PLL, N) ((PLL) + 0x80UL + ((N) * 0x4UL))
57#define PLLDIG_PLLODIV_DE BIT_32(31U)
58#define PLLDIG_PLLODIV_DIV_OFFSET 16U
59#define PLLDIG_PLLODIV_DIV_MASK GENMASK_32(23U, PLLDIG_PLLODIV_DIV_OFFSET)
60#define PLLDIG_PLLODIV_DIV(VAL) (((VAL) & PLLDIG_PLLODIV_DIV_MASK) >> \
61 PLLDIG_PLLODIV_DIV_OFFSET)
62#define PLLDIG_PLLODIV_DIV_SET(VAL) (PLLDIG_PLLODIV_DIV_MASK & ((VAL) << \
63 PLLDIG_PLLODIV_DIV_OFFSET))
64
Ghennadi Procopciuca080f782024-06-12 14:44:47 +030065/* MMC_CGM */
66#define CGM_MUXn_CSC(CGM_ADDR, MUX) ((CGM_ADDR) + 0x300UL + ((MUX) * 0x40UL))
67#define MC_CGM_MUXn_CSC_SELCTL_OFFSET 24U
68#define MC_CGM_MUXn_CSC_SELCTL_MASK GENMASK_32(29U, MC_CGM_MUXn_CSC_SELCTL_OFFSET)
69#define MC_CGM_MUXn_CSC_SELCTL(val) (MC_CGM_MUXn_CSC_SELCTL_MASK & ((val) \
70 << MC_CGM_MUXn_CSC_SELCTL_OFFSET))
71#define MC_CGM_MUXn_CSC_CLK_SW BIT_32(2U)
72#define MC_CGM_MUXn_CSC_SAFE_SW BIT_32(3U)
73
74#define CGM_MUXn_CSS(CGM_ADDR, MUX) ((CGM_ADDR) + 0x304UL + ((MUX) * 0x40UL))
75#define MC_CGM_MUXn_CSS_SELSTAT_OFFSET 24U
76#define MC_CGM_MUXn_CSS_SELSTAT_MASK GENMASK_32(29U, MC_CGM_MUXn_CSS_SELSTAT_OFFSET)
77#define MC_CGM_MUXn_CSS_SELSTAT(css) ((MC_CGM_MUXn_CSS_SELSTAT_MASK & (css))\
78 >> MC_CGM_MUXn_CSS_SELSTAT_OFFSET)
79#define MC_CGM_MUXn_CSS_SWTRG(css) ((MC_CGM_MUXn_CSS_SWTRG_MASK & (css)) \
80 >> MC_CGM_MUXn_CSS_SWTRG_OFFSET)
81#define MC_CGM_MUXn_CSS_SWTRG_OFFSET 17U
82#define MC_CGM_MUXn_CSS_SWTRG_MASK GENMASK_32(19U, MC_CGM_MUXn_CSS_SWTRG_OFFSET)
83#define MC_CGM_MUXn_CSS_SWTRG_SUCCESS 0x1U
84#define MC_CGM_MUXn_CSS_SWTRG_SAFE_CLK 0x4U
85#define MC_CGM_MUXn_CSS_SWTRG_SAFE_CLK_INACTIVE 0x5U
86#define MC_CGM_MUXn_CSS_SWIP BIT_32(16U)
87#define MC_CGM_MUXn_CSS_SAFE_SW BIT_32(3U)
88
Ghennadi Procopciucf21d3ae2024-08-05 16:48:49 +030089/* DFS */
90#define DFS_PORTSR(DFS_ADDR) ((DFS_ADDR) + 0xCUL)
91#define DFS_PORTOLSR(DFS_ADDR) ((DFS_ADDR) + 0x10UL)
92#define DFS_PORTOLSR_LOL(N) (BIT_32(N) & GENMASK_32(5U, 0U))
93#define DFS_PORTRESET(DFS_ADDR) ((DFS_ADDR) + 0x14UL)
94#define DFS_PORTRESET_MASK GENMASK_32(5U, 0U)
95#define DFS_PORTRESET_SET(VAL) (((VAL) & DFS_PORTRESET_MASK))
96
97#define DFS_CTL(DFS_ADDR) ((DFS_ADDR) + 0x18UL)
98#define DFS_CTL_RESET BIT_32(1U)
99
100#define DFS_DVPORTn(DFS_ADDR, PORT) ((DFS_ADDR) + 0x1CUL + ((PORT) * 0x4UL))
101#define DFS_DVPORTn_MFI_MASK GENMASK_32(15U, 8U)
102#define DFS_DVPORTn_MFI_SHIFT 8U
103#define DFS_DVPORTn_MFN_MASK GENMASK_32(7U, 0U)
104#define DFS_DVPORTn_MFN_SHIFT 0U
105#define DFS_DVPORTn_MFI(MFI) (((MFI) & DFS_DVPORTn_MFI_MASK) >> DFS_DVPORTn_MFI_SHIFT)
106#define DFS_DVPORTn_MFN(MFN) (((MFN) & DFS_DVPORTn_MFN_MASK) >> DFS_DVPORTn_MFN_SHIFT)
107#define DFS_DVPORTn_MFI_SET(VAL) (((VAL) << DFS_DVPORTn_MFI_SHIFT) & DFS_DVPORTn_MFI_MASK)
108#define DFS_DVPORTn_MFN_SET(VAL) (((VAL) << DFS_DVPORTn_MFN_SHIFT) & DFS_DVPORTn_MFN_MASK)
109
Ghennadi Procopciuc9dee8e42024-06-12 09:25:17 +0300110#endif /* S32CC_CLK_REGS_H */