This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 31a915436ced8c3035c8eeea52fa9c95841cabf2
Author: dechao_gong <[email protected]>
AuthorDate: Wed Oct 28 10:20:53 2026 +0800

    arch/arm/rtl8730e: add CA32 RTC driver on /dev/rtc0
    
    Wire the shared Ameba RTC driver up on the AmebaSmart CA32 and register
    the clock at /dev/rtc0, with the one-shot alarm when RTC_ALARM is set.
    
    Chip specifics go in ameba_rtc_chip.h, as for the other Ameba chips:
      - The RTC interrupt is GIC SPI 12, NuttX IRQ 44.
      - APBPeriph_RTC is bit 19 and APBPeriph_RTC_CLOCK is bit 3 here,
        whereas both are bit 3 on RTL8721Dx.
    
    The AP ROM carries no RTC_* symbols, so compile the SDK's RAM-side
    fwlib ameba_rtc.c into libameba_fwlib.a, in both the make and the CMake
    builds.  The RTC has no board wiring; the board only calls
    ameba_rtc_initialize() from bring-up.  Add an rtc configuration with the
    alarm example.
    
    The scripts/Make.defs change only widens the --no-warn-mismatch
    condition; the CMake build gets the same flag from AMEBA_EXTRA_LIBS in
    arch/arm/src/rtl8730e/CMakeLists.txt, which this change already extends.
    [skip-cmake-parity]
    
    Verified on hardware: a cold start reads the build date, date -s sets
    the clock and it keeps counting, and a 5 second alarm fires on time.
    
    Signed-off-by: dechao_gong <[email protected]>
    Assisted-by: Claude <[email protected]>
---
 arch/arm/include/rtl8730e/irq.h                    |  1 +
 arch/arm/src/rtl8730e/CMakeLists.txt               | 27 +++++++-
 arch/arm/src/rtl8730e/Make.defs                    |  8 ++-
 arch/arm/src/rtl8730e/ameba_board.mk               |  5 ++
 arch/arm/src/rtl8730e/ameba_rtc_chip.h             | 62 ++++++++++++++++++
 .../rtl8730e/rtl8730e_evb/configs/rtc/defconfig    | 63 ++++++++++++++++++
 boards/arm/rtl8730e/rtl8730e_evb/scripts/Make.defs |  2 +-
 .../arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt   |  6 ++
 boards/arm/rtl8730e/rtl8730e_evb/src/Makefile      |  6 +-
 .../rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c   | 11 ++++
 .../arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h   |  4 ++
 .../src/{rtl8730e_evb.h => rtl8730e_rtc.c}         | 75 +++++++---------------
 12 files changed, 213 insertions(+), 57 deletions(-)

diff --git a/arch/arm/include/rtl8730e/irq.h b/arch/arm/include/rtl8730e/irq.h
index d0132e46a36..93fd50f9ea9 100644
--- a/arch/arm/include/rtl8730e/irq.h
+++ b/arch/arm/include/rtl8730e/irq.h
@@ -43,6 +43,7 @@
 
 #define RTL8730E_IRQ_TIMER2     34   /* GIC SPI 2:  TIM2 (LP basic timer) */
 #define RTL8730E_IRQ_TIMER3     35   /* GIC SPI 3:  TIM3 (LP basic timer) */
+#define RTL8730E_IRQ_RTC        44   /* GIC SPI 12: RTC */
 #define RTL8730E_IRQ_ADC        46   /* GIC SPI 14: ADC */
 #define RTL8730E_IRQ_IPC_AP     56   /* GIC SPI 24: CA32 AP-IPC (WHC WiFi) */
 #define RTL8730E_IRQ_UART0      82   /* GIC SPI 50: UART0 */
diff --git a/arch/arm/src/rtl8730e/CMakeLists.txt 
b/arch/arm/src/rtl8730e/CMakeLists.txt
index e4cbade7b2f..2addf032f64 100644
--- a/arch/arm/src/rtl8730e/CMakeLists.txt
+++ b/arch/arm/src/rtl8730e/CMakeLists.txt
@@ -144,6 +144,21 @@ if(CONFIG_AMEBA_ADC)
   endif()
 endif()
 
