Fetch calibration data for thermal monitor

- Thermal calibration data is stored in fuses on the device. Enable the
efuse module to let us pull the data via the nvmem APIs.
- In the thermal driver, pull the calibration data via nvmem, using
indices derived from the old 4.4 kernel.

Change-Id: I540d42e5058ff414fcef42e30407426774b4e1bb
diff --git a/arch/arm64/boot/dts/mediatek/mt8167-coral.dts b/arch/arm64/boot/dts/mediatek/mt8167-coral.dts
index 8f93985..d860910 100644
--- a/arch/arm64/boot/dts/mediatek/mt8167-coral.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8167-coral.dts
@@ -104,8 +104,20 @@
 		clock-names = "therm", "auxadc";
 		mediatek,auxadc = <&auxadc>;
 		mediatek,apmixedsys = <&apmixedsys>;
+		nvmem-cells = <&thermal_calibration>;
+		nvmem-cell-names = "calibration-data";
 	};
 
+	efuse: efuse@10009000 {
+		compatible = "mediatek,mt8173-efuse";
+		reg = <0 0x10009000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		thermal_calibration: calib@180 {
+			reg = <0x180 0xc>;
+		};
+};
+
 	thermal-zones {
 		cpu_thermal: cpu_thermal {
 			polling-delay-passive = <1000>; /* ms */
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index f80d685..f2d2a98 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -885,6 +885,15 @@
 		goto out;
 	}
 
+	// MT8516 stores the 3 words of calibration data
+	// at indices 0x184, 0x180, 0x188.
+	// The nvmem APIs give us the values in order that
+	// they are laid out, so we need to swap the first two
+	// words.
+	if (mt->conf == &mt8516_thermal_data) {
+		swap(buf[0], buf[1]);
+	}
+
 	if (buf[0] & CALIB_BUF0_VALID) {
 		mt->adc_ge = CALIB_BUF1_ADC_GE(buf[1]);