From 73cc1f888477e39b62c6d42fe52c6f52d40074b2 Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Fri, 7 May 2021 11:28:35 +0800 Subject: [PATCH] driver/rtc: add config CONFIG_RTC_RPMSG_SERVER to N/A select rtc rpmsg role. Change-Id: I7f9053b070593573caa5d988c6a2e13593da6bc5 Signed-off-by: Jiuzhu Dong --- arch/sim/src/sim/up_rptun.c | 2 +- arch/sim/src/sim/up_rtc.c | 2 +- boards/sim/sim/sim/configs/rpserver/defconfig | 1 + drivers/timers/Kconfig | 4 ++++ drivers/timers/rpmsg_rtc.c | 19 +++++++++++++++---- include/nuttx/timers/rpmsg_rtc.h | 6 +++--- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/arch/sim/src/sim/up_rptun.c b/arch/sim/src/sim/up_rptun.c index d40070a448..c32d963bb7 100644 --- a/arch/sim/src/sim/up_rptun.c +++ b/arch/sim/src/sim/up_rptun.c @@ -239,7 +239,7 @@ int up_rptun_init(void) syslog_rpmsg_server_init(); #endif -#if CONFIG_SIM_RPTUN_MASTER == 0 +#ifndef CONFIG_RTC_RPMSG_SERVER up_rtc_set_lowerhalf(rpmsg_rtc_initialize(0)); #endif diff --git a/arch/sim/src/sim/up_rtc.c b/arch/sim/src/sim/up_rtc.c index efcb07cb54..628ae82b56 100644 --- a/arch/sim/src/sim/up_rtc.c +++ b/arch/sim/src/sim/up_rtc.c @@ -123,7 +123,7 @@ static bool sim_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower) int up_rtc_initialize(void) { -#ifdef CONFIG_SIM_RPTUN_MASTER +#ifdef CONFIG_RTC_RPMSG_SERVER up_rtc_set_lowerhalf(rpmsg_rtc_server_initialize(&g_sim_rtc)); #else up_rtc_set_lowerhalf(&g_sim_rtc); diff --git a/boards/sim/sim/sim/configs/rpserver/defconfig b/boards/sim/sim/sim/configs/rpserver/defconfig index 61c9281ec2..a903087ab0 100644 --- a/boards/sim/sim/sim/configs/rpserver/defconfig +++ b/boards/sim/sim/sim/configs/rpserver/defconfig @@ -57,6 +57,7 @@ CONFIG_RTC=y CONFIG_RTC_ARCH=y CONFIG_RTC_DRIVER=y CONFIG_RTC_RPMSG=y +CONFIG_RTC_RPMSG_SERVER=y CONFIG_SCHED_CHILD_STATUS=y CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORK=y diff --git a/drivers/timers/Kconfig b/drivers/timers/Kconfig index fb1ddf26cd..fc8cb42ebc 100644 --- a/drivers/timers/Kconfig +++ b/drivers/timers/Kconfig @@ -297,6 +297,10 @@ config RTC_RPMSG depends on OPENAMP select ARCH_HAVE_RTC_SUBSECONDS +config RTC_RPMSG_SERVER + bool "The RTC Rpmsg Role" + depends on OPENAMP + config RTC_RPMSG_SERVER_NAME string "The name of RTC Rpmsg Server" depends on RTC_RPMSG diff --git a/drivers/timers/rpmsg_rtc.c b/drivers/timers/rpmsg_rtc.c index bb38e10ade..f0b3542399 100644 --- a/drivers/timers/rpmsg_rtc.c +++ b/drivers/timers/rpmsg_rtc.c @@ -84,6 +84,7 @@ begin_packed_struct struct rpmsg_rtc_alarm_cancel_s #define rpmsg_rtc_alarm_fire_s rpmsg_rtc_alarm_cancel_s +#ifndef CONFIG_RTC_RPMSG_SERVER struct rpmsg_rtc_cookie_s { FAR struct rpmsg_rtc_header_s *msg; @@ -113,7 +114,7 @@ struct rpmsg_rtc_lowerhalf_s struct lower_setalarm_s alarminfo[CONFIG_RTC_NALARMS]; #endif }; - +#else struct rpmsg_rtc_server_s { FAR struct rtc_ops_s *ops; @@ -127,11 +128,13 @@ struct rpmsg_rtc_session_s struct list_node node; struct rpmsg_endpoint ept; }; +#endif /**************************************************************************** * Private Function Prototypes ****************************************************************************/ +#ifndef CONFIG_RTC_RPMSG_SERVER static void rpmsg_rtc_device_created(FAR struct rpmsg_device *rdev, FAR void *priv); static void rpmsg_rtc_device_destroy(FAR struct rpmsg_device *rdev, @@ -159,7 +162,7 @@ static int rpmsg_rtc_cancelalarm(FAR struct rtc_lowerhalf_s *lower, static int rpmsg_rtc_rdalarm(FAR struct rtc_lowerhalf_s *lower_, FAR struct lower_rdalarm_s *alarminfo); #endif - +#else static int rpmsg_rtc_server_rdtime(FAR struct rtc_lowerhalf_s *lower, FAR struct rtc_time *rtctime); static int rpmsg_rtc_server_settime(FAR struct rtc_lowerhalf_s *lower, @@ -184,11 +187,13 @@ static int rpmsg_rtc_server_setperiodic(FAR struct rtc_lowerhalf_s *lower, static int rpmsg_rtc_server_cancelperiodic (FAR struct rtc_lowerhalf_s *lower, int alarmid); #endif +#endif /**************************************************************************** * Private Data ****************************************************************************/ +#ifndef CONFIG_RTC_RPMSG_SERVER static const struct rtc_ops_s g_rpmsg_rtc_ops = { .rdtime = rpmsg_rtc_rdtime, @@ -201,7 +206,7 @@ static const struct rtc_ops_s g_rpmsg_rtc_ops = .rdalarm = rpmsg_rtc_rdalarm, #endif }; - +#else static struct rtc_ops_s g_rpmsg_rtc_server_ops = { .rdtime = rpmsg_rtc_server_rdtime, @@ -218,11 +223,13 @@ static struct rtc_ops_s g_rpmsg_rtc_server_ops = .cancelperiodic = rpmsg_rtc_server_cancelperiodic, #endif }; +#endif /**************************************************************************** * Private Functions ****************************************************************************/ +#ifndef CONFIG_RTC_RPMSG_SERVER static void rpmsg_rtc_device_created(FAR struct rpmsg_device *rdev, FAR void *priv) { @@ -442,7 +449,7 @@ static int rpmsg_rtc_rdalarm(FAR struct rtc_lowerhalf_s *lower_, return 0; } #endif - +#else static int rpmsg_rtc_server_rdtime(FAR struct rtc_lowerhalf_s *lower, FAR struct rtc_time *rtctime) { @@ -673,6 +680,7 @@ static void rpmsg_rtc_server_ns_bind(FAR struct rpmsg_device *rdev, list_add_tail(&server->list, &session->node); nxsem_post(&server->exclsem); } +#endif /**************************************************************************** * Name: rpmsg_rtc_initialize @@ -690,6 +698,7 @@ static void rpmsg_rtc_server_ns_bind(FAR struct rpmsg_device *rdev, * ****************************************************************************/ +#ifndef CONFIG_RTC_RPMSG_SERVER FAR struct rtc_lowerhalf_s *rpmsg_rtc_initialize(int minor) { FAR struct rpmsg_rtc_lowerhalf_s *lower; @@ -710,6 +719,7 @@ FAR struct rtc_lowerhalf_s *rpmsg_rtc_initialize(int minor) return (FAR struct rtc_lowerhalf_s *)lower; } +#else /**************************************************************************** * Name: rpmsg_rtc_server_initialize * @@ -746,3 +756,4 @@ FAR struct rtc_lowerhalf_s *rpmsg_rtc_server_initialize( return (FAR struct rtc_lowerhalf_s *)server; } +#endif diff --git a/include/nuttx/timers/rpmsg_rtc.h b/include/nuttx/timers/rpmsg_rtc.h index 764904fe3a..813cd04912 100644 --- a/include/nuttx/timers/rpmsg_rtc.h +++ b/include/nuttx/timers/rpmsg_rtc.h @@ -41,12 +41,12 @@ extern "C" #endif #ifdef CONFIG_RTC_RPMSG - +#ifndef CONFIG_RTC_RPMSG_SERVER FAR struct rtc_lowerhalf_s *rpmsg_rtc_initialize(int minor); - +#else FAR struct rtc_lowerhalf_s *rpmsg_rtc_server_initialize( FAR struct rtc_lowerhalf_s *lower); - +#endif /* CONFIG_RTC_RPMSG_SERVER */ #endif /* CONFIG_RTC_RPMSG */ #undef EXTERN