From 0882bb4d644d8e119a9a2cd0e3661b2726bcea8c Mon Sep 17 00:00:00 2001 From: Leandro Belli Date: Thu, 15 Oct 2020 17:11:38 +0100 Subject: scmi_system_power/boards: Add default timer_id and add extra check When SCMI notifications are supported a timer is required to handle graceful request. If this feature is not used timer_id must be set to FWK_ID_NONE. This patch also adds check for FWK_ID_NONE to prevent a binding with no configuration set. Change-Id: I25f982c2e8d686ac80dd0ebc2d9e64eac1522f3c Signed-off-by: Leandro Belli --- .../include/mod_scmi_system_power.h | 3 ++ .../scmi_system_power/src/mod_scmi_system_power.c | 35 ++++++++++++---------- .../scp_ramfw_fvp/config_scmi_system_power.c | 2 +- product/n1sdp/scp_ramfw/config_scmi_system_power.c | 6 ++-- .../rddaniel/scp_ramfw/config_scmi_system_power.c | 6 ++-- .../scp_ramfw/config_scmi_system_power.c | 6 ++-- .../rdn1e1/scp_ramfw/config_scmi_system_power.c | 6 ++-- .../sgi575/scp_ramfw/config_scmi_system_power.c | 6 ++-- .../sgm775/scp_ramfw/config_scmi_system_power.c | 3 +- .../sgm776/scp_ramfw/config_scmi_system_power.c | 3 +- .../synquacer/scp_ramfw/config_scmi_system_power.c | 3 +- product/tc0/scp_ramfw/config_scmi_system_power.c | 4 ++- 12 files changed, 48 insertions(+), 35 deletions(-) diff --git a/module/scmi_system_power/include/mod_scmi_system_power.h b/module/scmi_system_power/include/mod_scmi_system_power.h index ec0cdeaf..8c042682 100644 --- a/module/scmi_system_power/include/mod_scmi_system_power.h +++ b/module/scmi_system_power/include/mod_scmi_system_power.h @@ -63,6 +63,9 @@ struct mod_scmi_system_power_config { /*! * \brief Identifier of the alarm for graceful request timeout. + * + * \note This alarm is optional, if it is not used it must be set to + * FWK_ID_NONE */ fwk_id_t alarm_id; diff --git a/module/scmi_system_power/src/mod_scmi_system_power.c b/module/scmi_system_power/src/mod_scmi_system_power.c index 74e2f760..7b13e3b7 100644 --- a/module/scmi_system_power/src/mod_scmi_system_power.c +++ b/module/scmi_system_power/src/mod_scmi_system_power.c @@ -516,12 +516,16 @@ FWK_WEAK int scmi_sys_power_state_set_policy( #ifdef BUILD_HAS_SCMI_NOTIFICATIONS scmi_sys_power_state_notify(service_id, *state, false); #endif - scmi_sys_power_ctx.alarm_api->start( - scmi_sys_power_ctx.config->alarm_id, - scmi_sys_power_ctx.config->graceful_timeout, - MOD_TIMER_ALARM_TYPE_ONCE, - graceful_timer_callback, - *state); + + if (scmi_sys_power_ctx.alarm_api) + scmi_sys_power_ctx.alarm_api->start( + scmi_sys_power_ctx.config->alarm_id, + scmi_sys_power_ctx.config->graceful_timeout, + MOD_TIMER_ALARM_TYPE_ONCE, + graceful_timer_callback, + *state); + else + graceful_timer_callback(*state); } } @@ -704,16 +708,17 @@ static int scmi_sys_power_bind(fwk_id_t id, unsigned int round) * If notifications is supported a timer is required to handle graceful * requests. */ - status = fwk_module_bind( - scmi_sys_power_ctx.config->alarm_id, - MOD_TIMER_API_ID_ALARM, - &scmi_sys_power_ctx.alarm_api); - if (status != FWK_SUCCESS) - return status; - return scmi_sys_power_init_notifications(); -#else - return FWK_SUCCESS; + if (!fwk_id_is_equal(scmi_sys_power_ctx.config->alarm_id, FWK_ID_NONE)) { + status = fwk_module_bind( + scmi_sys_power_ctx.config->alarm_id, + MOD_TIMER_API_ID_ALARM, + &scmi_sys_power_ctx.alarm_api); + if (status != FWK_SUCCESS) + return status; + return scmi_sys_power_init_notifications(); + } #endif + return FWK_SUCCESS; } static int scmi_sys_power_process_bind_request(fwk_id_t source_id, diff --git a/product/morello/scp_ramfw_fvp/config_scmi_system_power.c b/product/morello/scp_ramfw_fvp/config_scmi_system_power.c index 31bb20d1..f969afda 100644 --- a/product/morello/scp_ramfw_fvp/config_scmi_system_power.c +++ b/product/morello/scp_ramfw_fvp/config_scmi_system_power.c @@ -15,5 +15,5 @@ const struct fwk_module_config config_scmi_system_power = { &(struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, - }, + .alarm_id = FWK_ID_NONE_INIT }, }; diff --git a/product/n1sdp/scp_ramfw/config_scmi_system_power.c b/product/n1sdp/scp_ramfw/config_scmi_system_power.c index 821cb7d2..1ba43921 100644 --- a/product/n1sdp/scp_ramfw/config_scmi_system_power.c +++ b/product/n1sdp/scp_ramfw/config_scmi_system_power.c @@ -11,8 +11,8 @@ #include const struct fwk_module_config config_scmi_system_power = { - .data = &((struct mod_scmi_system_power_config) { + .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 - }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/rddaniel/scp_ramfw/config_scmi_system_power.c b/product/rddaniel/scp_ramfw/config_scmi_system_power.c index 20b22582..abccf3f6 100644 --- a/product/rddaniel/scp_ramfw/config_scmi_system_power.c +++ b/product/rddaniel/scp_ramfw/config_scmi_system_power.c @@ -11,8 +11,8 @@ #include const struct fwk_module_config config_scmi_system_power = { - .data = &((struct mod_scmi_system_power_config) { + .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 - }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/rddanielxlr/scp_ramfw/config_scmi_system_power.c b/product/rddanielxlr/scp_ramfw/config_scmi_system_power.c index 20b22582..abccf3f6 100644 --- a/product/rddanielxlr/scp_ramfw/config_scmi_system_power.c +++ b/product/rddanielxlr/scp_ramfw/config_scmi_system_power.c @@ -11,8 +11,8 @@ #include const struct fwk_module_config config_scmi_system_power = { - .data = &((struct mod_scmi_system_power_config) { + .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 - }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/rdn1e1/scp_ramfw/config_scmi_system_power.c b/product/rdn1e1/scp_ramfw/config_scmi_system_power.c index 32714d2e..f1767fe2 100644 --- a/product/rdn1e1/scp_ramfw/config_scmi_system_power.c +++ b/product/rdn1e1/scp_ramfw/config_scmi_system_power.c @@ -11,8 +11,8 @@ #include const struct fwk_module_config config_scmi_system_power = { - .data = &((struct mod_scmi_system_power_config) { + .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 - }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/sgi575/scp_ramfw/config_scmi_system_power.c b/product/sgi575/scp_ramfw/config_scmi_system_power.c index 821cb7d2..1ba43921 100644 --- a/product/sgi575/scp_ramfw/config_scmi_system_power.c +++ b/product/sgi575/scp_ramfw/config_scmi_system_power.c @@ -11,8 +11,8 @@ #include const struct fwk_module_config config_scmi_system_power = { - .data = &((struct mod_scmi_system_power_config) { + .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 - }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/sgm775/scp_ramfw/config_scmi_system_power.c b/product/sgm775/scp_ramfw/config_scmi_system_power.c index 3a44bf60..47681867 100644 --- a/product/sgm775/scp_ramfw/config_scmi_system_power.c +++ b/product/sgm775/scp_ramfw/config_scmi_system_power.c @@ -15,5 +15,6 @@ struct fwk_module_config config_scmi_system_power = { .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/sgm776/scp_ramfw/config_scmi_system_power.c b/product/sgm776/scp_ramfw/config_scmi_system_power.c index 3a44bf60..47681867 100644 --- a/product/sgm776/scp_ramfw/config_scmi_system_power.c +++ b/product/sgm776/scp_ramfw/config_scmi_system_power.c @@ -15,5 +15,6 @@ struct fwk_module_config config_scmi_system_power = { .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/synquacer/scp_ramfw/config_scmi_system_power.c b/product/synquacer/scp_ramfw/config_scmi_system_power.c index 1b9720fa..1ba43921 100644 --- a/product/synquacer/scp_ramfw/config_scmi_system_power.c +++ b/product/synquacer/scp_ramfw/config_scmi_system_power.c @@ -13,5 +13,6 @@ const struct fwk_module_config config_scmi_system_power = { .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), }; diff --git a/product/tc0/scp_ramfw/config_scmi_system_power.c b/product/tc0/scp_ramfw/config_scmi_system_power.c index e5a491ae..167f213c 100644 --- a/product/tc0/scp_ramfw/config_scmi_system_power.c +++ b/product/tc0/scp_ramfw/config_scmi_system_power.c @@ -13,5 +13,7 @@ const struct fwk_module_config config_scmi_system_power = { .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, - .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0 }), + .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, + .alarm_id = FWK_ID_NONE_INIT }), + }; -- cgit v1.2.3