diff --git a/drivers/gpio/gpio_numaker.c b/drivers/gpio/gpio_numaker.c index a4fe05422178217..e28c72538b8bcfc 100644 --- a/drivers/gpio/gpio_numaker.c +++ b/drivers/gpio/gpio_numaker.c @@ -24,7 +24,11 @@ struct gpio_numaker_config { uint32_t reg; uint32_t gpa_base; uint32_t size; +#if defined(CONFIG_SOC_SERIES_M2L31X) + uint64_t clk_modidx; +#else uint32_t clk_modidx; +#endif const struct device *clk_dev; }; @@ -226,6 +230,15 @@ static void gpio_numaker_isr(const struct device *dev) #define CLOCK_CTRL_INIT(n) .clk_dev = DEVICE_DT_GET(DT_PARENT(DT_INST_CLOCKS_CTLR(n))), +#if defined(CONFIG_SOC_SERIES_M2L31X) +#define CLOCK_MODULE_INDEX_INIT(n) \ + (((uint64_t) DT_INST_CLOCKS_CELL(n, clock_module_index_hi32)) << 32) \ + |DT_INST_CLOCKS_CELL(n, clock_module_index) +#else +#define CLOCK_MODULE_INDEX_INIT(n) \ + DT_INST_CLOCKS_CELL(n, clock_module_index) +#endif + #define GPIO_NUMAKER_IRQ_INIT(n) \ do { \ IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), gpio_numaker_isr, \ @@ -242,7 +255,7 @@ static void gpio_numaker_isr(const struct device *dev) .reg = DT_INST_REG_ADDR(n), \ .gpa_base = DT_REG_ADDR(DT_NODELABEL(gpioa)), \ .size = DT_REG_SIZE(DT_NODELABEL(gpioa)), \ - .clk_modidx = DT_INST_CLOCKS_CELL(n, clock_module_index), \ + .clk_modidx = CLOCK_MODULE_INDEX_INIT(n), \ CLOCK_CTRL_INIT(n)}; \ \ static struct gpio_numaker_data gpio_numaker_data##n; \ diff --git a/drivers/serial/uart_numaker.c b/drivers/serial/uart_numaker.c index 381e552eac1f715..9758b2f138af4d9 100644 --- a/drivers/serial/uart_numaker.c +++ b/drivers/serial/uart_numaker.c @@ -21,7 +21,11 @@ LOG_MODULE_REGISTER(numaker_uart, LOG_LEVEL_ERR); struct uart_numaker_config { UART_T *uart; const struct reset_dt_spec reset; +#if defined(CONFIG_SOC_SERIES_M2L31X) + uint64_t clk_modidx; +#else uint32_t clk_modidx; +#endif uint32_t clk_src; uint32_t clk_div; const struct device *clk_dev; @@ -405,6 +409,15 @@ static const struct uart_driver_api uart_numaker_driver_api = { #define CLOCK_CTRL_INIT(n) .clk_dev = DEVICE_DT_GET(DT_PARENT(DT_INST_CLOCKS_CTLR(n))), +#if defined(CONFIG_SOC_SERIES_M2L31X) +#define CLOCK_MODULE_INDEX_INIT(n) \ + (((uint64_t) DT_INST_CLOCKS_CELL(n, clock_module_index_hi32)) << 32) \ + |DT_INST_CLOCKS_CELL(n, clock_module_index) +#else +#define CLOCK_MODULE_INDEX_INIT(n) \ + DT_INST_CLOCKS_CELL(n, clock_module_index) +#endif + #define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n); #define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), @@ -429,7 +442,7 @@ static const struct uart_driver_api uart_numaker_driver_api = { static const struct uart_numaker_config uart_numaker_cfg_##inst = { \ .uart = (UART_T *)DT_INST_REG_ADDR(inst), \ .reset = RESET_DT_SPEC_INST_GET(inst), \ - .clk_modidx = DT_INST_CLOCKS_CELL(inst, clock_module_index), \ + .clk_modidx = CLOCK_MODULE_INDEX_INIT(inst), \ .clk_src = DT_INST_CLOCKS_CELL(inst, clock_source), \ .clk_div = DT_INST_CLOCKS_CELL(inst, clock_divider), \ CLOCK_CTRL_INIT(inst).irq_n = DT_INST_IRQN(inst), \ diff --git a/dts/arm/nuvoton/m2l31x.dtsi b/dts/arm/nuvoton/m2l31x.dtsi index b3cbd6c997b5d4f..fc484a63024439a 100644 --- a/dts/arm/nuvoton/m2l31x.dtsi +++ b/dts/arm/nuvoton/m2l31x.dtsi @@ -51,7 +51,7 @@ pcc: peripheral-clock-controller { compatible = "nuvoton,numaker-pcc"; - #clock-cells = <3>; + #clock-cells = <4>; }; }; diff --git a/dts/bindings/clock/nuvoton,numaker-pcc.yaml b/dts/bindings/clock/nuvoton,numaker-pcc.yaml index 3239665a78e5058..d588421cb2b1a7e 100644 --- a/dts/bindings/clock/nuvoton,numaker-pcc.yaml +++ b/dts/bindings/clock/nuvoton,numaker-pcc.yaml @@ -9,9 +9,10 @@ include: [clock-controller.yaml, base.yaml] properties: "#clock-cells": - const: 3 + const: 4 clock-cells: - - clock-module-index # Same as u32ModuleIdx on invoking BSP CLK driver CLK_SetModuleClock() - - clock-source # Same as u32ClkSrc on invoking BSP CLK driver CLK_SetModuleClock() - - clock-divider # Same as u32ClkDiv on invoking BSP CLK driver CLK_SetModuleClock() + - clock-module-index-hi32 # Same as u32ModuleIdx/u64ModuleIdx on invoking BSP CLK driver + - clock-module-index # CLK_SetModuleClock() + - clock-source # Same as u32ClkSrc on invoking BSP CLK driver CLK_SetModuleClock() + - clock-divider # Same as u32ClkDiv on invoking BSP CLK driver CLK_SetModuleClock() diff --git a/include/zephyr/drivers/clock_control/clock_control_numaker.h b/include/zephyr/drivers/clock_control/clock_control_numaker.h index a61549153ab47c1..357054ca06f5f76 100644 --- a/include/zephyr/drivers/clock_control/clock_control_numaker.h +++ b/include/zephyr/drivers/clock_control/clock_control_numaker.h @@ -25,13 +25,17 @@ struct numaker_scc_subsys { uint32_t subsys_id; /* SCC sybsystem ID */ /* Peripheral clock control configuration structure - * clk_modidx is same as u32ModuleIdx in BSP CLK_SetModuleClock(). + * clk_modidx is same as u32ModuleIdx/u64ModuleIdx in BSP CLK_SetModuleClock(). * clk_src is same as u32ClkSrc in BSP CLK_SetModuleClock(). * clk_div is same as u32ClkDiv in BSP CLK_SetModuleClock(). */ union { struct { +#if defined(CONFIG_SOC_SERIES_M2L31X) + uint64_t clk_modidx; +#else uint32_t clk_modidx; +#endif uint32_t clk_src; uint32_t clk_div; } pcc; diff --git a/include/zephyr/dt-bindings/clock/numaker_m2l31x_clock.h b/include/zephyr/dt-bindings/clock/numaker_m2l31x_clock.h index fab7f656e4fc0b4..c7e77c09d4e26d5 100644 --- a/include/zephyr/dt-bindings/clock/numaker_m2l31x_clock.h +++ b/include/zephyr/dt-bindings/clock/numaker_m2l31x_clock.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NUMAKER_M2L31_CLOCK_H -#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NUMAKER_M2L31_CLOCK_H +#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NUMAKER_M2L31X_CLOCK_H +#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_NUMAKER_M2L31X_CLOCK_H #define NUMAKER_CLK_CLKSEL0_HCLKSEL_HXT 0x00000000 #define NUMAKER_CLK_CLKSEL0_HCLKSEL_LXT 0x00000001 @@ -193,82 +193,82 @@ #define NUMAKER_CLK_PCLKDIV_APB1DIV_DIV4 0x00000020 #define NUMAKER_CLK_PCLKDIV_APB1DIV_DIV8 0x00000030 #define NUMAKER_CLK_PCLKDIV_APB1DIV_DIV16 0x00000040 -#define NUMAKER_PDMA0_MODULE 0x00000001 -#define NUMAKER_ISP_MODULE 0x00000002 -#define NUMAKER_EBI_MODULE 0x00000003 -#define NUMAKER_ST_MODULE 0x018C0004 -#define NUMAKER_CRC_MODULE 0x00000007 -#define NUMAKER_CRPT_MODULE 0x0000000C -#define NUMAKER_KS_MODULE 0x0000000D -#define NUMAKER_USBH_MODULE 0x00A01090 -#define NUMAKER_GPA_MODULE 0x00000018 -#define NUMAKER_GPB_MODULE 0x00000019 -#define NUMAKER_GPC_MODULE 0x0000001A -#define NUMAKER_GPD_MODULE 0x0000001B -#define NUMAKER_GPE_MODULE 0x0000001C -#define NUMAKER_GPF_MODULE 0x0000001D -#define NUMAKER_GPG_MODULE 0x0000001E -#define NUMAKER_GPH_MODULE 0x0000001F -#define NUMAKER_RTC_MODULE 0x20000001 -#define NUMAKER_TMR0_MODULE 0x25A00002 -#define NUMAKER_TMR1_MODULE 0x25B00003 -#define NUMAKER_TMR2_MODULE 0x25C00004 -#define NUMAKER_TMR3_MODULE 0x25D00005 -#define NUMAKER_CLKO_MODULE 0x26100006 -#define NUMAKER_ACMP01_MODULE 0x20000007 -#define NUMAKER_I2C0_MODULE 0x20000008 -#define NUMAKER_I2C1_MODULE 0x20000009 -#define NUMAKER_I2C2_MODULE 0x2000000A -#define NUMAKER_I2C3_MODULE 0x2000000B -#define NUMAKER_QSPI0_MODULE 0x2908000C -#define NUMAKER_SPI0_MODULE 0x2990000D -#define NUMAKER_SPI1_MODULE 0x29B0000E -#define NUMAKER_SPI2_MODULE 0x2DA0000F -#define NUMAKER_UART0_MODULE 0x31801110 -#define NUMAKER_UART1_MODULE 0x31901191 -#define NUMAKER_UART2_MODULE 0x31A11012 -#define NUMAKER_UART3_MODULE 0x31B11093 -#define NUMAKER_UART4_MODULE 0x31C11114 -#define NUMAKER_UART5_MODULE 0x31D11195 -#define NUMAKER_UART6_MODULE 0x31E11216 -#define NUMAKER_UART7_MODULE 0x31F11297 -#define NUMAKER_OTG_MODULE 0x2000001A -#define NUMAKER_USBD_MODULE 0x20A0109B -#define NUMAKER_EADC0_MODULE 0x2128221C -#define NUMAKER_TRNG_MODULE 0x2000001F -#define NUMAKER_SPI3_MODULE 0x4DB00006 -#define NUMAKER_USCI0_MODULE 0x40000008 -#define NUMAKER_USCI1_MODULE 0x40000009 -#define NUMAKER_WWDT_MODULE 0x4578000B -#define NUMAKER_DAC_MODULE 0x4000000C -#define NUMAKER_EPWM0_MODULE 0x48800010 -#define NUMAKER_EPWM1_MODULE 0x48840011 -#define NUMAKER_EQEI0_MODULE 0x40000016 -#define NUMAKER_EQEI1_MODULE 0x40000017 -#define NUMAKER_TK_MODULE 0x489C0019 -#define NUMAKER_ECAP0_MODULE 0x4000001A -#define NUMAKER_ECAP1_MODULE 0x4000001B -#define NUMAKER_ACMP2_MODULE 0x60000007 -#define NUMAKER_PWM0_MODULE 0x6C980008 -#define NUMAKER_PWM1_MODULE 0x6C9C0009 -#define NUMAKER_UTCPD0_MODULE 0x6000000F -#define NUMAKER_CANRAM0_MODULE 0x80000010 -#define NUMAKER_CANRAM1_MODULE 0x80000011 -#define NUMAKER_CANFD0_MODULE 0x81621014 -#define NUMAKER_CANFD1_MODULE 0x816A1095 -#define NUMAKER_HCLK1_MODULE 0x81B3101C -#define NUMAKER_LPPDMA0_MODULE 0xA0000000 -#define NUMAKER_LPGPIO_MODULE 0xA0000001 -#define NUMAKER_LPSRAM_MODULE 0xA0000002 -#define NUMAKER_WDT_MODULE 0xB5600010 -#define NUMAKER_LPSPI0_MODULE 0xB5080011 -#define NUMAKER_LPI2C0_MODULE 0xA0000012 -#define NUMAKER_LPUART0_MODULE 0xB5031113 -#define NUMAKER_LPTMR0_MODULE 0xB5A00014 -#define NUMAKER_LPTMR1_MODULE 0xB5B00015 -#define NUMAKER_TTMR0_MODULE 0xB5100016 -#define NUMAKER_TTMR1_MODULE 0xB5180017 -#define NUMAKER_LPADC0_MODULE 0xB5431218 -#define NUMAKER_OPA_MODULE 0xA000001B +#define NUMAKER_PDMA0_MODULE 0x00000000 0x00000001 +#define NUMAKER_ISP_MODULE 0x00000000 0x00000002 +#define NUMAKER_EBI_MODULE 0x00000000 0x00000003 +#define NUMAKER_ST_MODULE 0x00000000 0x018C0004 +#define NUMAKER_CRC_MODULE 0x00000000 0x00000007 +#define NUMAKER_CRPT_MODULE 0x00000000 0x0000000C +#define NUMAKER_KS_MODULE 0x00000000 0x0000000D +#define NUMAKER_USBH_MODULE 0x00000000 0x00A01090 +#define NUMAKER_GPA_MODULE 0x00000000 0x00000018 +#define NUMAKER_GPB_MODULE 0x00000000 0x00000019 +#define NUMAKER_GPC_MODULE 0x00000000 0x0000001A +#define NUMAKER_GPD_MODULE 0x00000000 0x0000001B +#define NUMAKER_GPE_MODULE 0x00000000 0x0000001C +#define NUMAKER_GPF_MODULE 0x00000000 0x0000001D +#define NUMAKER_GPG_MODULE 0x00000000 0x0000001E +#define NUMAKER_GPH_MODULE 0x00000000 0x0000001F +#define NUMAKER_RTC_MODULE 0x00000000 0x20000001 +#define NUMAKER_TMR0_MODULE 0x00000000 0x25A00002 +#define NUMAKER_TMR1_MODULE 0x00000000 0x25B00003 +#define NUMAKER_TMR2_MODULE 0x00000000 0x25C00004 +#define NUMAKER_TMR3_MODULE 0x00000000 0x25D00005 +#define NUMAKER_CLKO_MODULE 0x00000000 0x26100006 +#define NUMAKER_ACMP01_MODULE 0x00000000 0x20000007 +#define NUMAKER_I2C0_MODULE 0x00000000 0x20000008 +#define NUMAKER_I2C1_MODULE 0x00000000 0x20000009 +#define NUMAKER_I2C2_MODULE 0x00000000 0x2000000A +#define NUMAKER_I2C3_MODULE 0x00000000 0x2000000B +#define NUMAKER_QSPI0_MODULE 0x00000000 0x2908000C +#define NUMAKER_SPI0_MODULE 0x00000000 0x2990000D +#define NUMAKER_SPI1_MODULE 0x00000000 0x29B0000E +#define NUMAKER_SPI2_MODULE 0x00000000 0x2DA0000F +#define NUMAKER_UART0_MODULE 0x00000000 0x31801110 +#define NUMAKER_UART1_MODULE 0x00000000 0x31901191 +#define NUMAKER_UART2_MODULE 0x00000000 0x31A11012 +#define NUMAKER_UART3_MODULE 0x00000000 0x31B11093 +#define NUMAKER_UART4_MODULE 0x00000000 0x31C11114 +#define NUMAKER_UART5_MODULE 0x00000000 0x31D11195 +#define NUMAKER_UART6_MODULE 0x00000000 0x31E11216 +#define NUMAKER_UART7_MODULE 0x00000000 0x31F11297 +#define NUMAKER_OTG_MODULE 0x00000000 0x2000001A +#define NUMAKER_USBD_MODULE 0x00000000 0x20A0109B +#define NUMAKER_EADC0_MODULE 0x00000000 0x2128221C +#define NUMAKER_TRNG_MODULE 0x00000000 0x2000001F +#define NUMAKER_SPI3_MODULE 0x00000000 0x4DB00006 +#define NUMAKER_USCI0_MODULE 0x00000000 0x40000008 +#define NUMAKER_USCI1_MODULE 0x00000000 0x40000009 +#define NUMAKER_WWDT_MODULE 0x00000000 0x4578000B +#define NUMAKER_DAC_MODULE 0x00000000 0x4000000C +#define NUMAKER_EPWM0_MODULE 0x00000000 0x48800010 +#define NUMAKER_EPWM1_MODULE 0x00000000 0x48840011 +#define NUMAKER_EQEI0_MODULE 0x00000000 0x40000016 +#define NUMAKER_EQEI1_MODULE 0x00000000 0x40000017 +#define NUMAKER_TK_MODULE 0x00000000 0x489C0019 +#define NUMAKER_ECAP0_MODULE 0x00000000 0x4000001A +#define NUMAKER_ECAP1_MODULE 0x00000000 0x4000001B +#define NUMAKER_ACMP2_MODULE 0x00000000 0x60000007 +#define NUMAKER_PWM0_MODULE 0x00000000 0x6C980008 +#define NUMAKER_PWM1_MODULE 0x00000000 0x6C9C0009 +#define NUMAKER_UTCPD0_MODULE 0x00000000 0x6000000F +#define NUMAKER_CANRAM0_MODULE 0x00000000 0x80000010 +#define NUMAKER_CANRAM1_MODULE 0x00000000 0x80000011 +#define NUMAKER_CANFD0_MODULE 0x00000000 0x81621014 +#define NUMAKER_CANFD1_MODULE 0x00000000 0x816A1095 +#define NUMAKER_HCLK1_MODULE 0x00000000 0x81B3101C +#define NUMAKER_LPPDMA0_MODULE 0x00000000 0xA0000000 +#define NUMAKER_LPGPIO_MODULE 0x00000000 0xA0000001 +#define NUMAKER_LPSRAM_MODULE 0x00000000 0xA0000002 +#define NUMAKER_WDT_MODULE 0x00000000 0xB5600010 +#define NUMAKER_LPSPI0_MODULE 0x00000000 0xB5080011 +#define NUMAKER_LPI2C0_MODULE 0x00000000 0xA0000012 +#define NUMAKER_LPUART0_MODULE 0x00000000 0xB5031113 +#define NUMAKER_LPTMR0_MODULE 0x00000000 0xB5A00014 +#define NUMAKER_LPTMR1_MODULE 0x00000000 0xB5B00015 +#define NUMAKER_TTMR0_MODULE 0x00000000 0xB5100016 +#define NUMAKER_TTMR1_MODULE 0x00000000 0xB5180017 +#define NUMAKER_LPADC0_MODULE 0x00000000 0xB5431218 +#define NUMAKER_OPA_MODULE 0x00000000 0xA000001B #endif