pmgr: Add pmgr_adt_power_{en,dis}able_index()

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-04-10 01:05:36 +09:00
parent 3bc3b0131f
commit 046620d4d5
2 changed files with 33 additions and 0 deletions

View file

@ -195,6 +195,26 @@ static int pmgr_adt_devices_set_mode(const char *path, u8 target_mode, int recur
return ret;
}
static int pmgr_adt_device_set_mode(const char *path, u32 index, u8 target_mode, int recurse)
{
const u32 *devices;
u32 n_devices;
int ret = 0;
if (pmgr_adt_find_devices(path, &devices, &n_devices) < 0)
return -1;
if (index >= n_devices)
return -1;
u16 device = FIELD_GET(PMGR_DEVICE_ID, devices[index]);
u8 die = FIELD_GET(PMGR_DIE_ID, devices[index]);
if (pmgr_set_mode_recursive(die, device, target_mode, recurse))
ret = -1;
return ret;
}
int pmgr_adt_power_enable(const char *path)
{
int ret = pmgr_adt_devices_set_mode(path, PMGR_PS_ACTIVE, true);
@ -206,6 +226,17 @@ int pmgr_adt_power_disable(const char *path)
return pmgr_adt_devices_set_mode(path, PMGR_PS_PWRGATE, false);
}
int pmgr_adt_power_enable_index(const char *path, u32 index)
{
int ret = pmgr_adt_device_set_mode(path, index, PMGR_PS_ACTIVE, true);
return ret;
}
int pmgr_adt_power_disable_index(const char *path, u32 index)
{
return pmgr_adt_device_set_mode(path, index, PMGR_PS_PWRGATE, false);
}
static int pmgr_reset_device(int die, const struct pmgr_device *dev)
{
if (die < 0 || die > 16) {

View file

@ -17,6 +17,8 @@ int pmgr_power_disable(u32 id);
int pmgr_adt_power_enable(const char *path);
int pmgr_adt_power_disable(const char *path);
int pmgr_adt_power_enable_index(const char *path, u32 index);
int pmgr_adt_power_disable_index(const char *path, u32 index);
int pmgr_adt_reset(const char *path);
int pmgr_reset(int die, const char *name);