+if(CONFIG_AMEBA_RTC)
+  list(APPEND SRCS ${AMEBA_COMMON}/ameba_rtc.c)
+  if(NOT CONFIG_RTL8730E_FLASH_FS
+     AND NOT CONFIG_AMEBA_GPIO
+     AND NOT CONFIG_AMEBA_UART
+     AND NOT CONFIG_AMEBA_I2C
+     AND NOT CONFIG_AMEBA_SPI
+     AND NOT CONFIG_AMEBA_PWM
+     AND NOT CONFIG_AMEBA_TIMER
+     AND NOT CONFIG_AMEBA_WDG
+     AND NOT CONFIG_AMEBA_ADC)
+    list(APPEND SRCS rtl8730e_flash_stubs.c)
+  endif()
+endif()
+
 target_include_directories(arch PRIVATE ${AMEBA_COMMON})
 target_sources(arch PRIVATE ${SRCS})
 
@@ -230,7 +245,8 @@ if(CONFIG_RTL8730E_FLASH_FS
    OR CONFIG_AMEBA_SPI
    OR CONFIG_AMEBA_PWM
    OR CONFIG_AMEBA_TIMER
-   OR CONFIG_AMEBA_ADC)
+   OR CONFIG_AMEBA_ADC
+   OR CONFIG_AMEBA_RTC)
   set(AMEBA_FWLIB_SRCS
       ${AMEBA_SOC}/fwlib/ram_common/ameba_arch.c ${AMEBA_SOC}/swlib/log.c
       ${AMEBA_SOC}/swlib/sscanf_minimal.c)
@@ -276,6 +292,11 @@ if(CONFIG_RTL8730E_FLASH_FS
          ${AMEBA_SOC}/fwlib/ram_common/ameba_otp.c)
   endif()
 
+  # The AP ROM has no RTC either; the fwlib RTC layer is RAM-side.
+  if(CONFIG_AMEBA_RTC)
+    list(APPEND AMEBA_FWLIB_SRCS ${AMEBA_SOC}/fwlib/ram_common/ameba_rtc.c)
+  endif()
+
   # Silence SDK warnings, activate CA32 code paths.  No -mcmse (ARMv7-A).
   set(AMEBA_FWLIB_INC
       -Wno-int-conversion
@@ -319,6 +340,7 @@ if(CONFIG_AMEBA_GPIO
    OR CONFIG_AMEBA_TIMER
    OR CONFIG_AMEBA_WDG
    OR CONFIG_AMEBA_ADC
+   OR CONFIG_AMEBA_RTC
    OR CONFIG_RTL8730E_FLASH_FS)
   list(APPEND AMEBA_EXTRA_LIBS
        ${AMEBA_SOC}/project/${AMEBA_KM_PROJ}/lib/soc/lib_rom.a)
@@ -331,7 +353,8 @@ if(CONFIG_RTL8730E_FLASH_FS
    OR CONFIG_AMEBA_SPI
    OR CONFIG_AMEBA_PWM
    OR CONFIG_AMEBA_TIMER
-   OR CONFIG_AMEBA_ADC)
+   OR CONFIG_AMEBA_ADC
+   OR CONFIG_AMEBA_RTC)
   list(APPEND AMEBA_EXTRA_LIBS ${AMEBA_FWLIB_A})
 endif()
 
diff --git a/arch/arm/src/rtl8730e/Make.defs b/arch/arm/src/rtl8730e/Make.defs
index aef5babb761..6d0a1838700 100644
--- a/arch/arm/src/rtl8730e/Make.defs
+++ b/arch/arm/src/rtl8730e/Make.defs
@@ -65,7 +65,7 @@ AMEBA_AP_SOC_LIB = 
$(TOPDIR)/arch/arm/src/common/ameba/ameba-rtos/component/soc/
 # rtl8730e_flash_stubs.c supplies the RAM-side symbols that lib_rom.a objects
 # expect (DiagPrintfNano, irq_enable, Pinmux_Config, etc.).  Compile them once
 # whenever any driver needing ROM is enabled.
