Skip to content

Commit

Permalink
soc: arm: ti_simplelink: drop custom constraint implementation
Browse files Browse the repository at this point in the history
The constraints API offered by TI HAL is meant to be used externally,
for example, when implementing a policy using their policy mechanism
(not used on Zephyr). The API is likely designed for systems where a
thin RTOS is used (e.g., FreeRTOS, TI-RTOS?), places where you basically
get a Kernel and a few services around, but not a system like Zephyr
where you also get, for example, a power management subsystem. This
means that it gets difficult for an RTOS like Zephyr to use such HAL
APIs while using its own constraints API. The first question is why we
allowed such kind of HAL code to be part of upstream Zephyr. It
certainly does useful things, but it is also uses a HAL infrastructure
which is hardly exportable to an RTOS like Zephyr. Part of the
Power_init() code, for example, should likely be in a clock controller
driver, where Zephyr APIs can be used.

The _solution_ that was done to workaround this case was allowing custom
full re-implementations of the constraints API. So we are basically
overwriting a functional API with custom HAL code because of poor HAL
designs. This is in general a bad design principle. If we allow this, we
can hardly offer any guarantees to the API users. For example, is
re-implemented as thread-safe? What is the API behavior then? ...
Platforms like TI that have incomplete support in Zephyr tend to leverage
to HAL code certain functions that should be proper Zephyr
drivers. Such platforms should not influence the design of APIs because
they lack solid foundations.

This patch removes the custom implementation since the HAL has been
patched so that it forwards PM state constraints to Zephyr.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull authored and carlescufi committed Feb 28, 2022
1 parent 902ba8a commit bb40e38
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions soc/arm/ti_simplelink/cc13x2_cc26x2/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,57 +189,5 @@ void PowerCC26XX_schedulerRestore(void)
*/
}

#ifdef CONFIG_PM
/* Constraint API hooks */

void pm_constraint_set(enum pm_state state)
{
switch (state) {
case PM_STATE_RUNTIME_IDLE:
Power_setConstraint(PowerCC26XX_DISALLOW_IDLE);
break;
case PM_STATE_STANDBY:
Power_setConstraint(PowerCC26XX_DISALLOW_STANDBY);
break;
default:
break;
}
}

void pm_constraint_release(enum pm_state state)
{
switch (state) {
case PM_STATE_RUNTIME_IDLE:
Power_releaseConstraint(PowerCC26XX_DISALLOW_IDLE);
break;
case PM_STATE_STANDBY:
Power_releaseConstraint(PowerCC26XX_DISALLOW_STANDBY);
break;
default:
break;
}
}

bool pm_constraint_get(enum pm_state state)
{
bool ret = true;
uint32_t constraints;

constraints = Power_getConstraintMask();
switch (state) {
case PM_STATE_RUNTIME_IDLE:
ret = (constraints & (1 << PowerCC26XX_DISALLOW_IDLE)) == 0;
break;
case PM_STATE_STANDBY:
ret = (constraints & (1 << PowerCC26XX_DISALLOW_STANDBY)) == 0;
break;
default:
break;
}

return ret;
}
#endif /* CONFIG_PM */

SYS_INIT(power_initialize, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(unlatch_pins, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);

0 comments on commit bb40e38

Please sign in to comment.