13#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_RENESAS_RA_CGC_H_
14#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_RENESAS_RA_CGC_H_
31#define RA_CGC_PROP_HAS_STATUS_OKAY_OR(node_id, prop, default_value) \
32 COND_CODE_1(DT_NODE_HAS_STATUS(node_id, okay), \
33 (DT_PROP(node_id, prop)), (default_value))
41#define RA_CGC_CLK_SRC(node_id) \
42 COND_CODE_1(DT_NODE_HAS_STATUS(node_id, okay), \
43 (UTIL_CAT(BSP_CLOCKS_SOURCE_, DT_NODE_FULL_NAME_UPPER_TOKEN(node_id))), \
44 (BSP_CLOCKS_CLOCK_DISABLED))
51#define RA_CGC_CLK_DIV(clk, prop, default_value) \
52 UTIL_CAT(RA_CGC_DIV_, DT_NODE_FULL_NAME_UPPER_TOKEN(clk)) \
53 (RA_CGC_PROP_HAS_STATUS_OKAY_OR(clk, prop, default_value))
63#define RA_CGC_DIV_BCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
65#define RA_CGC_DIV_CANFDCLK(n) UTIL_CAT(BSP_CLOCKS_CANFD_CLOCK_DIV_, n)
67#define RA_CGC_DIV_CECCLK(n) UTIL_CAT(BSP_CLOCKS_CEC_CLOCK_DIV_, n)
69#define RA_CGC_DIV_CLKOUT(n) UTIL_CAT(BSP_CLOCKS_CLKOUT_DIV_, n)
71#define RA_CGC_DIV_CPUCLK0(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
73#define RA_CGC_DIV_CPUCLK1(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
75#define RA_CGC_DIV_MRPCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
77#define RA_CGC_DIV_CPUCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
79#define RA_CGC_DIV_FCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
81#define RA_CGC_DIV_I3CCLK(n) UTIL_CAT(BSP_CLOCKS_I3C_CLOCK_DIV_, n)
83#define RA_CGC_DIV_ICLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
85#define RA_CGC_DIV_LCDCLK(n) UTIL_CAT(BSP_CLOCKS_LCD_CLOCK_DIV_, n)
87#define RA_CGC_DIV_OCTASPICLK(n) UTIL_CAT(BSP_CLOCKS_OCTA_CLOCK_DIV_, n)
89#define RA_CGC_DIV_PCLKA(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
91#define RA_CGC_DIV_PCLKB(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
93#define RA_CGC_DIV_PCLKC(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
95#define RA_CGC_DIV_PCLKD(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
97#define RA_CGC_DIV_PCLKE(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
99#define RA_CGC_DIV_PLL(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
101#define RA_CGC_DIV_PLLP(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
103#define RA_CGC_DIV_PLLQ(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
105#define RA_CGC_DIV_PLLR(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
107#define RA_CGC_DIV_PLL2(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
109#define RA_CGC_DIV_PLL2P(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
111#define RA_CGC_DIV_PLL2Q(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
113#define RA_CGC_DIV_PLL2R(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
115#define RA_CGC_DIV_SCICLK(n) UTIL_CAT(BSP_CLOCKS_SCI_CLOCK_DIV_, n)
117#define RA_CGC_DIV_SPICLK(n) UTIL_CAT(BSP_CLOCKS_SPI_CLOCK_DIV_, n)
119#define RA_CGC_DIV_U60CLK(n) UTIL_CAT(BSP_CLOCKS_USB60_CLOCK_DIV_, n)
121#define RA_CGC_DIV_UCLK(n) UTIL_CAT(BSP_CLOCKS_USB_CLOCK_DIV_, n)
123#define RA_CGC_DIV_SCISPICLK(n) UTIL_CAT(BSP_CLOCKS_SCISPI_CLOCK_DIV_, n)
125#define RA_CGC_DIV_GPTCLK(n) UTIL_CAT(BSP_CLOCKS_GPT_CLOCK_DIV_, n)
127#define RA_CGC_DIV_IICCLK(n) UTIL_CAT(BSP_CLOCKS_IIC_CLOCK_DIV_, n)
129#define RA_CGC_DIV_ADCCLK(n) UTIL_CAT(BSP_CLOCKS_ADC_CLOCK_DIV_, n)
131#define RA_CGC_DIV_MRICLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
133#define RA_CGC_DIV_NPUCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
135#define RA_CGC_DIV_BCLKA(n) UTIL_CAT(BSP_CLOCKS_BCLKA_CLOCK_DIV_, n)
137#define RA_CGC_DIV_ESWCLK(n) UTIL_CAT(BSP_CLOCKS_ESW_CLOCK_DIV_, n)
139#define RA_CGC_DIV_ESWPHYCLK(n) UTIL_CAT(BSP_CLOCKS_ESWPHY_CLOCK_DIV_, n)
141#define RA_CGC_DIV_ETHPHYCLK(n) UTIL_CAT(BSP_CLOCKS_ETHPHY_CLOCK_DIV_, n)
143#define RA_CGC_DIV_ESCCLK(n) UTIL_CAT(BSP_CLOCKS_ESC_CLOCK_DIV_, n)
145#define RA_CGC_DIV_DSMIFCLK(n) UTIL_CAT(BSP_CLOCKS_DSMIF_CLOCK_DIV_, n)
148#define RA_CGC_DIV_XTALDIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
150#define RA_CGC_DIV_HOCODIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
152#define RA_CGC_DIV_MOCODIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
154#define RA_CGC_DIV_SAU_CK00(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
156#define RA_CGC_DIV_SAU_CK01(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
158#define RA_CGC_DIV_SAU_CK10(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
160#define RA_CGC_DIV_SAU_CK11(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
162#define RA_CGC_DIV_TAU_CK01(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
164#define RA_CGC_DIV_TAU_CK02(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
166#define RA_CGC_DIV_TAU_CK03(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
168#define RA_CGC_DIV_TAU_CK04(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
179#define BSP_CLOCKS_SOURCE_PLL BSP_CLOCKS_SOURCE_CLOCK_PLL
181#define BSP_CLOCKS_SOURCE_PLLP BSP_CLOCKS_SOURCE_CLOCK_PLL
183#define BSP_CLOCKS_SOURCE_PLLQ BSP_CLOCKS_SOURCE_CLOCK_PLL1Q
185#define BSP_CLOCKS_SOURCE_PLLR BSP_CLOCKS_SOURCE_CLOCK_PLL1R
187#define BSP_CLOCKS_SOURCE_PLL2 BSP_CLOCKS_SOURCE_CLOCK_PLL2
189#define BSP_CLOCKS_SOURCE_PLL2P BSP_CLOCKS_SOURCE_CLOCK_PLL2
191#define BSP_CLOCKS_SOURCE_PLL2Q BSP_CLOCKS_SOURCE_CLOCK_PLL2Q
193#define BSP_CLOCKS_SOURCE_PLL2R BSP_CLOCKS_SOURCE_CLOCK_PLL2R
196#define BSP_CLOCKS_SOURCE_XTALDIV_CLK BSP_CLOCKS_SOURCE_CLOCK_MAIN_OSC
198#define BSP_CLOCKS_SOURCE_HOCODIV_CLK BSP_CLOCKS_SOURCE_CLOCK_HOCO
200#define BSP_CLOCKS_SOURCE_MOCODIV_CLK BSP_CLOCKS_SOURCE_CLOCK_MOCO
203#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pclk))
204#if DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(hoco))
205#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_HOCO
206#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(moco))
207#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_MOCO
208#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(loco))
209#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_LOCO
210#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(xtal))
211#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_MAIN_OSC
212#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(subclk))
213#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_SUBCLOCK
214#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(hocodiv_clk))
215#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_HOCODIV_CLK
216#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(mocodiv_clk))
217#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_MOCODIV_CLK
218#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(xtaldiv_clk))
219#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_XTALDIV_CLK
221#error "Invalid pclk source clock"
226#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(fsxp))
227#if DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(fsxp)), DT_NODELABEL(loco))
228#define BSP_CLOCKS_SOURCE_FSXP BSP_CLOCKS_SOURCE_CLOCK_LOCO
229#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(fsxp)), DT_NODELABEL(subclk))
230#define BSP_CLOCKS_SOURCE_FSXP BSP_CLOCKS_SOURCE_CLOCK_SUBCLOCK
232#error "Invalid fsxp source clock"
244#define BSP_CLOCKS_CLKOUT_DIV_1 (0)
245#define BSP_CLOCKS_CLKOUT_DIV_2 (1)
246#define BSP_CLOCKS_CLKOUT_DIV_4 (2)
247#define BSP_CLOCKS_CLKOUT_DIV_8 (3)
248#define BSP_CLOCKS_CLKOUT_DIV_16 (4)
249#define BSP_CLOCKS_CLKOUT_DIV_32 (5)
250#define BSP_CLOCKS_CLKOUT_DIV_64 (6)
251#define BSP_CLOCKS_CLKOUT_DIV_128 (7)
Main header file for clock control driver API.
Renesas RA Clock Generator Circuit (CGC) definitions for Zephyr.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Peripheral clock configuration.
Definition renesas_ra_cgc.h:257
uint32_t clk_div
Clock divider value.
Definition renesas_ra_cgc.h:259
uint32_t clk_src
Clock source selection.
Definition renesas_ra_cgc.h:258
Subsystem clock control configuration.
Definition renesas_ra_cgc.h:265
uint32_t mstp
MSTP register index.
Definition renesas_ra_cgc.h:266
uint32_t stop_bit
Clock stop bit.
Definition renesas_ra_cgc.h:267