mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/sim: register RTC after clock initialization
Registering /dev/rtc0 from up_rtc_initialize() creates the pseudofs inode before clock_inittime() synchronizes CLOCK_REALTIME. Its timestamp is consequently zero and omitted by ls -l. Keep lower-half setup in early RTC initialization, but defer character-device registration to up_initialize(), which runs after clock initialization. Fixes #19504 Signed-off-by: hanzhijian <hanzhijian@zepp.com>
This commit is contained in:
parent
564fae94d7
commit
634d8a1272
3 changed files with 38 additions and 1 deletions
|
|
@ -266,6 +266,14 @@ void up_initialize(void)
|
|||
sim_init_cmdline();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Register the RTC after clock_initialize() has synchronized system
|
||||
* time.
|
||||
*/
|
||||
|
||||
sim_rtc_initialize();
|
||||
#endif
|
||||
|
||||
/* Register some tty-port to access tty-port on sim platform */
|
||||
|
||||
sim_uartinit();
|
||||
|
|
|
|||
|
|
@ -276,6 +276,12 @@ int sim_init_func_call_ipi(int irq);
|
|||
void sim_timer_update(void);
|
||||
#endif
|
||||
|
||||
/* sim_rtc.c ****************************************************************/
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
int sim_rtc_initialize(void);
|
||||
#endif
|
||||
|
||||
/* sim_uart.c ***************************************************************/
|
||||
|
||||
void sim_uartinit(void);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ static struct rtc_lowerhalf_s g_sim_rtc =
|
|||
.ops = &g_sim_rtc_ops,
|
||||
};
|
||||
|
||||
static struct rtc_lowerhalf_s *g_sim_rtc_lower;
|
||||
static int64_t g_sim_delta;
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -134,6 +135,28 @@ int up_rtc_initialize(void)
|
|||
rtc = rpmsg_rtc_initialize();
|
||||
sync = false;
|
||||
#endif
|
||||
|
||||
g_sim_rtc_lower = rtc;
|
||||
up_rtc_set_lowerhalf(rtc, sync);
|
||||
return rtc_initialize(0, rtc);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_rtc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Register the SIM RTC driver after the system clock has been initialized.
|
||||
* This ensures that the /dev/rtc0 inode receives a valid timestamp.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sim_rtc_initialize(void)
|
||||
{
|
||||
return rtc_initialize(0, g_sim_rtc_lower);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue