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

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

commit 060ac93f8284304c54c1a9913c3f91fa23da3955
Author: xuxingliang <[email protected]>
AuthorDate: Thu Jul 11 22:57:12 2024 +0800

    arm64: allow to use custom up_timer_initialize
    
    Signed-off-by: xuxingliang <[email protected]>
---
 arch/arm64/src/a64/Make.defs                       |  2 +-
 .../{common/arm64_arch_timer.h => a64/a64_timer.c} | 30 +++-----
 arch/arm64/src/common/arm64_arch_timer.c           | 80 +++++-----------------
 arch/arm64/src/common/arm64_arch_timer.h           | 30 ++++----
 arch/arm64/src/common/arm64_cpustart.c             |  3 -
 arch/arm64/src/fvp-v8r/Make.defs                   |  2 +-
 .../arm64_arch_timer.h => fvp-v8r/fvp_timer.c}     | 30 +++-----
 arch/arm64/src/goldfish/Make.defs                  |  2 +-
 .../goldfish_timer.c}                              | 30 +++-----
 arch/arm64/src/imx8/Make.defs                      |  2 +-
 .../arm64_arch_timer.h => imx8/imx8_timer.c}       | 30 +++-----
 arch/arm64/src/imx9/Make.defs                      |  3 +-
 .../arm64_arch_timer.h => imx9/imx9_timer.c}       | 30 +++-----
 arch/arm64/src/qemu/CMakeLists.txt                 |  2 +-
 arch/arm64/src/qemu/Make.defs                      |  2 +
 .../arm64_arch_timer.h => qemu/qemu_timer.c}       | 30 +++-----
 arch/arm64/src/rk3399/Make.defs                    |  2 +-
 .../arm64_arch_timer.h => rk3399/rk3399_timer.c}   | 30 +++-----
 arch/arm64/src/zynq-mpsoc/Make.defs                |  2 +-
 .../arm64_arch_timer.h => zynq-mpsoc/zynq_timer.c} | 30 +++-----
 20 files changed, 108 insertions(+), 264 deletions(-)

diff --git a/arch/arm64/src/a64/Make.defs b/arch/arm64/src/a64/Make.defs
index e0fdcc69b5..e3a239f14f 100644
--- a/arch/arm64/src/a64/Make.defs
+++ b/arch/arm64/src/a64/Make.defs
@@ -21,7 +21,7 @@
 include common/Make.defs
 
 # Allwinner A64 specific C source files
-CHIP_CSRCS  = a64_boot.c a64_pio.c a64_serial.c a64_twi.c
+CHIP_CSRCS  = a64_boot.c a64_pio.c a64_serial.c a64_twi.c a64_timer.c
 
 ifeq ($(CONFIG_A64_DE),y)
 CHIP_CSRCS += a64_de.c
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/a64/a64_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/a64/a64_timer.c
index 691e429ca2..878fed7725 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/a64/a64_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/a64/a64_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/common/arm64_arch_timer.c 
b/arch/arm64/src/common/arm64_arch_timer.c
index ce7e4dda02..39f0923b42 100644
--- a/arch/arm64/src/common/arm64_arch_timer.c
+++ b/arch/arm64/src/common/arm64_arch_timer.c
@@ -38,6 +38,19 @@
 #include "arm64_gic.h"
 #include "arm64_arch_timer.h"
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
+#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
+#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
+#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+
+#define ARM_ARCH_TIMER_IRQ                  CONFIG_ARM_TIMER_VIRTUAL_IRQ
+#define ARM_ARCH_TIMER_PRIO                 IRQ_DEFAULT_PRIORITY
+#define ARM_ARCH_TIMER_FLAGS                IRQ_TYPE_LEVEL
+
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -306,6 +319,10 @@ static const struct oneshot_operations_s g_oneshot_ops =
   .tick_cancel    = arm64_tick_cancel,
 };
 
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
 /****************************************************************************
  * Name: oneshot_initialize
  *
@@ -319,7 +336,7 @@ static const struct oneshot_operations_s g_oneshot_ops =
  *
  ****************************************************************************/
 
