mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 09:44:13 +00:00
pmgr: Add pmgr_adt_power_{en,dis}able_index()
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
3bc3b0131f
commit
046620d4d5
2 changed files with 33 additions and 0 deletions
31
src/pmgr.c
31
src/pmgr.c
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue