s5j/timerisr: use RTC as an OS time tick
authorHeesub Shin <heesub.shin@samsung.com>
Mon, 3 Apr 2017 00:18:44 +0000 (09:18 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:05 +0000 (12:02 +0900)
Using the MCT as an OS systick timer by reserving a local timer seems
overkill. For such purpose, S5J provides the RTC tick counter and using
using it seems more appropriate. This commit configures it as an OS time
tick instead of MCT local timer.

This is a preparation step for redesigning the MCT driver. It does not
introduce any functional differences except changing the tick source.

Change-Id: Ic0f9a20c7d10fee7451c2c0a5857af6c19b07fbf
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
os/arch/arm/src/artik053/include/board.h
os/arch/arm/src/s5j/s5j_timerisr.c
os/arch/arm/src/sidk_s5jt200/include/board.h

index 198fc64..79df9f6 100644 (file)
@@ -53,6 +53,6 @@
 #ifndef __ARCH_ARM_SRC_ARTIK053_INCLUDE_BOARD_H__
 #define __ARCH_ARM_SRC_ARTIK053_INCLUDE_BOARD_H__
 
-#define SYSCLK_FREQUENCY 26000000 /* 26MHz */
+#define SYSCLK_FREQUENCY       32768 /* RTC clock at 32768Hz */
 
 #endif /* __ARCH_ARM_SRC_ARTIK053_INCLUDE_BOARD_H__ */
index b2c33d7..6625ac1 100644 (file)
@@ -60,6 +60,9 @@
 
 #include <arch/board/board.h>
 #include "chip.h"
+#include "up_arch.h"
+
+#include "s5j_rtc.h"
 
 /****************************************************************************
  * Pre-processor Definitions
  *   of the systems.
  *
  ****************************************************************************/
-int up_timerisr(int irq, uint32_t *regs, void *arg)
+int up_timerisr(int irq, FAR void *context, FAR void *arg)
 {
-       /* Reset timer */
-       s5j_mct_clear_pending(MCT_L0);
+       /* Clear interrupt pending */
+       putreg32(RTC_INTP_TIMETIC0, S5J_RTC_INTP);
 
        /* Process timer interrupt */
        sched_process_timer();
@@ -117,18 +120,14 @@ int up_timerisr(int irq, uint32_t *regs, void *arg)
  ****************************************************************************/
 void up_timer_initialize(void)
 {
-       /* Configure local timer0 to interrupt at the requested rate */
-       s5j_mct_local_int_ctrl(MCT_L0, LINT_INT);
-       s5j_mct_local_set_tick_cnt(MCT_L0, SYSTICK_RELOAD);
-       s5j_mct_local_set_int_cnt_manual(MCT_L0, 0);
-
-       s5j_mct_local_set_interval(MCT_L0);
-       s5j_mct_local_start_int(MCT_L0);
-       s5j_mct_local_start_timer(MCT_L0);
+       /* Configure the RTC timetick to generate periodic interrupts */
+       modifyreg32(S5J_RTC_RTCCON, RTC_RTCCON_TICKEN0, 0);
+       putreg32(SYSTICK_RELOAD, S5J_RTC_TICCNT0);
+       modifyreg32(S5J_RTC_RTCCON, 0, RTC_RTCCON_TICKEN0);
 
        /* Attach the timer interrupt vector */
-       irq_attach(IRQ_MCT_L0, (xcpt_t) up_timerisr, NULL);
+       irq_attach(IRQ_TOP_RTC_TIC, up_timerisr, NULL);
 
        /* Enable the timer interrupt */
-       up_enable_irq(IRQ_MCT_L0);
+       up_enable_irq(IRQ_TOP_RTC_TIC);
 }
index d816907..0fb0fb8 100644 (file)
@@ -58,7 +58,7 @@
  * Included Files
  ************************************************************************************/
 
-#define SYSCLK_FREQUENCY     26000000  /* 26MHz */
+#define SYSCLK_FREQUENCY       32768 /* RTC clock at 32768Hz */
 
 #ifndef __ASSEMBLY__
 extern void s5j_boardinitialize(void);