tunables: add tunables_apply_local_addr

Signed-off-by: Sven Peter <sven@svenpeter.dev>
This commit is contained in:
Sven Peter 2021-04-07 22:39:43 +02:00 committed by Hector Martin
parent a17e64f1e2
commit 8aa3c69a2d
5 changed files with 35 additions and 7 deletions

View file

@ -611,6 +611,8 @@ class M1N1Proxy:
return self.request(self.P_TUNABLES_APPLY_GLOBAL, path, prop)
def tunables_apply_local(self, path, prop, reg_offset):
return self.request(self.P_TUNABLES_APPLY_LOCAL, path, prop, reg_offset)
def tunables_apply_local_addr(self, path, prop, base):
return self.request(self.P_TUNABLES_APPLY_LOCAL, path, prop, base)
if __name__ == "__main__":
import serial

View file

@ -318,6 +318,10 @@ int proxy_process(ProxyRequest *request, ProxyReply *reply)
reply->retval = tunables_apply_local((const char *)request->args[0],
(const char *)request->args[1], request->args[2]);
break;
case P_TUNABLES_APPLY_LOCAL_ADDR:
reply->retval = tunables_apply_local_addr(
(const char *)request->args[0], (const char *)request->args[1], request->args[2]);
break;
default:
reply->status = S_BADCMD;

View file

@ -84,6 +84,7 @@ typedef enum {
P_TUNABLES_APPLY_GLOBAL = 0xa00,
P_TUNABLES_APPLY_LOCAL,
P_TUNABLES_APPLY_LOCAL_ADDR,
} ProxyOp;

View file

@ -75,19 +75,13 @@ struct tunable_local {
u64 value;
} PACKED;
int tunables_apply_local(const char *path, const char *prop, u32 reg_offset)
int tunables_apply_local_addr(const char *path, const char *prop, uintptr_t base)
{
struct tunable_info info;
if (tunables_adt_find(path, prop, &info, sizeof(struct tunable_local)) < 0)
return -1;
u64 base;
if (adt_get_reg(adt, info.node_path, "reg", reg_offset, &base, NULL) < 0) {
printf("tunable: Error getting regs\n");
return -1;
}
const struct tunable_local *tunables = (const struct tunable_local *)info.tunable_raw;
for (u32 i = 0; i < info.tunable_len; ++i) {
const struct tunable_local *tunable = &tunables[i];
@ -112,3 +106,19 @@ int tunables_apply_local(const char *path, const char *prop, u32 reg_offset)
}
return 0;
}
int tunables_apply_local(const char *path, const char *prop, u32 reg_offset)
{
struct tunable_info info;
if (tunables_adt_find(path, prop, &info, sizeof(struct tunable_local)) < 0)
return -1;
u64 base;
if (adt_get_reg(adt, info.node_path, "reg", reg_offset, &base, NULL) < 0) {
printf("tunable: Error getting regs\n");
return -1;
}
return tunables_apply_local_addr(path, prop, base);
}

View file

@ -26,4 +26,15 @@ int tunables_apply_global(const char *path, const char *prop);
*/
int tunables_apply_local(const char *path, const char *prop, u32 reg_idx);
/*
* This functions does the same as tunables_apply_local except that it allows
* to specify the base address to which the tunables will be applied to instead
* of extracting it from the "regs" property.
*
* Example usage for two tunables for the USB DRD DART node:
* tunables_apply_local_addr("/arm-io/dart-usb0", "dart-tunables-instance-0", 0x382f00000);
* tunables_apply_local_addr("/arm-io/dart-usb0", "dart-tunables-instance-1", 0x382f80000);
*/
int tunables_apply_local_addr(const char *path, const char *prop, uintptr_t base);
#endif