-ifneq ($(filter y,$(CONFIG_AMEBA_GPIO) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_WDG) $(CONFIG_AMEBA_ADC) 
$(CONFIG_RTL8730E_FLASH_FS)),)
+ifneq ($(filter y,$(CONFIG_AMEBA_GPIO) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_WDG) $(CONFIG_AMEBA_ADC) 
$(CONFIG_AMEBA_RTC) $(CONFIG_RTL8730E_FLASH_FS)),)
 CHIP_CSRCS += rtl8730e_flash_stubs.c
 EXTRA_LIBS += $(AMEBA_AP_SOC_LIB)$(DELIM)lib_rom.a
 
@@ -103,6 +103,10 @@ ifeq ($(CONFIG_AMEBA_ADC),y)
 CHIP_CSRCS += ameba_adc.c
 endif
 
+ifeq ($(CONFIG_AMEBA_RTC),y)
+CHIP_CSRCS += ameba_rtc.c
+endif
+
 # WiFi (WHC host, CA32 side).
 ifeq ($(CONFIG_RTL8730E_WIFI),y)
 CHIP_CSRCS += rtl8730e_wifi_init.c
@@ -133,7 +137,7 @@ endif
 
 # fwlib archive is needed whenever any driver uses RAM-side SDK tables
 # (flash MTD, UART, I2C, ...).  Link it once for all such configs.
-ifneq ($(filter y,$(CONFIG_RTL8730E_FLASH_FS) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_ADC)),)
+ifneq ($(filter y,$(CONFIG_RTL8730E_FLASH_FS) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_ADC) $(CONFIG_AMEBA_RTC)),)
 
 # Prebuilt staging area (within the board tree, gitignored).
 AMEBA_PREBUILT      = $(BOARD_DIR)$(DELIM)prebuilt
diff --git a/arch/arm/src/rtl8730e/ameba_board.mk 
b/arch/arm/src/rtl8730e/ameba_board.mk
index bc461d4c02d..e0d5c7aa9cb 100644
--- a/arch/arm/src/rtl8730e/ameba_board.mk
+++ b/arch/arm/src/rtl8730e/ameba_board.mk
@@ -105,6 +105,11 @@ AMEBA_FWLIB_SRCS += 
$(AMEBA_SOC)/fwlib/ram_common/ameba_adc.c
 AMEBA_FWLIB_SRCS += $(AMEBA_SOC)/fwlib/ram_common/ameba_otp.c
 endif
 
+# The AP ROM has no RTC either; the fwlib RTC layer is RAM-side.
+ifeq ($(CONFIG_AMEBA_RTC),y)
+AMEBA_FWLIB_SRCS += $(AMEBA_SOC)/fwlib/ram_common/ameba_rtc.c
+endif
+
 # Include paths scoped to the fwlib compile only (never leaked to NuttX core).
 # -DCONFIG_ARM_CORE_CA32 activates the CA32 code paths in ameba_flash_ram.c.
 # No -mcmse (that is Cortex-M33 TrustZone; CA32 is ARMv7-A non-secure EL1).
