mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 09:44:13 +00:00
pmgr: s/clock/power/
Signed-off-by: Sven Peter <sven@svenpeter.dev>
This commit is contained in:
parent
734f8cc1b4
commit
1254b4bee6
7 changed files with 39 additions and 39 deletions
|
@ -43,8 +43,8 @@ i2c_dev_t *i2c_init(const char *adt_node)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pmgr_adt_clocks_enable(adt_node)) {
|
||||
printf("i2c: Error enabling clocks for %s\n", adt_node);
|
||||
if (pmgr_adt_power_enable(adt_node)) {
|
||||
printf("i2c: Error enabling power for %s\n", adt_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -182,8 +182,8 @@ int pcie_init(void)
|
|||
int port_reg_cnt = port_regs / port_count;
|
||||
printf("pcie: ADT uses %d reg entries per port\n", port_reg_cnt);
|
||||
|
||||
if (pmgr_adt_clocks_enable(path)) {
|
||||
printf("pcie: Error enabling clocks for %s\n", path);
|
||||
if (pmgr_adt_power_enable(path)) {
|
||||
printf("pcie: Error enabling power for %s\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
32
src/pmgr.c
32
src/pmgr.c
|
@ -139,17 +139,17 @@ static int pmgr_set_mode_recursive(u16 id, u8 target_mode, bool recurse)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pmgr_clock_enable(u16 id)
|
||||
int pmgr_power_enable(u16 id)
|
||||
{
|
||||
return pmgr_set_mode_recursive(id, PMGR_PS_ACTIVE, true);
|
||||
}
|
||||
|
||||
int pmgr_clock_disable(u16 id)
|
||||
int pmgr_power_disable(u16 id)
|
||||
{
|
||||
return pmgr_set_mode_recursive(id, PMGR_PS_PWRGATE, false);
|
||||
}
|
||||
|
||||
static int pmgr_adt_find_clocks(const char *path, const u32 **clocks, u32 *n_clocks)
|
||||
static int pmgr_adt_find_devices(const char *path, const u32 **devices, u32 *n_devices)
|
||||
{
|
||||
int node_offset = adt_path_offset(adt, path);
|
||||
if (node_offset < 0) {
|
||||
|
@ -157,43 +157,43 @@ static int pmgr_adt_find_clocks(const char *path, const u32 **clocks, u32 *n_clo
|
|||
return -1;
|
||||
}
|
||||
|
||||
*clocks = adt_getprop(adt, node_offset, "clock-gates", n_clocks);
|
||||
if (*clocks == NULL || *n_clocks == 0) {
|
||||
*devices = adt_getprop(adt, node_offset, "clock-gates", n_devices);
|
||||
if (*devices == NULL || *n_devices == 0) {
|
||||
printf("pmgr: Error getting %s clock-gates.\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*n_clocks /= 4;
|
||||
*n_devices /= 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pmgr_adt_clocks_set_mode(const char *path, u8 target_mode, int recurse)
|
||||
static int pmgr_adt_devices_set_mode(const char *path, u8 target_mode, int recurse)
|
||||
{
|
||||
const u32 *clocks;
|
||||
u32 n_clocks;
|
||||
const u32 *devices;
|
||||
u32 n_devices;
|
||||
int ret = 0;
|
||||
|
||||
if (pmgr_adt_find_clocks(path, &clocks, &n_clocks) < 0)
|
||||
if (pmgr_adt_find_devices(path, &devices, &n_devices) < 0)
|
||||
return -1;
|
||||
|
||||
for (u32 i = 0; i < n_clocks; ++i) {
|
||||
if (pmgr_set_mode_recursive(clocks[i], target_mode, recurse))
|
||||
for (u32 i = 0; i < n_devices; ++i) {
|
||||
if (pmgr_set_mode_recursive(devices[i], target_mode, recurse))
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pmgr_adt_clocks_enable(const char *path)
|
||||
int pmgr_adt_power_enable(const char *path)
|
||||
{
|
||||
int ret = pmgr_adt_clocks_set_mode(path, PMGR_PS_ACTIVE, true);
|
||||
int ret = pmgr_adt_devices_set_mode(path, PMGR_PS_ACTIVE, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pmgr_adt_clocks_disable(const char *path)
|
||||
int pmgr_adt_power_disable(const char *path)
|
||||
{
|
||||
return pmgr_adt_clocks_set_mode(path, PMGR_PS_PWRGATE, false);
|
||||
return pmgr_adt_devices_set_mode(path, PMGR_PS_PWRGATE, false);
|
||||
}
|
||||
|
||||
int pmgr_init(void)
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
int pmgr_init(void);
|
||||
|
||||
int pmgr_clock_enable(u16 id);
|
||||
int pmgr_clock_disable(u16 id);
|
||||
int pmgr_power_enable(u16 id);
|
||||
int pmgr_power_disable(u16 id);
|
||||
|
||||
int pmgr_adt_clocks_enable(const char *path);
|
||||
int pmgr_adt_clocks_disable(const char *path);
|
||||
int pmgr_adt_power_enable(const char *path);
|
||||
int pmgr_adt_power_disable(const char *path);
|
||||
|
||||
#endif
|
||||
|
|
16
src/proxy.c
16
src/proxy.c
|
@ -360,17 +360,17 @@ int proxy_process(ProxyRequest *request, ProxyReply *reply)
|
|||
reply->retval = kboot_prepare_dt((void *)request->args[0]);
|
||||
break;
|
||||
|
||||
case P_PMGR_CLOCK_ENABLE:
|
||||
reply->retval = pmgr_clock_enable(request->args[0]);
|
||||
case P_PMGR_POWER_ENABLE:
|
||||
reply->retval = pmgr_power_enable(request->args[0]);
|
||||
break;
|
||||
case P_PMGR_CLOCK_DISABLE:
|
||||
reply->retval = pmgr_clock_enable(request->args[0]);
|
||||
case P_PMGR_POWER_DISABLE:
|
||||
reply->retval = pmgr_power_enable(request->args[0]);
|
||||
break;
|
||||
case P_PMGR_ADT_CLOCKS_ENABLE:
|
||||
reply->retval = pmgr_adt_clocks_enable((const char *)request->args[0]);
|
||||
case P_PMGR_ADT_POWER_ENABLE:
|
||||
reply->retval = pmgr_adt_power_enable((const char *)request->args[0]);
|
||||
break;
|
||||
case P_PMGR_ADT_CLOCKS_DISABLE:
|
||||
reply->retval = pmgr_adt_clocks_disable((const char *)request->args[0]);
|
||||
case P_PMGR_ADT_POWER_DISABLE:
|
||||
reply->retval = pmgr_adt_power_disable((const char *)request->args[0]);
|
||||
break;
|
||||
|
||||
case P_IODEV_SET_USAGE:
|
||||
|
|
|
@ -93,10 +93,10 @@ typedef enum {
|
|||
P_KBOOT_SET_INITRD,
|
||||
P_KBOOT_PREPARE_DT,
|
||||
|
||||
P_PMGR_CLOCK_ENABLE = 0x800, // power/clock management ops
|
||||
P_PMGR_CLOCK_DISABLE,
|
||||
P_PMGR_ADT_CLOCKS_ENABLE,
|
||||
P_PMGR_ADT_CLOCKS_DISABLE,
|
||||
P_PMGR_POWER_ENABLE = 0x800, // power/clock management ops
|
||||
P_PMGR_POWER_DISABLE,
|
||||
P_PMGR_ADT_POWER_ENABLE,
|
||||
P_PMGR_ADT_POWER_DISABLE,
|
||||
|
||||
P_IODEV_SET_USAGE = 0x900,
|
||||
P_IODEV_CAN_READ,
|
||||
|
|
|
@ -108,15 +108,15 @@ int usb_phy_bringup(u32 idx)
|
|||
return -1;
|
||||
|
||||
snprintf(path, sizeof(path), FMT_ATC_PATH, idx);
|
||||
if (pmgr_adt_clocks_enable(path) < 0)
|
||||
if (pmgr_adt_power_enable(path) < 0)
|
||||
return -1;
|
||||
|
||||
snprintf(path, sizeof(path), FMT_DART_PATH, idx);
|
||||
if (pmgr_adt_clocks_enable(path) < 0)
|
||||
if (pmgr_adt_power_enable(path) < 0)
|
||||
return -1;
|
||||
|
||||
snprintf(path, sizeof(path), FMT_DRD_PATH, idx);
|
||||
if (pmgr_adt_clocks_enable(path) < 0)
|
||||
if (pmgr_adt_power_enable(path) < 0)
|
||||
return -1;
|
||||
|
||||
write32(usb_regs.atc + 0x08, 0x01c1000f);
|
||||
|
|
Loading…
Reference in a new issue