arch: cxd56xx: Use spinlock API in cxd56_rtc.c

Summary:
- This commit improves cxd56_rtc performance in SMP mode.

Impact:
- This commit affects SMP mode only.

Testing:
- Tested with spresense:smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2020-08-26 16:46:59 +09:00 committed by Alin Jerpelea
parent dcdd7264c8
commit c770dc9134

View File

@ -446,7 +446,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
irqstate_t flags;
uint64_t count;
flags = enter_critical_section();
flags = spin_lock_irqsave();
#ifdef RTC_DIRECT_CONTROL
/* wait until previous write request is completed */
@ -469,7 +469,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
g_rtc_save->offset = (int64_t)count - (int64_t)cxd56_rtc_count();
#endif
leave_critical_section(flags);
spin_unlock_irqrestore(flags);
rtc_dumptime(tp, "Setting time");
@ -497,12 +497,12 @@ uint64_t cxd56_rtc_count(void)
* 1st post -> 2nd pre, and should be operated in atomic.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave();
val = (uint64_t)getreg32(CXD56_RTC0_RTPOSTCNT) << 15;
val |= getreg32(CXD56_RTC0_RTPRECNT);
leave_critical_section(flags);
spin_unlock_irqrestore(flags);
return val;
}
@ -524,12 +524,12 @@ uint64_t cxd56_rtc_almcount(void)
uint64_t val;
irqstate_t flags;
flags = enter_critical_section();
flags = spin_lock_irqsave();
val = (uint64_t)getreg32(CXD56_RTC0_SETALMPOSTCNT(0)) << 15;
val |= (getreg32(CXD56_RTC0_SETALMPRECNT(0)) & 0x7fff);
leave_critical_section(flags);
spin_unlock_irqrestore(flags);
return val;
}
@ -570,7 +570,7 @@ int cxd56_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
{
/* The set the alarm */
flags = enter_critical_section();
flags = spin_lock_irqsave();
cbinfo->ac_cb = alminfo->as_cb;
cbinfo->ac_arg = alminfo->as_arg;
@ -594,7 +594,7 @@ int cxd56_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
while (RTCREG_ALM_BUSY_MASK & getreg32(CXD56_RTC0_ALMOUTEN(id)));
leave_critical_section(flags);
spin_unlock_irqrestore(flags);
rtc_dumptime(&alminfo->as_time, "New Alarm time");
ret = OK;
@ -635,7 +635,7 @@ int cxd56_rtc_cancelalarm(enum alm_id_e alarmid)
{
/* Unset the alarm */
flags = enter_critical_section();
flags = spin_lock_irqsave();
cbinfo->ac_cb = NULL;
@ -643,7 +643,7 @@ int cxd56_rtc_cancelalarm(enum alm_id_e alarmid)
putreg32(0, CXD56_RTC0_ALMOUTEN(alarmid));
leave_critical_section(flags);
spin_unlock_irqrestore(flags);
ret = OK;
}