diff --git a/arch/arm/src/rtl8730e/ameba_rtc_chip.h 
b/arch/arm/src/rtl8730e/ameba_rtc_chip.h
new file mode 100644
index 00000000000..e73f6b11c47
--- /dev/null
+++ b/arch/arm/src/rtl8730e/ameba_rtc_chip.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * arch/arm/src/rtl8730e/ameba_rtc_chip.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_RTL8730E_AMEBA_RTC_CHIP_H
+#define __ARCH_ARM_SRC_RTL8730E_AMEBA_RTC_CHIP_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/irq.h>
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Per-chip RTC wiring for RTL8730E (AmebaSmart, CA32).  The shared driver
+ * (arch/arm/src/common/ameba/ameba_rtc.c) reads only the macros below.  The
+ * fwlib RTC layer is RAM-side here (the AP ROM has no RTC_*) and addresses
+ * the always-on block at RTC_BASE (0x4200e000) itself, so no register base
+ * appears in this header.
+ *
+ * The RTC interrupt is GIC SPI 12 (SDK ameba_vector_table.h, CA32 section),
+ * i.e. NuttX IRQ 12 + 32.
+ */
+
+#define AMEBA_RTC_IRQ             RTL8730E_IRQ_RTC
+
+/* APBPeriph_RTC (function, bit 19) and APBPeriph_RTC_CLOCK (bit 3) from the
+ * SDK sysreg_aon.h; unlike RTL8721Dx the two masks differ here.
+ */
+
+#define AMEBA_RTC_APBPERIPH       (((uint32_t)3 << 30) | ((uint32_t)1 << 19))
+#define AMEBA_RTC_APBPERIPH_CLK   (((uint32_t)3 << 30) | ((uint32_t)1 << 3))
+
+/* Calendar base year of RTC_TimeTypeDef.RTC_Year (RTC_BASE_YEAR). */
+
+#define AMEBA_RTC_BASE_YEAR       1900
+
+#endif /* __ARCH_ARM_SRC_RTL8730E_AMEBA_RTC_CHIP_H */
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/configs/rtc/defconfig 
b/boards/arm/rtl8730e/rtl8730e_evb/configs/rtc/defconfig
new file mode 100644
index 00000000000..15c6a74146a
--- /dev/null
+++ b/boards/arm/rtl8730e/rtl8730e_evb/configs/rtc/defconfig
@@ -0,0 +1,63 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_NSH_DISABLE_MB is not set
+# CONFIG_NSH_DISABLE_MH is not set
+# CONFIG_NSH_DISABLE_MW is not set
+CONFIG_ALARM_ARCH=y
+CONFIG_AMEBA_RTC=y
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="rtl8730e_evb"
+CONFIG_ARCH_BOARD_RTL8730E_EVB=y
+CONFIG_ARCH_CHIP="rtl8730e"
+CONFIG_ARCH_CHIP_RTL8730E=y
+CONFIG_ARCH_CHIP_RTL8730E_CA32=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_LOWVECTORS=y
+CONFIG_ARM_PSCI=y
+CONFIG_BOARD_LOOPSPERMSEC=393693
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_ASSERTIONS=y
+CONFIG_DEBUG_FEATURES=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEFAULT_TASK_STACKSIZE=4096
+CONFIG_EXAMPLES_ALARM=y
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_FLASH_SIZE=1048576
+CONFIG_FLASH_START=0x60300000
+CONFIG_FLASH_VSTART=0x60300000
+CONFIG_FS_PROCFS=y
+CONFIG_FS_TMPFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_LIBC_MEMFD_ERROR=y
+CONFIG_MM_DEFAULT_ALIGNMENT=64
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_PRIORITY_INHERITANCE=y
+CONFIG_RAM_SIZE=3145728
+CONFIG_RAM_START=0x60400000
+CONFIG_RAM_VSTART=0x60400000
+CONFIG_RAW_BINARY=y
+CONFIG_READLINE_CMD_HISTORY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC_ALARM=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_HPWORKPRIORITY=192
+CONFIG_SMP=y
+CONFIG_SMP_NCPUS=2
+CONFIG_STACK_COLORATION=y
+CONFIG_START_DAY=28
+CONFIG_START_MONTH=10
+CONFIG_START_YEAR=2026
+CONFIG_SYSTEM_NSH=y
+CONFIG_USEC_PER_TICK=1000
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/scripts/Make.defs 
b/boards/arm/rtl8730e/rtl8730e_evb/scripts/Make.defs
index 88090db7424..f4c798e90cb 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/scripts/Make.defs
+++ b/boards/arm/rtl8730e/rtl8730e_evb/scripts/Make.defs
@@ -62,7 +62,7 @@ include 
$(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)rtl8730e$(DELIM)ameba
 # lib_rom.a and the RTK toolchain's libgcc.a are compiled without VFP ABI
 # flags; suppress the harmless mismatch so the linker does not abort on it
 # whenever libameba_fwlib.a is in the link (GPIO, WiFi, or flash-FS config).