-static struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void)
+struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void)
 {
   struct arm64_oneshot_lowerhalf_s *priv;
 
@@ -360,64 +377,3 @@ static struct oneshot_lowerhalf_s 
*arm64_oneshot_initialize(void)
 
   return &priv->lh;
 }
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function:  up_timer_initialize
- *
- * Description:
- *   This function is called during start-up to initialize the system timer
- *   interrupt.
- *
- ****************************************************************************/
-
-void up_timer_initialize(void)
-{
-  uint64_t freq;
-
-  freq = arm64_arch_timer_get_cntfrq();
-  tmrinfo("%s: cp15 timer(s) running at %" PRIu64 ".%" PRIu64 "MHz\n",
-          __func__, freq / 1000000, (freq / 10000) % 100);
-
-  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
-}
-
-#ifdef CONFIG_SMP
-/****************************************************************************
- * Function:  arm64_arch_timer_secondary_init
- *
- * Description:
- *   This function is called during start-up to initialize the system timer
- *   interrupt for smp.
- *
- * Notes:
- * The origin design for ARMv8-A timer is assigned private timer to
- * every PE(CPU core), the ARM_ARCH_TIMER_IRQ is a PPI so it's
- * should be enable at every core.
- *
- * But for NuttX, it's design only for primary core to handle timer
- * interrupt and call nxsched_process_timer at timer tick mode.
- * So we need only enable timer for primary core
- *
- * IMX6 use GPT which is a SPI rather than generic timer to handle
- * timer interrupt
- ****************************************************************************/
-
-void arm64_arch_timer_secondary_init()
-{
-#ifdef CONFIG_SCHED_TICKLESS
-  tmrinfo("arm64_arch_timer_secondary_init\n");
-
-  /* Enable int */
-
-  up_enable_irq(ARM_ARCH_TIMER_IRQ);
-
-  /* Start timer */
-
-  arm64_arch_timer_enable(true);
-#endif
-}
-#endif
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/common/arm64_arch_timer.h
index 691e429ca2..12276004a7 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/common/arm64_arch_timer.h
@@ -25,26 +25,26 @@
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
+#include <nuttx/config.h>
+#include <nuttx/timers/oneshot.h>
 
 /****************************************************************************
- * Pre-processor Definitions
+ * Public Function Prototypes
  ****************************************************************************/
 
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
-
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
-
 /****************************************************************************
- * Public Function Prototypes
+ * Name: arm64_oneshot_initialize
+ *
+ * Description:
+ *   This function initialize generic timer hardware module
+ *   and return an instance of a "lower half" timer interface.
+ *
+ * Returned Value:
+ *   On success, a non-NULL oneshot_lowerhalf_s is returned to the caller.
+ *   In the event of any failure, a NULL value is returned.
+ *
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
+
+struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void);
 
 #endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
diff --git a/arch/arm64/src/common/arm64_cpustart.c 
b/arch/arm64/src/common/arm64_cpustart.c
index bee962f99c..05fb736143 100644
--- a/arch/arm64/src/common/arm64_cpustart.c
+++ b/arch/arm64/src/common/arm64_cpustart.c
@@ -232,10 +232,7 @@ void arm64_boot_secondary_c_routine(void)
 
   arm64_gic_secondary_init();
 
-  arm64_arch_timer_secondary_init();
-
   up_perf_init(NULL);
 
   arm64_smp_init_top();
 }
-
diff --git a/arch/arm64/src/fvp-v8r/Make.defs b/arch/arm64/src/fvp-v8r/Make.defs
index c314e8d139..8151dd063a 100644
--- a/arch/arm64/src/fvp-v8r/Make.defs
+++ b/arch/arm64/src/fvp-v8r/Make.defs
@@ -21,7 +21,7 @@
 include common/Make.defs
 
 # fvp-specific C source files
-CHIP_CSRCS  = fvp_boot.c fvp_serial.c
+CHIP_CSRCS  = fvp_boot.c fvp_serial.c fvp_timer.c
 
 ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
 CHIP_ASRCS  += fvp_lowputc.S
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/fvp-v8r/fvp_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/fvp-v8r/fvp_timer.c
index 691e429ca2..8f188fee53 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/fvp-v8r/fvp_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/fvp-v8r/fvp_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/goldfish/Make.defs 
b/arch/arm64/src/goldfish/Make.defs
index 67bae71105..837cf3b293 100644
--- a/arch/arm64/src/goldfish/Make.defs
+++ b/arch/arm64/src/goldfish/Make.defs
@@ -21,7 +21,7 @@
 include common/Make.defs
 
 # qemu-specific C source files
-CHIP_CSRCS = goldfish_boot.c goldfish_serial.c
+CHIP_CSRCS = goldfish_boot.c goldfish_serial.c goldfish_timer.c
 
 ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
 CHIP_ASRCS = goldfish_lowputc.S
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/goldfish/goldfish_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/goldfish/goldfish_timer.c
index 691e429ca2..4842d4a90f 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/goldfish/goldfish_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/goldfish/goldfish_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/imx8/Make.defs b/arch/arm64/src/imx8/Make.defs
index 196f65b543..3d71a05d35 100644
--- a/arch/arm64/src/imx8/Make.defs
+++ b/arch/arm64/src/imx8/Make.defs
@@ -22,7 +22,7 @@ include common/Make.defs
 
 # i.MX8-specific C source files
 
-CHIP_CSRCS  = imx8_boot.c
+CHIP_CSRCS  = imx8_boot.c imx8_timer.c
 
 ifeq ($(CONFIG_ARCH_CHIP_IMX8_QUADMAX),y)
   CHIP_CSRCS += imx8qm_serial.c
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/imx8/imx8_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/imx8/imx8_timer.c
index 691e429ca2..43fdaa8dab 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/imx8/imx8_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/imx8/imx8_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/imx9/Make.defs b/arch/arm64/src/imx9/Make.defs
index 58676f1641..6cb5db086a 100644
--- a/arch/arm64/src/imx9/Make.defs
+++ b/arch/arm64/src/imx9/Make.defs
@@ -22,7 +22,8 @@ include common/Make.defs
 
 # i.MX9-specific C source files
 
-CHIP_CSRCS = imx9_boot.c imx9_ccm.c imx9_clockconfig.c imx9_gpio.c 
imx9_iomuxc.c
+CHIP_CSRCS  = imx9_boot.c imx9_ccm.c imx9_clockconfig.c imx9_gpio.c
+CHIP_CSRCS += imx9_iomuxc.c imx9_timer.c
 
 ifeq ($(CONFIG_ARCH_CHIP_IMX93),y)
   CHIP_CSRCS += imx9_lpuart.c imx9_lowputc.c
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/imx9/imx9_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/imx9/imx9_timer.c
index 691e429ca2..30a3c87509 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/imx9/imx9_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/imx9/imx9_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/qemu/CMakeLists.txt 
b/arch/arm64/src/qemu/CMakeLists.txt
index 7c83bec2d2..24890840e9 100644
--- a/arch/arm64/src/qemu/CMakeLists.txt
+++ b/arch/arm64/src/qemu/CMakeLists.txt
@@ -17,7 +17,7 @@
 # the License.
 #
 # 
##############################################################################
-set(SRCS qemu_boot.c qemu_serial.c)
+set(SRCS qemu_boot.c qemu_serial.c qemu_timer.c)
 
 if(CONFIG_ARCH_EARLY_PRINT)
   list(APPEND SRCS qemu_lowputc.S)
diff --git a/arch/arm64/src/qemu/Make.defs b/arch/arm64/src/qemu/Make.defs
index 0816edca2d..5457974eab 100644
--- a/arch/arm64/src/qemu/Make.defs
+++ b/arch/arm64/src/qemu/Make.defs
@@ -23,6 +23,8 @@ include common/Make.defs
 # qemu-specific C source files
 CHIP_CSRCS  = qemu_boot.c qemu_serial.c
 
+CHIP_CSRCS += qemu_timer.c
+
 ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
 CHIP_ASRCS  = qemu_lowputc.S
 endif
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/qemu/qemu_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/qemu/qemu_timer.c
index 691e429ca2..3e952cbd83 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/qemu/qemu_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/qemu/qemu_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/rk3399/Make.defs b/arch/arm64/src/rk3399/Make.defs
index ceb41df155..6a6efc45d1 100644
--- a/arch/arm64/src/rk3399/Make.defs
+++ b/arch/arm64/src/rk3399/Make.defs
@@ -21,7 +21,7 @@
 include common/Make.defs
 
 # Rockchip RK3399 specific C source files
-CHIP_CSRCS  = rk3399_boot.c rk3399_serial.c
+CHIP_CSRCS  = rk3399_boot.c rk3399_serial.c rk3399_timer.c
 
 ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
 CHIP_ASRCS  = rk3399_lowputc.S
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/rk3399/rk3399_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/rk3399/rk3399_timer.c
index 691e429ca2..574bdd8ebd 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/rk3399/rk3399_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/rk3399/rk3399_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}
diff --git a/arch/arm64/src/zynq-mpsoc/Make.defs 
b/arch/arm64/src/zynq-mpsoc/Make.defs
index 4c857c4e59..8c5e5dc28c 100644
--- a/arch/arm64/src/zynq-mpsoc/Make.defs
+++ b/arch/arm64/src/zynq-mpsoc/Make.defs
@@ -21,7 +21,7 @@
 include common/Make.defs
 
 # Rockchip zynq mpsoc specific C source files
-CHIP_CSRCS  = zynq_boot.c zynq_serial.c zynq_mio.c
+CHIP_CSRCS  = zynq_boot.c zynq_serial.c zynq_mio.c zynq_timer.c
 
 ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
 CHIP_ASRCS  = zynq_lowputc.S
diff --git a/arch/arm64/src/common/arm64_arch_timer.h 
b/arch/arm64/src/zynq-mpsoc/zynq_timer.c
similarity index 57%
copy from arch/arm64/src/common/arm64_arch_timer.h
copy to arch/arm64/src/zynq-mpsoc/zynq_timer.c
index 691e429ca2..96ad1e860b 100644
--- a/arch/arm64/src/common/arm64_arch_timer.h
+++ b/arch/arm64/src/zynq-mpsoc/zynq_timer.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm64/src/common/arm64_arch_timer.h
+ * arch/arm64/src/zynq-mpsoc/zynq_timer.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,33 +18,19 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-#define __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
-#include "arm64_gic.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define CONFIG_ARM_TIMER_SECURE_IRQ         (GIC_PPI_INT_BASE + 13)
-#define CONFIG_ARM_TIMER_NON_SECURE_IRQ     (GIC_PPI_INT_BASE + 14)
-#define CONFIG_ARM_TIMER_VIRTUAL_IRQ        (GIC_PPI_INT_BASE + 11)
-#define CONFIG_ARM_TIMER_HYP_IRQ            (GIC_PPI_INT_BASE + 10)
+#include <nuttx/timers/arch_alarm.h>
 
-#define ARM_ARCH_TIMER_IRQ     CONFIG_ARM_TIMER_VIRTUAL_IRQ
-#define ARM_ARCH_TIMER_PRIO    IRQ_DEFAULT_PRIORITY
-#define ARM_ARCH_TIMER_FLAGS   IRQ_TYPE_LEVEL
+#include "arm64_arch_timer.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Public Functions
  ****************************************************************************/
-#ifdef CONFIG_SMP
-void arm64_arch_timer_secondary_init(void);
-#endif
 
-#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */
+void up_timer_initialize(void)
+{
+  up_alarm_set_lowerhalf(arm64_oneshot_initialize());
+}

Reply via email to