From d155b3168ec3a3f885905cfce3b8fddce8ef4386 Mon Sep 17 00:00:00 2001 From: Furkan AKKIZ <94184469+hfakkiz@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:44:46 +0300 Subject: [PATCH] feat(Other): Add MAX78002 SoC into the Zephyr build system (#1158) Signed-off-by: Furkan Akkiz --- Libraries/zephyr/MAX/Include/wrap_max32_adc.h | 3 +- Libraries/zephyr/MAX/Include/wrap_max32_i2c.h | 2 +- Libraries/zephyr/MAX/Include/wrap_max32_lp.h | 2 +- Libraries/zephyr/MAX/Include/wrap_max32_owm.h | 3 +- Libraries/zephyr/MAX/Include/wrap_max32_spi.h | 2 +- Libraries/zephyr/MAX/Include/wrap_max32_sys.h | 7 +- Libraries/zephyr/MAX/Include/wrap_max32_tmr.h | 7 +- .../zephyr/MAX/Include/wrap_max32_trng.h | 2 +- .../zephyr/MAX/Include/wrap_max32_uart.h | 2 +- Libraries/zephyr/MAX/Include/wrap_max32_wdt.h | 2 +- .../zephyr/MAX/Source/MAX78002/CMakeLists.txt | 183 ++++++++++++++++++ .../MAX/Source/MAX78002/max78xxx_system.c | 24 +++ 12 files changed, 228 insertions(+), 11 deletions(-) create mode 100644 Libraries/zephyr/MAX/Source/MAX78002/CMakeLists.txt create mode 100644 Libraries/zephyr/MAX/Source/MAX78002/max78xxx_system.c diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_adc.h b/Libraries/zephyr/MAX/Include/wrap_max32_adc.h index aa1a4140f7c..acd90ab080c 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_adc.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_adc.h @@ -153,7 +153,8 @@ static inline void Wrap_MXC_ADC_GetData(uint16_t **outdata) /* * MAX32690, related mapping */ -#elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) +#elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || \ + (CONFIG_SOC_MAX78002) #define WRAP_MXC_F_ADC_CONV_DONE_IE MXC_F_ADC_INTEN_SEQ_DONE #define WRAP_MXC_F_ADC_CONV_DONE_IF MXC_F_ADC_INTFL_SEQ_DONE diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_i2c.h b/Libraries/zephyr/MAX/Include/wrap_max32_i2c.h index 4437a6f43a5..b3a23108489 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_i2c.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_i2c.h @@ -130,7 +130,7 @@ static inline void Wrap_MXC_I2C_Stop(mxc_i2c_regs_t *i2c) */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) /* * Control register bits */ diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_lp.h b/Libraries/zephyr/MAX/Include/wrap_max32_lp.h index e68c3fc396b..2f3281f31eb 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_lp.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_lp.h @@ -56,7 +56,7 @@ static inline void Wrap_MXC_LP_EnterPowerDownMode(void) * MAX32690, MAX32655 related mapping */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32680) || \ - (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) static inline void Wrap_MXC_LP_EnterLowPowerMode(void) { diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_owm.h b/Libraries/zephyr/MAX/Include/wrap_max32_owm.h index e462abb4e3a..21d5528e443 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_owm.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_owm.h @@ -40,7 +40,8 @@ static inline int Wrap_MXC_OWM_Init(const mxc_owm_cfg_t *cfg) /* * MAX32690, MAX32655 related mapping */ -#elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32680) +#elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32680) || \ + (CONFIG_SOC_MAX78002) static inline int Wrap_MXC_OWM_Init(const mxc_owm_cfg_t *cfg) { diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_spi.h b/Libraries/zephyr/MAX/Include/wrap_max32_spi.h index 42694d25b33..bf2acbc9d11 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_spi.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_spi.h @@ -75,7 +75,7 @@ static inline int Wrap_MXC_SPI_Init(mxc_spi_regs_t *spi, int masterMode, int qua */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) #if defined(CONFIG_SOC_MAX32657) #define ADI_MAX32_SPI_CTRL_MASTER_MODE MXC_F_SPI_CTRL0_CONT_MODE #else diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_sys.h b/Libraries/zephyr/MAX/Include/wrap_max32_sys.h index 289c16b91e8..a1d3d14b9cd 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_sys.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_sys.h @@ -56,10 +56,15 @@ static inline void Wrap_MXC_SYS_SetClockDiv(int div) */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) #define ADI_MAX32_CLK_IPO MXC_SYS_CLOCK_IPO +#if defined(CONFIG_SOC_MAX78002) +#define ADI_MAX32_CLK_IPLL MXC_SYS_CLOCK_IPLL +#define ADI_MAX32_CLK_EBO MXC_SYS_CLOCK_EBO +#else #define ADI_MAX32_CLK_ERFO MXC_SYS_CLOCK_ERFO +#endif #define ADI_MAX32_CLK_IBRO MXC_SYS_CLOCK_IBRO #define ADI_MAX32_CLK_INRO MXC_SYS_CLOCK_INRO #define ADI_MAX32_CLK_ERTCO MXC_SYS_CLOCK_ERTCO diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_tmr.h b/Libraries/zephyr/MAX/Include/wrap_max32_tmr.h index 4af417efc04..f3706dae731 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_tmr.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_tmr.h @@ -103,7 +103,7 @@ int Wrap_MXC_TMR_GetPendingInt(mxc_tmr_regs_t *tmr) */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) #if defined(CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32675) || (CONFIG_SOC_MAX32657) /* All timers are 32bits */ @@ -142,13 +142,16 @@ static inline int Wrap_MXC_TMR_GetClockIndex(int z_clock) return MXC_TMR_EXT_CLK; case 2: // ADI_MAX32_PRPH_CLK_SRC_IBRO return MXC_TMR_8M_CLK; +#if !defined(CONFIG_SOC_MAX78002) case 3: //ADI_MAX32_PRPH_CLK_SRC_ERFO return MXC_TMR_32M_CLK; +#endif case 4: //ADI_MAX32_PRPH_CLK_SRC_ERTCO return MXC_TMR_32K_CLK; case 5: //ADI_MAX32_PRPH_CLK_SRC_INRO return MXC_TMR_INRO_CLK; -#if defined(CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32690) +#if defined(CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32690) || \ + (CONFIG_SOC_MAX78002) case 6: //ADI_MAX32_PRPH_CLK_SRC_ISO return MXC_TMR_ISO_CLK; #endif diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_trng.h b/Libraries/zephyr/MAX/Include/wrap_max32_trng.h index 84fdc24fbc8..b9f3a72e3ac 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_trng.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_trng.h @@ -46,7 +46,7 @@ static inline int Wrap_MXC_TRNG_RandomInt_NonBlocking(uint32_t *data) */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) static inline int Wrap_MXC_TRNG_RandomInt_NonBlocking(uint32_t *data) { diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_uart.h b/Libraries/zephyr/MAX/Include/wrap_max32_uart.h index 8991a03be9b..713ec47a166 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_uart.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_uart.h @@ -119,7 +119,7 @@ static inline void Wrap_MXC_UART_DisableRxDMA(mxc_uart_regs_t *uart) */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) // status flags #define ADI_MAX32_UART_RX_EMPTY MXC_F_UART_STATUS_RX_EM #define ADI_MAX32_UART_TX_EMPTY MXC_F_UART_STATUS_TX_EM diff --git a/Libraries/zephyr/MAX/Include/wrap_max32_wdt.h b/Libraries/zephyr/MAX/Include/wrap_max32_wdt.h index 6fc4dca6813..07823afffac 100644 --- a/Libraries/zephyr/MAX/Include/wrap_max32_wdt.h +++ b/Libraries/zephyr/MAX/Include/wrap_max32_wdt.h @@ -85,7 +85,7 @@ static inline int Wrap_MXC_WDT_SelectClockSource(mxc_wdt_regs_t *wdt, uint32_t c */ #elif defined(CONFIG_SOC_MAX32690) || (CONFIG_SOC_MAX32655) || (CONFIG_SOC_MAX32670) || \ (CONFIG_SOC_MAX32672) || (CONFIG_SOC_MAX32662) || (CONFIG_SOC_MAX32675) || \ - (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) + (CONFIG_SOC_MAX32680) || (CONFIG_SOC_MAX32657) || (CONFIG_SOC_MAX78002) #define WRAP_MXC_F_WDT_CTRL_EN MXC_F_WDT_CTRL_EN diff --git a/Libraries/zephyr/MAX/Source/MAX78002/CMakeLists.txt b/Libraries/zephyr/MAX/Source/MAX78002/CMakeLists.txt new file mode 100644 index 00000000000..11839a856fd --- /dev/null +++ b/Libraries/zephyr/MAX/Source/MAX78002/CMakeLists.txt @@ -0,0 +1,183 @@ +############################################################################## +# +# Copyright (C) 2024 Analog Devices, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + + +if(NOT TARGET_REV) + # Default version A1, not actively use in driver but requires to be defined. + zephyr_compile_definitions(-DTARGET_REV=0x4131) +endif() + +zephyr_include_directories( + ${MSDK_PERIPH_SRC_DIR}/ADC + ${MSDK_PERIPH_SRC_DIR}/AES + ${MSDK_PERIPH_SRC_DIR}/CRC + ${MSDK_PERIPH_SRC_DIR}/DMA + ${MSDK_PERIPH_SRC_DIR}/FLC + ${MSDK_PERIPH_SRC_DIR}/GPIO + ${MSDK_PERIPH_SRC_DIR}/I2C + ${MSDK_PERIPH_SRC_DIR}/I2S + ${MSDK_PERIPH_SRC_DIR}/ICC + ${MSDK_PERIPH_SRC_DIR}/LP + ${MSDK_PERIPH_SRC_DIR}/LPCMP + ${MSDK_PERIPH_SRC_DIR}/OWM + ${MSDK_PERIPH_SRC_DIR}/PT + ${MSDK_PERIPH_SRC_DIR}/RTC + ${MSDK_PERIPH_SRC_DIR}/SPI + ${MSDK_PERIPH_SRC_DIR}/SDHC + ${MSDK_PERIPH_SRC_DIR}/SYS + ${MSDK_PERIPH_SRC_DIR}/TMR + ${MSDK_PERIPH_SRC_DIR}/TRNG + ${MSDK_PERIPH_SRC_DIR}/UART + ${MSDK_PERIPH_SRC_DIR}/WDT + ${MSDK_PERIPH_SRC_DIR}/WUT +) + +if(CONFIG_ARM) + zephyr_library_sources(${MSDK_CMSIS_DIR}/Source/system_max78002.c) + zephyr_library_sources(${MSDK_PERIPH_SRC_DIR}/SYS/mxc_lock.c) +elseif(CONFIG_RISCV) + zephyr_library_sources(${MSDK_CMSIS_DIR}/Source/system_riscv_max78002.c) +endif() + +zephyr_library_sources( + ./max78xxx_system.c + + ${MSDK_PERIPH_SRC_DIR}/ICC/icc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/ICC/icc_reva.c + + ${MSDK_PERIPH_SRC_DIR}/LP/lp_ai87.c + + ${MSDK_PERIPH_SRC_DIR}/LPCMP/lpcmp_ai87.c + ${MSDK_PERIPH_SRC_DIR}/LPCMP/lpcmp_reva.c + + ${MSDK_PERIPH_SRC_DIR}/SYS/mxc_assert.c + ${MSDK_PERIPH_SRC_DIR}/SYS/mxc_delay.c + ${MSDK_PERIPH_SRC_DIR}/SYS/pins_ai87.c + ${MSDK_PERIPH_SRC_DIR}/SYS/sys_ai87.c + + ${MSDK_PERIPH_SRC_DIR}/DMA/dma_ai87.c + ${MSDK_PERIPH_SRC_DIR}/DMA/dma_reva.c + + ${MSDK_PERIPH_SRC_DIR}/PT/pt_ai87.c + ${MSDK_PERIPH_SRC_DIR}/PT/pt_reva.c + + ${MSDK_PERIPH_SRC_DIR}/SDHC/sdhc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/SDHC/sdhc_reva.c + + ${MSDK_PERIPH_SRC_DIR}/WUT/wut_ai87.c + ${MSDK_PERIPH_SRC_DIR}/WUT/wut_reva.c +) + +if (CONFIG_ADC_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/ADC/adc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/ADC/adc_revb.c +) +endif() + +if (CONFIG_UART_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/UART/uart_common.c + ${MSDK_PERIPH_SRC_DIR}/UART/uart_ai87.c + ${MSDK_PERIPH_SRC_DIR}/UART/uart_revb.c +) +endif() + +if (CONFIG_GPIO_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/GPIO/gpio_common.c + ${MSDK_PERIPH_SRC_DIR}/GPIO/gpio_ai87.c + ${MSDK_PERIPH_SRC_DIR}/GPIO/gpio_reva.c +) +endif() + +if (CONFIG_SPI_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/SPI/spi_ai87.c + ${MSDK_PERIPH_SRC_DIR}/SPI/spi_reva1.c +) +endif() + +if (CONFIG_I2C_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/I2C/i2c_ai87.c + ${MSDK_PERIPH_SRC_DIR}/I2C/i2c_reva.c +) +endif() + +if (CONFIG_I2S_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/I2S/i2s_ai87.c + ${MSDK_PERIPH_SRC_DIR}/I2S/i2s_reva.c +) +endif() + +if (CONFIG_WDT_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/WDT/wdt_common.c + ${MSDK_PERIPH_SRC_DIR}/WDT/wdt_ai87.c + ${MSDK_PERIPH_SRC_DIR}/WDT/wdt_revb.c +) +endif() + +if (CONFIG_RTC_MAX32 OR CONFIG_COUNTER_RTC_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/RTC/rtc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/RTC/rtc_reva.c +) +endif() + +if (CONFIG_SOC_FLASH_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/FLC/flc_common.c + ${MSDK_PERIPH_SRC_DIR}/FLC/flc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/FLC/flc_reva.c +) +endif() + +if (CONFIG_PWM_MAX32 OR CONFIG_TIMER_MAX32 OR CONFIG_COUNTER_TIMER_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/TMR/tmr_common.c + ${MSDK_PERIPH_SRC_DIR}/TMR/tmr_ai87.c + ${MSDK_PERIPH_SRC_DIR}/TMR/tmr_revb.c +) +endif() + +if (CONFIG_ENTROPY_MAX32_TRNG) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/TRNG/trng_ai87.c + ${MSDK_PERIPH_SRC_DIR}/TRNG/trng_revb.c +) +endif() + +if (CONFIG_CRYPTO_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/AES/aes_ai87.c + ${MSDK_PERIPH_SRC_DIR}/AES/aes_revb.c + + ${MSDK_PERIPH_SRC_DIR}/CRC/crc_ai87.c + ${MSDK_PERIPH_SRC_DIR}/CRC/crc_reva.c +) +endif() + +if (CONFIG_W1_MAX32) +zephyr_library_sources( + ${MSDK_PERIPH_SRC_DIR}/OWM/owm_ai87.c + ${MSDK_PERIPH_SRC_DIR}/OWM/owm_reva.c +) +endif() diff --git a/Libraries/zephyr/MAX/Source/MAX78002/max78xxx_system.c b/Libraries/zephyr/MAX/Source/MAX78002/max78xxx_system.c new file mode 100644 index 00000000000..ac79d2afce9 --- /dev/null +++ b/Libraries/zephyr/MAX/Source/MAX78002/max78xxx_system.c @@ -0,0 +1,24 @@ +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#include "max78002.h" + +/* + * This function is called during boot up. + */ +void max32xx_system_init(void) {}