12#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_RENESAS_RA_CGC_H_
13#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_RENESAS_RA_CGC_H_
30#define RA_CGC_PROP_HAS_STATUS_OKAY_OR(node_id, prop, default_value) \
31 COND_CODE_1(DT_NODE_HAS_STATUS(node_id, okay), \
32 (DT_PROP(node_id, prop)), (default_value))
40#define RA_CGC_CLK_SRC(node_id) \
41 COND_CODE_1(DT_NODE_HAS_STATUS(node_id, okay), \
42 (UTIL_CAT(BSP_CLOCKS_SOURCE_, DT_NODE_FULL_NAME_UPPER_TOKEN(node_id))), \
43 (BSP_CLOCKS_CLOCK_DISABLED))
50#define RA_CGC_CLK_DIV(clk, prop, default_value) \
51 UTIL_CAT(RA_CGC_DIV_, DT_NODE_FULL_NAME_UPPER_TOKEN(clk)) \
52 (RA_CGC_PROP_HAS_STATUS_OKAY_OR(clk, prop, default_value))
61#define RA_CGC_DIV_BCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
63#define RA_CGC_DIV_CANFDCLK(n) UTIL_CAT(BSP_CLOCKS_CANFD_CLOCK_DIV_, n)
65#define RA_CGC_DIV_CECCLK(n) UTIL_CAT(BSP_CLOCKS_CEC_CLOCK_DIV_, n)
67#define RA_CGC_DIV_CLKOUT(n) UTIL_CAT(BSP_CLOCKS_CLKOUT_DIV_, n)
69#define RA_CGC_DIV_CPUCLK0(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
71#define RA_CGC_DIV_CPUCLK1(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
73#define RA_CGC_DIV_MRPCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
75#define RA_CGC_DIV_CPUCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
77#define RA_CGC_DIV_FCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
79#define RA_CGC_DIV_I3CCLK(n) UTIL_CAT(BSP_CLOCKS_I3C_CLOCK_DIV_, n)
81#define RA_CGC_DIV_ICLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
83#define RA_CGC_DIV_LCDCLK(n) UTIL_CAT(BSP_CLOCKS_LCD_CLOCK_DIV_, n)
85#define RA_CGC_DIV_OCTASPICLK(n) UTIL_CAT(BSP_CLOCKS_OCTA_CLOCK_DIV_, n)
87#define RA_CGC_DIV_PCLKA(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
89#define RA_CGC_DIV_PCLKB(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
91#define RA_CGC_DIV_PCLKC(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
93#define RA_CGC_DIV_PCLKD(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
95#define RA_CGC_DIV_PCLKE(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
97#define RA_CGC_DIV_PLL(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
99#define RA_CGC_DIV_PLLP(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
101#define RA_CGC_DIV_PLLQ(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
103#define RA_CGC_DIV_PLLR(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
105#define RA_CGC_DIV_PLL2(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
107#define RA_CGC_DIV_PLL2P(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
109#define RA_CGC_DIV_PLL2Q(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
111#define RA_CGC_DIV_PLL2R(n) UTIL_CAT(BSP_CLOCKS_PLL_DIV_, n)
113#define RA_CGC_DIV_SCICLK(n) UTIL_CAT(BSP_CLOCKS_SCI_CLOCK_DIV_, n)
115#define RA_CGC_DIV_SPICLK(n) UTIL_CAT(BSP_CLOCKS_SPI_CLOCK_DIV_, n)
117#define RA_CGC_DIV_U60CLK(n) UTIL_CAT(BSP_CLOCKS_USB60_CLOCK_DIV_, n)
119#define RA_CGC_DIV_UCLK(n) UTIL_CAT(BSP_CLOCKS_USB_CLOCK_DIV_, n)
121#define RA_CGC_DIV_SCISPICLK(n) UTIL_CAT(BSP_CLOCKS_SCISPI_CLOCK_DIV_, n)
123#define RA_CGC_DIV_GPTCLK(n) UTIL_CAT(BSP_CLOCKS_GPT_CLOCK_DIV_, n)
125#define RA_CGC_DIV_IICCLK(n) UTIL_CAT(BSP_CLOCKS_IIC_CLOCK_DIV_, n)
127#define RA_CGC_DIV_ADCCLK(n) UTIL_CAT(BSP_CLOCKS_ADC_CLOCK_DIV_, n)
129#define RA_CGC_DIV_MRICLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
131#define RA_CGC_DIV_NPUCLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
133#define RA_CGC_DIV_BCLKA(n) UTIL_CAT(BSP_CLOCKS_BCLKA_CLOCK_DIV_, n)
135#define RA_CGC_DIV_ESWCLK(n) UTIL_CAT(BSP_CLOCKS_ESW_CLOCK_DIV_, n)
137#define RA_CGC_DIV_ESWPHYCLK(n) UTIL_CAT(BSP_CLOCKS_ESWPHY_CLOCK_DIV_, n)
139#define RA_CGC_DIV_ETHPHYCLK(n) UTIL_CAT(BSP_CLOCKS_ETHPHY_CLOCK_DIV_, n)
141#define RA_CGC_DIV_ESCCLK(n) UTIL_CAT(BSP_CLOCKS_ESC_CLOCK_DIV_, n)
143#define RA_CGC_DIV_DSMIFCLK(n) UTIL_CAT(BSP_CLOCKS_DSMIF_CLOCK_DIV_, n)
146#define RA_CGC_DIV_XTALDIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
148#define RA_CGC_DIV_HOCODIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
150#define RA_CGC_DIV_MOCODIV_CLK(n) UTIL_CAT(BSP_CLOCKS_SYS_CLOCK_DIV_, n)
152#define RA_CGC_DIV_SAU_CK00(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
154#define RA_CGC_DIV_SAU_CK01(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
156#define RA_CGC_DIV_SAU_CK10(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
158#define RA_CGC_DIV_SAU_CK11(n) UTIL_CAT(BSP_CLOCKS_SAU_CLOCK_DIV_, n)
160#define RA_CGC_DIV_TAU_CK01(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
162#define RA_CGC_DIV_TAU_CK02(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
164#define RA_CGC_DIV_TAU_CK03(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
166#define RA_CGC_DIV_TAU_CK04(n) UTIL_CAT(TIMER_SOURCE_DIV_, n)
176#define BSP_CLOCKS_SOURCE_PLL BSP_CLOCKS_SOURCE_CLOCK_PLL
178#define BSP_CLOCKS_SOURCE_PLLP BSP_CLOCKS_SOURCE_CLOCK_PLL
180#define BSP_CLOCKS_SOURCE_PLLQ BSP_CLOCKS_SOURCE_CLOCK_PLL1Q
182#define BSP_CLOCKS_SOURCE_PLLR BSP_CLOCKS_SOURCE_CLOCK_PLL1R
184#define BSP_CLOCKS_SOURCE_PLL2 BSP_CLOCKS_SOURCE_CLOCK_PLL2
186#define BSP_CLOCKS_SOURCE_PLL2P BSP_CLOCKS_SOURCE_CLOCK_PLL2
188#define BSP_CLOCKS_SOURCE_PLL2Q BSP_CLOCKS_SOURCE_CLOCK_PLL2Q
190#define BSP_CLOCKS_SOURCE_PLL2R BSP_CLOCKS_SOURCE_CLOCK_PLL2R
193#define BSP_CLOCKS_SOURCE_XTALDIV_CLK BSP_CLOCKS_SOURCE_CLOCK_MAIN_OSC
195#define BSP_CLOCKS_SOURCE_HOCODIV_CLK BSP_CLOCKS_SOURCE_CLOCK_HOCO
197#define BSP_CLOCKS_SOURCE_MOCODIV_CLK BSP_CLOCKS_SOURCE_CLOCK_MOCO
200#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(pclk))
201#if DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(hoco))
202#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_HOCO
203#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(moco))
204#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_MOCO
205#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(loco))
206#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_LOCO
207#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(xtal))
208#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_MAIN_OSC
209#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(subclk))
210#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_CLOCK_SUBCLOCK
211#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(hocodiv_clk))
212#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_HOCODIV_CLK
213#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(mocodiv_clk))
214#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_MOCODIV_CLK
215#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(pclk)), DT_NODELABEL(xtaldiv_clk))
216#define BSP_CLOCKS_SOURCE_PCLK BSP_CLOCKS_SOURCE_XTALDIV_CLK
218#error "Invalid pclk source clock"
223#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(fsxp))
224#if DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(fsxp)), DT_NODELABEL(loco))
225#define BSP_CLOCKS_SOURCE_FSXP BSP_CLOCKS_SOURCE_CLOCK_LOCO
226#elif DT_SAME_NODE(DT_CLOCKS_CTLR(DT_NODELABEL(fsxp)), DT_NODELABEL(subclk))
227#define BSP_CLOCKS_SOURCE_FSXP BSP_CLOCKS_SOURCE_CLOCK_SUBCLOCK
229#error "Invalid fsxp source clock"
240#define BSP_CLOCKS_CLKOUT_DIV_1 (0)
241#define BSP_CLOCKS_CLKOUT_DIV_2 (1)
242#define BSP_CLOCKS_CLKOUT_DIV_4 (2)
243#define BSP_CLOCKS_CLKOUT_DIV_8 (3)
244#define BSP_CLOCKS_CLKOUT_DIV_16 (4)
245#define BSP_CLOCKS_CLKOUT_DIV_32 (5)
246#define BSP_CLOCKS_CLKOUT_DIV_64 (6)
247#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:253
uint32_t clk_div
Clock divider value.
Definition renesas_ra_cgc.h:255
uint32_t clk_src
Clock source selection.
Definition renesas_ra_cgc.h:254
Subsystem clock control configuration.
Definition renesas_ra_cgc.h:261
uint32_t mstp
MSTP register index.
Definition renesas_ra_cgc.h:262
uint32_t stop_bit
Clock stop bit.
Definition renesas_ra_cgc.h:263