-ifneq ($(filter y,$(CONFIG_AMEBA_GPIO) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_WDG) $(CONFIG_AMEBA_ADC) 
$(CONFIG_RTL8730E_WIFI) $(CONFIG_RTL8730E_FLASH_FS)),)
+ifneq ($(filter y,$(CONFIG_AMEBA_GPIO) $(CONFIG_AMEBA_UART) 
$(CONFIG_AMEBA_I2C) $(CONFIG_AMEBA_SPI) $(CONFIG_AMEBA_PWM) 
$(CONFIG_AMEBA_TIMER) $(CONFIG_AMEBA_WDG) $(CONFIG_AMEBA_ADC) 
$(CONFIG_AMEBA_RTC) $(CONFIG_RTL8730E_WIFI) $(CONFIG_RTL8730E_FLASH_FS)),)
 LDFLAGS += --no-warn-mismatch
 endif
 
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt 
b/boards/arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt
index 1bdd8a58a35..4c84c466b89 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt
+++ b/boards/arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt
@@ -69,6 +69,12 @@ if(CONFIG_AMEBA_ADC)
                              PRIVATE ${NUTTX_DIR}/arch/arm/src/common/ameba)
 endif()
 
+if(CONFIG_AMEBA_RTC)
+  list(APPEND SRCS rtl8730e_rtc.c)
+  target_include_directories(board
+                             PRIVATE ${NUTTX_DIR}/arch/arm/src/common/ameba)
+endif()
+
 if(CONFIG_LIBC_FDT)
   target_include_directories(board
                              PRIVATE ${NUTTX_DIR}/libs/libc/fdt/dtc/libfdt)
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/src/Makefile 
b/boards/arm/rtl8730e/rtl8730e_evb/src/Makefile
index 619b895ea93..1d93a6ac230 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/src/Makefile
+++ b/boards/arm/rtl8730e/rtl8730e_evb/src/Makefile
@@ -34,7 +34,7 @@ ifeq ($(CONFIG_LIBC_FDT),y)
 CFLAGS += 
${INCDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)fdt$(DELIM)dtc$(DELIM)libfdt
 endif
 
-ifneq 
($(CONFIG_RTL8730E_FLASH_FS)$(CONFIG_AMEBA_GPIO)$(CONFIG_AMEBA_UART)$(CONFIG_AMEBA_I2C)$(CONFIG_AMEBA_SPI)$(CONFIG_AMEBA_PWM)$(CONFIG_AMEBA_TIMER)$(CONFIG_AMEBA_WDG)$(CONFIG_AMEBA_ADC),)
+ifneq 
($(CONFIG_RTL8730E_FLASH_FS)$(CONFIG_AMEBA_GPIO)$(CONFIG_AMEBA_UART)$(CONFIG_AMEBA_I2C)$(CONFIG_AMEBA_SPI)$(CONFIG_AMEBA_PWM)$(CONFIG_AMEBA_TIMER)$(CONFIG_AMEBA_WDG)$(CONFIG_AMEBA_ADC)$(CONFIG_AMEBA_RTC),)
 CFLAGS += 
${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)common$(DELIM)ameba
 endif
 
@@ -70,4 +70,8 @@ ifeq ($(CONFIG_AMEBA_ADC),y)
 CSRCS += rtl8730e_adc.c
 endif
 
