@@ -126,8 +126,14 @@ struct lvts_ctrl_data {
126126 continue; \
127127 else
128128
129+ struct lvts_platform_ops {
130+ int (* lvts_raw_to_temp )(u32 raw_temp , int temp_factor );
131+ u32 (* lvts_temp_to_raw )(int temperature , int temp_factor );
132+ };
133+
129134struct lvts_data {
130135 const struct lvts_ctrl_data * lvts_ctrl ;
136+ const struct lvts_platform_ops * ops ;
131137 const u32 * conn_cmd ;
132138 const u32 * init_cmd ;
133139 int num_cal_offsets ;
@@ -273,7 +279,17 @@ static inline int lvts_debugfs_init(struct device *dev,
273279
274280#endif
275281
276- static int lvts_raw_to_temp (u32 raw_temp , int temp_factor )
282+ static int lvts_raw_to_temp (u32 raw_temp , const struct lvts_data * lvts_data )
283+ {
284+ return lvts_data -> ops -> lvts_raw_to_temp (raw_temp & 0xFFFF , lvts_data -> temp_factor );
285+ }
286+
287+ static u32 lvts_temp_to_raw (int temperature , const struct lvts_data * lvts_data )
288+ {
289+ return lvts_data -> ops -> lvts_temp_to_raw (temperature , lvts_data -> temp_factor );
290+ }
291+
292+ static int lvts_raw_to_temp_mt7988 (u32 raw_temp , int temp_factor )
277293{
278294 int temperature ;
279295
@@ -283,7 +299,7 @@ static int lvts_raw_to_temp(u32 raw_temp, int temp_factor)
283299 return temperature ;
284300}
285301
286- static u32 lvts_temp_to_raw (int temperature , int temp_factor )
302+ static u32 lvts_temp_to_raw_mt7988 (int temperature , int temp_factor )
287303{
288304 u32 raw_temp = ((s64 )(golden_temp_offset - temperature )) << 14 ;
289305
@@ -330,7 +346,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
330346 if (rc )
331347 return - EAGAIN ;
332348
333- * temp = lvts_raw_to_temp (value & 0xFFFF , lvts_data -> temp_factor );
349+ * temp = lvts_raw_to_temp (value , lvts_data );
334350
335351 return 0 ;
336352}
@@ -400,8 +416,8 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
400416 const struct lvts_data * lvts_data = lvts_ctrl -> lvts_data ;
401417 void __iomem * base = lvts_sensor -> base ;
402418 u32 raw_low = lvts_temp_to_raw (low != - INT_MAX ? low : LVTS_MINIMUM_THRESHOLD ,
403- lvts_data -> temp_factor );
404- u32 raw_high = lvts_temp_to_raw (high , lvts_data -> temp_factor );
419+ lvts_data );
420+ u32 raw_high = lvts_temp_to_raw (high , lvts_data );
405421 bool should_update_thresh ;
406422
407423 lvts_sensor -> low_thresh = low ;
@@ -1778,6 +1794,11 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
17781794 }
17791795};
17801796
1797+ static const struct lvts_platform_ops lvts_platform_ops_mt7988 = {
1798+ .lvts_raw_to_temp = lvts_raw_to_temp_mt7988 ,
1799+ .lvts_temp_to_raw = lvts_temp_to_raw_mt7988 ,
1800+ };
1801+
17811802static const struct lvts_data mt7988_lvts_ap_data = {
17821803 .lvts_ctrl = mt7988_lvts_ap_data_ctrl ,
17831804 .conn_cmd = mt7988_conn_cmds ,
@@ -1789,6 +1810,7 @@ static const struct lvts_data mt7988_lvts_ap_data = {
17891810 .temp_offset = LVTS_COEFF_B_MT7988 ,
17901811 .gt_calib_bit_offset = 24 ,
17911812 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1813+ .ops = & lvts_platform_ops_mt7988 ,
17921814};
17931815
17941816static const struct lvts_data mt8186_lvts_data = {
@@ -1803,6 +1825,7 @@ static const struct lvts_data mt8186_lvts_data = {
18031825 .gt_calib_bit_offset = 24 ,
18041826 .def_calibration = 19000 ,
18051827 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1828+ .ops = & lvts_platform_ops_mt7988 ,
18061829};
18071830
18081831static const struct lvts_data mt8188_lvts_mcu_data = {
@@ -1817,6 +1840,7 @@ static const struct lvts_data mt8188_lvts_mcu_data = {
18171840 .gt_calib_bit_offset = 20 ,
18181841 .def_calibration = 35000 ,
18191842 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1843+ .ops = & lvts_platform_ops_mt7988 ,
18201844};
18211845
18221846static const struct lvts_data mt8188_lvts_ap_data = {
@@ -1831,6 +1855,7 @@ static const struct lvts_data mt8188_lvts_ap_data = {
18311855 .gt_calib_bit_offset = 20 ,
18321856 .def_calibration = 35000 ,
18331857 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1858+ .ops = & lvts_platform_ops_mt7988 ,
18341859};
18351860
18361861static const struct lvts_data mt8192_lvts_mcu_data = {
@@ -1845,6 +1870,7 @@ static const struct lvts_data mt8192_lvts_mcu_data = {
18451870 .gt_calib_bit_offset = 24 ,
18461871 .def_calibration = 35000 ,
18471872 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1873+ .ops = & lvts_platform_ops_mt7988 ,
18481874};
18491875
18501876static const struct lvts_data mt8192_lvts_ap_data = {
@@ -1859,6 +1885,7 @@ static const struct lvts_data mt8192_lvts_ap_data = {
18591885 .gt_calib_bit_offset = 24 ,
18601886 .def_calibration = 35000 ,
18611887 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1888+ .ops = & lvts_platform_ops_mt7988 ,
18621889};
18631890
18641891static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1873,6 +1900,7 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
18731900 .gt_calib_bit_offset = 24 ,
18741901 .def_calibration = 35000 ,
18751902 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1903+ .ops = & lvts_platform_ops_mt7988 ,
18761904};
18771905
18781906static const struct lvts_data mt8195_lvts_ap_data = {
@@ -1887,6 +1915,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
18871915 .gt_calib_bit_offset = 24 ,
18881916 .def_calibration = 35000 ,
18891917 .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT7988 ,
1918+ .ops = & lvts_platform_ops_mt7988 ,
18901919};
18911920
18921921static const struct of_device_id lvts_of_match [] = {
0 commit comments