aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hardinfo/dt_util.c37
-rw-r--r--includes/dt_util.h6
-rw-r--r--modules/devices/gpu.c15
3 files changed, 50 insertions, 8 deletions
diff --git a/hardinfo/dt_util.c b/hardinfo/dt_util.c
index 60f84553..78ee2128 100644
--- a/hardinfo/dt_util.c
+++ b/hardinfo/dt_util.c
@@ -942,6 +942,7 @@ dt_opp_range *dtr_get_opp_range(dtr *s, const char *name) {
uint64_t khz = 0;
uint32_t lns = 0;
char *row_status = NULL;
+ uint32_t i = 0;
if (!s)
return NULL;
@@ -950,9 +951,40 @@ dt_opp_range *dtr_get_opp_range(dtr *s, const char *name) {
if (!obj)
goto get_opp_finish;
- opp_ph = dtr_get_prop_u32(s, obj, "operating-points-v2");
- if (!opp_ph)
+ opp_ph = dtr_get_prop_u32(s, obj, "operating-points-v2"); /* OPPv2 */
+ table_obj = dtr_get_prop_obj(s, obj, "operating-points"); /* OPPv1 */
+ if (!opp_ph) {
+ if (table_obj) {
+ /* only v1 */
+ ret = g_new0(dt_opp_range, 1);
+ ret->version = 1;
+ ret->clock_latency_ns = dtr_get_prop_u32(s, obj, "clock-latency");
+
+ /* pairs of (kHz,uV) */
+ for (i = 0; i < table_obj->length; i += 2) {
+ khz = table_obj->data_int[i];
+ if (khz > ret->khz_max)
+ ret->khz_max = khz;
+ if (khz < ret->khz_min || ret->khz_min == 0)
+ ret->khz_min = khz;
+ }
+
+ } else {
+ /* is clock-frequency available? */
+ khz = dtr_get_prop_u32(s, obj, "clock-frequency");
+ if (khz) {
+ ret = g_new0(dt_opp_range, 1);
+ ret->version = 0;
+ ret->khz_max = khz;
+ ret->clock_latency_ns = dtr_get_prop_u32(s, obj, "clock-latency");
+ }
+ }
goto get_opp_finish;
+ } else {
+ /* use v2 if both available */
+ dtr_obj_free(table_obj);
+ table_obj = NULL;
+ }
opp_table_path = dtr_phandle_lookup(s, opp_ph);
if (!opp_table_path)
@@ -971,6 +1003,7 @@ dt_opp_range *dtr_get_opp_range(dtr *s, const char *name) {
goto get_opp_finish;
ret = g_new0(dt_opp_range, 1);
+ ret->version = 2;
ret->phandle = opp_ph;
full_path = dtr_obj_full_path(table_obj);
diff --git a/includes/dt_util.h b/includes/dt_util.h
index 5f2f3233..0c5dcfa8 100644
--- a/includes/dt_util.h
+++ b/includes/dt_util.h
@@ -30,6 +30,7 @@ enum {
DTP_CLOCKS, /* <phref, #clock-cells> */
DTP_GPIOS, /* <phref, #gpio-cells> */
DTP_DMAS, /* dma-specifier list */
+ DTP_OPP1, /* list of operating points, pairs of (kHz,uV) */
DTP_PH_REF_OPP2, /* phandle reference to opp-v2 table */
};
@@ -91,9 +92,10 @@ void dtr_msg(dtr *s, char *fmt, ...);
* ex: ret = appf(ret, "%s=%s\n", name, value); */
char *appf(char *src, char *fmt, ...);
-/* operating-points-v2 */
+/* operating-points v0,v1,v2 */
typedef struct {
- uint32_t phandle;
+ uint32_t version; /* opp version, 0 = clock-frequency only */
+ uint32_t phandle; /* v2 only */
uint32_t khz_min;
uint32_t khz_max;
uint32_t clock_latency_ns;
diff --git a/modules/devices/gpu.c b/modules/devices/gpu.c
index 19aadef9..eb921bb3 100644
--- a/modules/devices/gpu.c
+++ b/modules/devices/gpu.c
@@ -195,14 +195,21 @@ int _dt_soc_gpu(gpud *gpu) {
gchar *opp_str;
if (gpu->dt_opp) {
- opp_str = g_strdup_printf("[%s %s]\n"
+ static const char *freq_src[] = {
+ N_("clock-frequency property"),
+ N_("Operating Points (OPPv1)"),
+ N_("Operating Points (OPPv2)"),
+ };
+ opp_str = g_strdup_printf("[%s]\n"
/* MinFreq */ "%s=%d %s\n"
/* MaxFreq */ "%s=%d %s\n"
- /* Latency */ "%s=%d %s\n",
- _("Frequency Scaling"), _("(OPPv2)"),
+ /* Latency */ "%s=%d %s\n"
+ /* Source */ "%s=%s\n",
+ _("Frequency Scaling"),
_("Minimum"), gpu->dt_opp->khz_min, _("kHz"),
_("Maximum"), gpu->dt_opp->khz_max, _("kHz"),
- _("Transition Latency"), gpu->dt_opp->clock_latency_ns, _("ns") );
+ _("Transition Latency"), gpu->dt_opp->clock_latency_ns, _("ns"),
+ _("Source"), _(freq_src[gpu->dt_opp->version]) );
} else
opp_str = strdup("");