+ifeq ($(CONFIG_AMEBA_RTC),y)
+CSRCS += rtl8730e_rtc.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c 
b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c
index 72e0fa0805a..3a0af9a3489 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c
+++ b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c
@@ -326,6 +326,17 @@ int rtl8730e_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_AMEBA_RTC
+  /* Register the on-chip RTC at /dev/rtc0. */
+
+  ret = rtl8730e_rtc_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR,
+             "ERROR: Failed to initialize RTC: %d\n", ret);
+    }
+#endif
+
   UNUSED(ret);
   return OK;
 }
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h 
b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
index a6b84bf8839..c5650fffcd3 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
+++ b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
@@ -89,5 +89,9 @@ int rtl8730e_wdg_initialize(void);
 int rtl8730e_adc_initialize(void);
 #endif
 
+#ifdef CONFIG_AMEBA_RTC
+int rtl8730e_rtc_initialize(void);
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* __BOARDS_ARM_RTL8730E_RTL8730E_EVB_SRC_RTL8730E_EVB_H */
diff --git a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h 
b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_rtc.c
similarity index 52%
copy from boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
copy to boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_rtc.c
index a6b84bf8839..591047517d6 100644
--- a/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
+++ b/boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_rtc.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_evb.h
+ * boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_rtc.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -20,74 +20,47 @@
  *
  ****************************************************************************/
 
-#ifndef __BOARDS_ARM_RTL8730E_RTL8730E_EVB_SRC_RTL8730E_EVB_H
-#define __BOARDS_ARM_RTL8730E_RTL8730E_EVB_SRC_RTL8730E_EVB_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
 #include <nuttx/config.h>
 
-#include <stdint.h>
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
+#include <syslog.h>
+#include <errno.h>
 
-/****************************************************************************
- * Public Data
- ****************************************************************************/
+#include "ameba_rtc.h"
+#include "rtl8730e_evb.h"
 
-#ifndef __ASSEMBLY__
+#ifdef CONFIG_AMEBA_RTC
 
 /****************************************************************************
- * Public Functions Definitions
+ * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: rtl8730e_bringup
+ * Name: rtl8730e_rtc_initialize
  *
  * Description:
- *   Bring up board features
+ *   Bring up the on-chip RTC and register it at /dev/rtc0.  The RTC has no
+ *   board wiring (it is an internal clock), so this simply defers to the
+ *   shared driver.
  *
  ****************************************************************************/
 
-#if defined(CONFIG_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE)
-int rtl8730e_bringup(void);
-#endif
-
-#ifdef CONFIG_AMEBA_GPIO
-int rtl8730e_gpio_initialize(void);
-#endif
-
-#ifdef CONFIG_AMEBA_UART
-int rtl8730e_uart_initialize(void);
-#endif
-
-#ifdef CONFIG_AMEBA_I2C
-int rtl8730e_i2c_initialize(void);
-#endif
-
-#ifdef CONFIG_AMEBA_SPI
-int rtl8730e_spi_initialize(void);
-#endif
-
-#ifdef CONFIG_AMEBA_PWM
-int rtl8730e_pwm_initialize(void);
-#endif
-
-#ifdef CONFIG_AMEBA_TIMER
-int rtl8730e_timer_initialize(void);
-#endif
+int rtl8730e_rtc_initialize(void)
+{
+  int ret;
 
-#ifdef CONFIG_AMEBA_WDG
-int rtl8730e_wdg_initialize(void);
-#endif
+  ret = ameba_rtc_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR,
+             "ERROR: ameba_rtc_initialize(/dev/rtc0) failed: %d\n", ret);
+      return ret;
+    }
 
-#ifdef CONFIG_AMEBA_ADC
-int rtl8730e_adc_initialize(void);
-#endif
+  return OK;
+}
 
-#endif /* __ASSEMBLY__ */
-#endif /* __BOARDS_ARM_RTL8730E_RTL8730E_EVB_SRC_RTL8730E_EVB_H */
+#endif /* CONFIG_AMEBA_RTC */

Reply via email to