]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: meson: sm: Add thermal calibration SMC call
authorRonald Claveau <linux-kernel-dev@aliel.fr>
Fri, 24 Apr 2026 15:45:11 +0000 (17:45 +0200)
committerDaniel Lezcano <daniel.lezcano@kernel.org>
Tue, 26 May 2026 11:24:33 +0000 (13:24 +0200)
Add SM_THERMAL_CALIB_READ at SMC ID 0x82000047 in the command
table and implement meson_sm_get_thermal_calib(), which forwards the
tsensor_id argument to the secure monitor and returns the calibration data.

Also realign the CMD() column to improve readability.

Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
[ dlezcano: Fixed kernel-doc format warning ]
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20260424-add-thermal-t7-vim4-v5-3-9040ca36afe2@aliel.fr
drivers/firmware/meson/meson_sm.c

index 3ab67aaa9e5da9da7bd7ee66bf9da4f922d39d10..ab9751a59b552f40a541d45d7b0c3ca750519d9a 100644 (file)
@@ -41,12 +41,13 @@ static const struct meson_sm_chip gxbb_chip = {
        .cmd_shmem_in_base      = 0x82000020,
        .cmd_shmem_out_base     = 0x82000021,
        .cmd = {
-               CMD(SM_EFUSE_READ,      0x82000030),
-               CMD(SM_EFUSE_WRITE,     0x82000031),
+               CMD(SM_EFUSE_READ,              0x82000030),
+               CMD(SM_EFUSE_WRITE,             0x82000031),
                CMD(SM_EFUSE_USER_MAX,  0x82000033),
-               CMD(SM_GET_CHIP_ID,     0x82000044),
-               CMD(SM_A1_PWRC_SET,     0x82000093),
-               CMD(SM_A1_PWRC_GET,     0x82000095),
+               CMD(SM_GET_CHIP_ID,             0x82000044),
+               CMD(SM_THERMAL_CALIB_READ,      0x82000047),
+               CMD(SM_A1_PWRC_SET,             0x82000093),
+               CMD(SM_A1_PWRC_GET,             0x82000095),
                { /* sentinel */ },
        },
 };
@@ -245,6 +246,23 @@ struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node)
 }
 EXPORT_SYMBOL_GPL(meson_sm_get);
 
+/**
+ * meson_sm_get_thermal_calib - Read thermal sensor calibration data.
+ * @fw:                Pointer to secure-monitor firmware.
+ * @trim_info: Pointer to store the returned calibration data.
+ * @tsensor_id:        Sensor index to identify which sensor's calibration data
+ *             to retrieve
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32 *trim_info,
+                              u32 tsensor_id)
+{
+       return meson_sm_call(fw, SM_THERMAL_CALIB_READ, trim_info, tsensor_id,
+                            0, 0, 0, 0);
+}
+EXPORT_SYMBOL_GPL(meson_sm_get_thermal_calib);
+
 #define SM_CHIP_ID_LENGTH      119
 #define SM_CHIP_ID_OFFSET      4
 #define SM_CHIP_ID_SIZE                12