Skip to content

Commit 046620d

Browse files
committed
pmgr: Add pmgr_adt_power_{en,dis}able_index()
Signed-off-by: Hector Martin <[email protected]>
1 parent 3bc3b01 commit 046620d

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/pmgr.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ static int pmgr_adt_devices_set_mode(const char *path, u8 target_mode, int recur
195195
return ret;
196196
}
197197

198+
static int pmgr_adt_device_set_mode(const char *path, u32 index, u8 target_mode, int recurse)
199+
{
200+
const u32 *devices;
201+
u32 n_devices;
202+
int ret = 0;
203+
204+
if (pmgr_adt_find_devices(path, &devices, &n_devices) < 0)
205+
return -1;
206+
207+
if (index >= n_devices)
208+
return -1;
209+
210+
u16 device = FIELD_GET(PMGR_DEVICE_ID, devices[index]);
211+
u8 die = FIELD_GET(PMGR_DIE_ID, devices[index]);
212+
if (pmgr_set_mode_recursive(die, device, target_mode, recurse))
213+
ret = -1;
214+
215+
return ret;
216+
}
217+
198218
int pmgr_adt_power_enable(const char *path)
199219
{
200220
int ret = pmgr_adt_devices_set_mode(path, PMGR_PS_ACTIVE, true);
@@ -206,6 +226,17 @@ int pmgr_adt_power_disable(const char *path)
206226
return pmgr_adt_devices_set_mode(path, PMGR_PS_PWRGATE, false);
207227
}
208228

229+
int pmgr_adt_power_enable_index(const char *path, u32 index)
230+
{
231+
int ret = pmgr_adt_device_set_mode(path, index, PMGR_PS_ACTIVE, true);
232+
return ret;
233+
}
234+
235+
int pmgr_adt_power_disable_index(const char *path, u32 index)
236+
{
237+
return pmgr_adt_device_set_mode(path, index, PMGR_PS_PWRGATE, false);
238+
}
239+
209240
static int pmgr_reset_device(int die, const struct pmgr_device *dev)
210241
{
211242
if (die < 0 || die > 16) {

src/pmgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ int pmgr_power_disable(u32 id);
1717

1818
int pmgr_adt_power_enable(const char *path);
1919
int pmgr_adt_power_disable(const char *path);
20+
int pmgr_adt_power_enable_index(const char *path, u32 index);
21+
int pmgr_adt_power_disable_index(const char *path, u32 index);
2022
int pmgr_adt_reset(const char *path);
2123

2224
int pmgr_reset(int die, const char *name);

0 commit comments

Comments
 (0)