drivers: regulator: smartbond: Regulator driver update

This commit should deal with the followings:

1. Change regulator's driver priority as it should now
   be used by the clock control driver.
2. Check if the VDD level is permitted to change when PLL
   is the system clock. This is because the PLL requires
   that VDD be 1.2V.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
This commit is contained in:
Ioannis Karachalios 2024-05-23 17:39:36 +03:00 committed by Alberto Escolar
parent c1fecdc2e3
commit 570a508633
2 changed files with 21 additions and 2 deletions

View file

@ -10,7 +10,7 @@ config REGULATOR_DA1469X
config REGULATOR_DA1469X_INIT_PRIORITY
int "Renesas DA1469x regulators driver init priority"
default KERNEL_INIT_PRIORITY_DEVICE
default 20
depends on REGULATOR_DA1469X
help
Init priority for the Renesas DA1469x regulators driver.

View file

@ -13,6 +13,7 @@
#include <zephyr/pm/pm.h>
#include <zephyr/pm/device.h>
#include <DA1469xAB.h>
#include <zephyr/devicetree.h>
LOG_MODULE_REGISTER(regulator_da1469x, CONFIG_REGULATOR_LOG_LEVEL);
@ -22,6 +23,9 @@ LOG_MODULE_REGISTER(regulator_da1469x, CONFIG_REGULATOR_LOG_LEVEL);
#define DA1469X_LDO_3V0_MODE_VBAT BIT(8)
#define DA1469X_LDO_3V0_MODE_VBUS BIT(9)
#define PLL_FREQ DT_PROP(DT_NODELABEL(pll), clock_frequency)
#define PLL_VDD_UV 1200000
static const struct linear_range curren_ranges[] = {
LINEAR_RANGE_INIT(30000, 30000, 0, 31),
};
@ -281,6 +285,20 @@ static int regulator_da1469x_set_voltage(const struct device *dev, int32_t min_u
uint16_t idx;
uint32_t mask;
if ((SystemCoreClock == PLL_FREQ) && (config->rail == VDD)) {
/* PLL requires that VDD be @1.2V */
if (max_uv < PLL_VDD_UV) {
return -EPERM;
}
/*
* The get index API should select the min voltage;
* make sure the correct voltage is applied.
*/
if (min_uv < PLL_VDD_UV) {
min_uv = PLL_VDD_UV;
}
}
ret = linear_range_group_get_win_index(config->desc->voltage_ranges,
config->desc->voltage_range_count,
min_uv, max_uv, &idx);
@ -442,7 +460,8 @@ static int regulator_da1469x_pm_action(const struct device *dev,
(DT_PROP(node, renesas_regulator_dcdc_vbat_high) * \
DCDC_DCDC_VDD_REG_DCDC_VDD_ENABLE_HV_Msk) | \
(DT_PROP(node, renesas_regulator_dcdc_vbat_low) * \
DCDC_DCDC_VDD_REG_DCDC_VDD_ENABLE_LV_Msk) \
DCDC_DCDC_VDD_REG_DCDC_VDD_ENABLE_LV_Msk), \
.rail = rail_id, \
}; \
PM_DEVICE_DT_DEFINE(node, regulator_da1469x_pm_action); \
DEVICE_DT_DEFINE(node, regulator_da1469x_init, \