developer | 43a264f | 2024-03-26 14:09:54 +0800 | [diff] [blame^] | 1 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |
| 2 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |
| 3 | @@ -531,7 +531,11 @@ struct iwl_mvm_tt_mgmt { |
| 4 | * @tzone: thermal zone device data |
| 5 | */ |
| 6 | struct iwl_mvm_thermal_device { |
| 7 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 8 | s16 temp_trips[IWL_MAX_DTS_TRIPS]; |
| 9 | +#else |
| 10 | + struct thermal_trip trips[IWL_MAX_DTS_TRIPS]; |
| 11 | +#endif |
| 12 | u8 fw_trips_index[IWL_MAX_DTS_TRIPS]; |
| 13 | struct thermal_zone_device *tzone; |
| 14 | }; |
| 15 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c |
| 16 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c |
| 17 | @@ -573,6 +573,7 @@ int iwl_mvm_send_temp_report_ths_cmd(str |
| 18 | * and uncompressed, the FW should get it compressed and sorted |
| 19 | */ |
| 20 | |
| 21 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 22 | /* compress temp_trips to cmd array, remove uninitialized values*/ |
| 23 | for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { |
| 24 | if (mvm->tz_device.temp_trips[i] != S16_MIN) { |
| 25 | @@ -580,6 +581,15 @@ int iwl_mvm_send_temp_report_ths_cmd(str |
| 26 | cpu_to_le16(mvm->tz_device.temp_trips[i]); |
| 27 | } |
| 28 | } |
| 29 | +#else |
| 30 | + /* compress trips to cmd array, remove uninitialized values*/ |
| 31 | + for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { |
| 32 | + if (mvm->tz_device.trips[i].temperature != INT_MIN) { |
| 33 | + cmd.thresholds[idx++] = |
| 34 | + cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000)); |
| 35 | + } |
| 36 | + } |
| 37 | +#endif |
| 38 | cmd.num_temps = cpu_to_le32(idx); |
| 39 | |
| 40 | if (!idx) |
| 41 | @@ -593,8 +603,13 @@ int iwl_mvm_send_temp_report_ths_cmd(str |
| 42 | */ |
| 43 | for (i = 0; i < idx; i++) { |
| 44 | for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) { |
| 45 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 46 | if (le16_to_cpu(cmd.thresholds[i]) == |
| 47 | mvm->tz_device.temp_trips[j]) |
| 48 | +#else |
| 49 | + if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) == |
| 50 | + mvm->tz_device.trips[j].temperature) |
| 51 | +#endif |
| 52 | mvm->tz_device.fw_trips_index[i] = j; |
| 53 | } |
| 54 | } |
| 55 | @@ -638,6 +653,7 @@ out: |
| 56 | return ret; |
| 57 | } |
| 58 | |
| 59 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 60 | static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device, |
| 61 | int trip, int *temp) |
| 62 | { |
| 63 | @@ -661,14 +677,19 @@ static int iwl_mvm_tzone_get_trip_type(s |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | +#endif |
| 68 | |
| 69 | static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, |
| 70 | int trip, int temp) |
| 71 | { |
| 72 | struct iwl_mvm *mvm = thermal_zone_device_priv(device); |
| 73 | struct iwl_mvm_thermal_device *tzone; |
| 74 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 75 | int i, ret; |
| 76 | s16 temperature; |
| 77 | +#else |
| 78 | + int ret; |
| 79 | +#endif |
| 80 | |
| 81 | mutex_lock(&mvm->mutex); |
| 82 | |
| 83 | @@ -678,17 +699,21 @@ static int iwl_mvm_tzone_set_trip_temp(s |
| 84 | goto out; |
| 85 | } |
| 86 | |
| 87 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 88 | if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) { |
| 89 | ret = -EINVAL; |
| 90 | goto out; |
| 91 | } |
| 92 | +#endif |
| 93 | |
| 94 | if ((temp / 1000) > S16_MAX) { |
| 95 | ret = -EINVAL; |
| 96 | goto out; |
| 97 | } |
| 98 | |
| 99 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 100 | temperature = (s16)(temp / 1000); |
| 101 | +#endif |
| 102 | tzone = &mvm->tz_device; |
| 103 | |
| 104 | if (!tzone) { |
| 105 | @@ -696,6 +721,7 @@ static int iwl_mvm_tzone_set_trip_temp(s |
| 106 | goto out; |
| 107 | } |
| 108 | |
| 109 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 110 | /* no updates*/ |
| 111 | if (tzone->temp_trips[trip] == temperature) { |
| 112 | ret = 0; |
| 113 | @@ -711,6 +737,7 @@ static int iwl_mvm_tzone_set_trip_temp(s |
| 114 | } |
| 115 | |
| 116 | tzone->temp_trips[trip] = temperature; |
| 117 | +#endif |
| 118 | |
| 119 | ret = iwl_mvm_send_temp_report_ths_cmd(mvm); |
| 120 | out: |
| 121 | @@ -720,8 +747,10 @@ out: |
| 122 | |
| 123 | static struct thermal_zone_device_ops tzone_ops = { |
| 124 | .get_temp = iwl_mvm_tzone_get_temp, |
| 125 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 126 | .get_trip_temp = iwl_mvm_tzone_get_trip_temp, |
| 127 | .get_trip_type = iwl_mvm_tzone_get_trip_type, |
| 128 | +#endif |
| 129 | .set_trip_temp = iwl_mvm_tzone_set_trip_temp, |
| 130 | }; |
| 131 | |
| 132 | @@ -743,7 +772,12 @@ static void iwl_mvm_thermal_zone_registe |
| 133 | BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH); |
| 134 | |
| 135 | sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF); |
| 136 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 137 | mvm->tz_device.tzone = thermal_zone_device_register(name, |
| 138 | +#else |
| 139 | + mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, |
| 140 | + mvm->tz_device.trips, |
| 141 | +#endif |
| 142 | IWL_MAX_DTS_TRIPS, |
| 143 | IWL_WRITABLE_TRIPS_MSK, |
| 144 | mvm, &tzone_ops, |
| 145 | @@ -766,8 +800,15 @@ static void iwl_mvm_thermal_zone_registe |
| 146 | /* 0 is a valid temperature, |
| 147 | * so initialize the array with S16_MIN which invalid temperature |
| 148 | */ |
| 149 | +#if LINUX_VERSION_IS_LESS(6,6,0) |
| 150 | for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) |
| 151 | mvm->tz_device.temp_trips[i] = S16_MIN; |
| 152 | +#else |
| 153 | + for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) { |
| 154 | + mvm->tz_device.trips[i].temperature = INT_MIN; |
| 155 | + mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; |
| 156 | + } |
| 157 | +#endif |
| 158 | } |
| 159 | |
| 160 | static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev, |