|
24 | 24 | #define MLXSW_THERMAL_ZONE_MAX_NAME 16
|
25 | 25 | #define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0)
|
26 | 26 | #define MLXSW_THERMAL_MAX_STATE 10
|
| 27 | +#define MLXSW_THERMAL_MIN_STATE 2 |
27 | 28 | #define MLXSW_THERMAL_MAX_DUTY 255
|
28 |
| -/* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Values |
29 |
| - * MLXSW_THERMAL_MAX_STATE + x, where x is between 2 and 10 are used for |
30 |
| - * setting fan speed dynamic minimum. For example, if value is set to 14 (40%) |
31 |
| - * cooling levels vector will be set to 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10 to |
32 |
| - * introduce PWM speed in percent: 40, 40, 40, 40, 40, 50, 60. 70, 80, 90, 100. |
33 |
| - */ |
34 |
| -#define MLXSW_THERMAL_SPEED_MIN (MLXSW_THERMAL_MAX_STATE + 2) |
35 |
| -#define MLXSW_THERMAL_SPEED_MAX (MLXSW_THERMAL_MAX_STATE * 2) |
36 |
| -#define MLXSW_THERMAL_SPEED_MIN_LEVEL 2 /* 20% */ |
37 | 29 |
|
38 | 30 | /* External cooling devices, allowed for binding to mlxsw thermal zones. */
|
39 | 31 | static char * const mlxsw_thermal_external_allowed_cdev[] = {
|
@@ -646,49 +638,16 @@ static int mlxsw_thermal_set_cur_state(struct thermal_cooling_device *cdev,
|
646 | 638 | struct mlxsw_thermal *thermal = cdev->devdata;
|
647 | 639 | struct device *dev = thermal->bus_info->dev;
|
648 | 640 | char mfsc_pl[MLXSW_REG_MFSC_LEN];
|
649 |
| - unsigned long cur_state, i; |
650 | 641 | int idx;
|
651 |
| - u8 duty; |
652 | 642 | int err;
|
653 | 643 |
|
| 644 | + if (state > MLXSW_THERMAL_MAX_STATE) |
| 645 | + return -EINVAL; |
| 646 | + |
654 | 647 | idx = mlxsw_get_cooling_device_idx(thermal, cdev);
|
655 | 648 | if (idx < 0)
|
656 | 649 | return idx;
|
657 | 650 |
|
658 |
| - /* Verify if this request is for changing allowed fan dynamical |
659 |
| - * minimum. If it is - update cooling levels accordingly and update |
660 |
| - * state, if current state is below the newly requested minimum state. |
661 |
| - * For example, if current state is 5, and minimal state is to be |
662 |
| - * changed from 4 to 6, thermal->cooling_levels[0 to 5] will be changed |
663 |
| - * all from 4 to 6. And state 5 (thermal->cooling_levels[4]) should be |
664 |
| - * overwritten. |
665 |
| - */ |
666 |
| - if (state >= MLXSW_THERMAL_SPEED_MIN && |
667 |
| - state <= MLXSW_THERMAL_SPEED_MAX) { |
668 |
| - state -= MLXSW_THERMAL_MAX_STATE; |
669 |
| - for (i = 0; i <= MLXSW_THERMAL_MAX_STATE; i++) |
670 |
| - thermal->cooling_levels[i] = max(state, i); |
671 |
| - |
672 |
| - mlxsw_reg_mfsc_pack(mfsc_pl, idx, 0); |
673 |
| - err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsc), mfsc_pl); |
674 |
| - if (err) |
675 |
| - return err; |
676 |
| - |
677 |
| - duty = mlxsw_reg_mfsc_pwm_duty_cycle_get(mfsc_pl); |
678 |
| - cur_state = mlxsw_duty_to_state(duty); |
679 |
| - |
680 |
| - /* If current fan state is lower than requested dynamical |
681 |
| - * minimum, increase fan speed up to dynamical minimum. |
682 |
| - */ |
683 |
| - if (state < cur_state) |
684 |
| - return 0; |
685 |
| - |
686 |
| - state = cur_state; |
687 |
| - } |
688 |
| - |
689 |
| - if (state > MLXSW_THERMAL_MAX_STATE) |
690 |
| - return -EINVAL; |
691 |
| - |
692 | 651 | /* Normalize the state to the valid speed range. */
|
693 | 652 | state = thermal->cooling_levels[state];
|
694 | 653 | mlxsw_reg_mfsc_pack(mfsc_pl, idx, mlxsw_state_to_duty(state));
|
@@ -998,8 +957,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
|
998 | 957 |
|
999 | 958 | /* Initialize cooling levels per PWM state. */
|
1000 | 959 | for (i = 0; i < MLXSW_THERMAL_MAX_STATE; i++)
|
1001 |
| - thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL, |
1002 |
| - i); |
| 960 | + thermal->cooling_levels[i] = max(MLXSW_THERMAL_MIN_STATE, i); |
1003 | 961 |
|
1004 | 962 | thermal->polling_delay = bus_info->low_frequency ?
|
1005 | 963 | MLXSW_THERMAL_SLOW_POLL_INT :
|
|
0 commit comments