aboutsummaryrefslogtreecommitdiff
path: root/hw/dts.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2017-01-20 16:29:37 +0100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-03-16 17:17:24 +1100
commitf703a23b24317c8c524077f728e03cf669765198 (patch)
tree53b92bb6af63ec19ac75fa33c016d2c37f9ed89a /hw/dts.c
parent04aaed9bcba35a87d7ac50beb60757087c1d6e42 (diff)
downloadskiboot-f703a23b24317c8c524077f728e03cf669765198.zip
skiboot-f703a23b24317c8c524077f728e03cf669765198.tar.gz
skiboot-f703a23b24317c8c524077f728e03cf669765198.tar.bz2
dts: introduce a dts_keep_max() routine
This routine will also be used for reading the p9 core DTS and it saves a couple of lines in skiboot. Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/dts.c')
-rw-r--r--hw/dts.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/hw/dts.c b/hw/dts.c
index 4d7e38f..4fd97e7 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -115,6 +115,24 @@ static void dts_decode_one_dts(uint16_t raw, struct dts *dts)
}
}
+static void dts_keep_max(struct dts *temps, int n, struct dts *dts)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ int16_t t = temps[i].temp;
+
+ if (!temps[i].valid)
+ continue;
+
+ if (t > dts->temp)
+ dts->temp = t;
+
+ dts->valid++;
+ dts->trip |= temps[i].trip;
+ }
+}
+
/* Per core Digital Thermal Sensors */
#define EX_THERM_DTS_RESULT0 0x10050000
#define EX_THERM_DTS_RESULT1 0x10050001
@@ -136,7 +154,6 @@ static int dts_read_core_temp_p8(uint32_t pir, struct dts *dts)
int32_t core = pir_to_core_id(pir);
uint64_t dts0, dts1;
struct dts temps[P8_CT_ZONES];
- int i;
int rc;
rc = xscom_read(chip_id, XSCOM_ADDR_P8_EX(core, EX_THERM_DTS_RESULT0),
@@ -154,19 +171,7 @@ static int dts_read_core_temp_p8(uint32_t pir, struct dts *dts)
dts_decode_one_dts(dts0 >> 16, &temps[P8_CT_ZONE_FXU]);
dts_decode_one_dts(dts1 >> 48, &temps[P8_CT_ZONE_L3C]);
- for (i = 0; i < P8_CT_ZONES; i++) {
- int16_t t = temps[i].temp;
-
- if (!temps[i].valid)
- continue;
-
- /* keep the max temperature of all 4 sensors */
- if (t > dts->temp)
- dts->temp = t;
-
- dts->valid++;
- dts->trip |= temps[i].trip;
- }
+ dts_keep_max(temps, P8_CT_ZONES, dts);
prlog(PR_TRACE, "DTS: Chip %x Core %x temp:%dC trip:%x\n",
chip_id, core, dts->temp, dts->trip);