|
25 | 25 | #define MLXSW_THERMAL_ZONE_MAX_NAME 16 |
26 | 26 | #define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0) |
27 | 27 | #define MLXSW_THERMAL_MAX_STATE 10 |
| 28 | +#define MLXSW_THERMAL_MIN_STATE 2 |
28 | 29 | #define MLXSW_THERMAL_MAX_DUTY 255 |
29 | | -/* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Values |
30 | | - * MLXSW_THERMAL_MAX_STATE + x, where x is between 2 and 10 are used for |
31 | | - * setting fan speed dynamic minimum. For example, if value is set to 14 (40%) |
32 | | - * cooling levels vector will be set to 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10 to |
33 | | - * introduce PWM speed in percent: 40, 40, 40, 40, 40, 50, 60. 70, 80, 90, 100. |
34 | | - */ |
35 | | -#define MLXSW_THERMAL_SPEED_MIN (MLXSW_THERMAL_MAX_STATE + 2) |
36 | | -#define MLXSW_THERMAL_SPEED_MAX (MLXSW_THERMAL_MAX_STATE * 2) |
37 | | -#define MLXSW_THERMAL_SPEED_MIN_LEVEL 2 /* 20% */ |
38 | 30 |
|
39 | 31 | /* External cooling devices, allowed for binding to mlxsw thermal zones. */ |
40 | 32 | static char * const mlxsw_thermal_external_allowed_cdev[] = { |
@@ -703,49 +695,16 @@ static int mlxsw_thermal_set_cur_state(struct thermal_cooling_device *cdev, |
703 | 695 | struct mlxsw_thermal *thermal = cdev->devdata; |
704 | 696 | struct device *dev = thermal->bus_info->dev; |
705 | 697 | char mfsc_pl[MLXSW_REG_MFSC_LEN]; |
706 | | - unsigned long cur_state, i; |
707 | 698 | int idx; |
708 | | - u8 duty; |
709 | 699 | int err; |
710 | 700 |
|
| 701 | + if (state > MLXSW_THERMAL_MAX_STATE) |
| 702 | + return -EINVAL; |
| 703 | + |
711 | 704 | idx = mlxsw_get_cooling_device_idx(thermal, cdev); |
712 | 705 | if (idx < 0) |
713 | 706 | return idx; |
714 | 707 |
|
715 | | - /* Verify if this request is for changing allowed fan dynamical |
716 | | - * minimum. If it is - update cooling levels accordingly and update |
717 | | - * state, if current state is below the newly requested minimum state. |
718 | | - * For example, if current state is 5, and minimal state is to be |
719 | | - * changed from 4 to 6, thermal->cooling_levels[0 to 5] will be changed |
720 | | - * all from 4 to 6. And state 5 (thermal->cooling_levels[4]) should be |
721 | | - * overwritten. |
722 | | - */ |
723 | | - if (state >= MLXSW_THERMAL_SPEED_MIN && |
724 | | - state <= MLXSW_THERMAL_SPEED_MAX) { |
725 | | - state -= MLXSW_THERMAL_MAX_STATE; |
726 | | - for (i = 0; i <= MLXSW_THERMAL_MAX_STATE; i++) |
727 | | - thermal->cooling_levels[i] = max(state, i); |
728 | | - |
729 | | - mlxsw_reg_mfsc_pack(mfsc_pl, idx, 0); |
730 | | - err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsc), mfsc_pl); |
731 | | - if (err) |
732 | | - return err; |
733 | | - |
734 | | - duty = mlxsw_reg_mfsc_pwm_duty_cycle_get(mfsc_pl); |
735 | | - cur_state = mlxsw_duty_to_state(duty); |
736 | | - |
737 | | - /* If current fan state is lower than requested dynamical |
738 | | - * minimum, increase fan speed up to dynamical minimum. |
739 | | - */ |
740 | | - if (state < cur_state) |
741 | | - return 0; |
742 | | - |
743 | | - state = cur_state; |
744 | | - } |
745 | | - |
746 | | - if (state > MLXSW_THERMAL_MAX_STATE) |
747 | | - return -EINVAL; |
748 | | - |
749 | 708 | /* Normalize the state to the valid speed range. */ |
750 | 709 | state = thermal->cooling_levels[state]; |
751 | 710 | mlxsw_reg_mfsc_pack(mfsc_pl, idx, mlxsw_state_to_duty(state)); |
@@ -1040,8 +999,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, |
1040 | 999 |
|
1041 | 1000 | /* Initialize cooling levels per PWM state. */ |
1042 | 1001 | for (i = 0; i < MLXSW_THERMAL_MAX_STATE; i++) |
1043 | | - thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL, |
1044 | | - i); |
| 1002 | + thermal->cooling_levels[i] = max(MLXSW_THERMAL_MIN_STATE, i); |
1045 | 1003 |
|
1046 | 1004 | thermal->polling_delay = bus_info->low_frequency ? |
1047 | 1005 | MLXSW_THERMAL_SLOW_POLL_INT : |
|
0 commit comments