|
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[] = { |
@@ -620,49 +612,16 @@ static int mlxsw_thermal_set_cur_state(struct thermal_cooling_device *cdev, |
620 | 612 | struct mlxsw_thermal *thermal = cdev->devdata; |
621 | 613 | struct device *dev = thermal->bus_info->dev; |
622 | 614 | char mfsc_pl[MLXSW_REG_MFSC_LEN]; |
623 | | - unsigned long cur_state, i; |
624 | 615 | int idx; |
625 | | - u8 duty; |
626 | 616 | int err; |
627 | 617 |
|
| 618 | + if (state > MLXSW_THERMAL_MAX_STATE) |
| 619 | + return -EINVAL; |
| 620 | + |
628 | 621 | idx = mlxsw_get_cooling_device_idx(thermal, cdev); |
629 | 622 | if (idx < 0) |
630 | 623 | return idx; |
631 | 624 |
|
632 | | - /* Verify if this request is for changing allowed fan dynamical |
633 | | - * minimum. If it is - update cooling levels accordingly and update |
634 | | - * state, if current state is below the newly requested minimum state. |
635 | | - * For example, if current state is 5, and minimal state is to be |
636 | | - * changed from 4 to 6, thermal->cooling_levels[0 to 5] will be changed |
637 | | - * all from 4 to 6. And state 5 (thermal->cooling_levels[4]) should be |
638 | | - * overwritten. |
639 | | - */ |
640 | | - if (state >= MLXSW_THERMAL_SPEED_MIN && |
641 | | - state <= MLXSW_THERMAL_SPEED_MAX) { |
642 | | - state -= MLXSW_THERMAL_MAX_STATE; |
643 | | - for (i = 0; i <= MLXSW_THERMAL_MAX_STATE; i++) |
644 | | - thermal->cooling_levels[i] = max(state, i); |
645 | | - |
646 | | - mlxsw_reg_mfsc_pack(mfsc_pl, idx, 0); |
647 | | - err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsc), mfsc_pl); |
648 | | - if (err) |
649 | | - return err; |
650 | | - |
651 | | - duty = mlxsw_reg_mfsc_pwm_duty_cycle_get(mfsc_pl); |
652 | | - cur_state = mlxsw_duty_to_state(duty); |
653 | | - |
654 | | - /* If current fan state is lower than requested dynamical |
655 | | - * minimum, increase fan speed up to dynamical minimum. |
656 | | - */ |
657 | | - if (state < cur_state) |
658 | | - return 0; |
659 | | - |
660 | | - state = cur_state; |
661 | | - } |
662 | | - |
663 | | - if (state > MLXSW_THERMAL_MAX_STATE) |
664 | | - return -EINVAL; |
665 | | - |
666 | 625 | /* Normalize the state to the valid speed range. */ |
667 | 626 | state = thermal->cooling_levels[state]; |
668 | 627 | mlxsw_reg_mfsc_pack(mfsc_pl, idx, mlxsw_state_to_duty(state)); |
@@ -963,8 +922,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, |
963 | 922 |
|
964 | 923 | /* Initialize cooling levels per PWM state. */ |
965 | 924 | for (i = 0; i < MLXSW_THERMAL_MAX_STATE; i++) |
966 | | - thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL, |
967 | | - i); |
| 925 | + thermal->cooling_levels[i] = max(MLXSW_THERMAL_MIN_STATE, i); |
968 | 926 |
|
969 | 927 | thermal->polling_delay = bus_info->low_frequency ? |
970 | 928 | MLXSW_THERMAL_SLOW_POLL_INT : |
|
0 commit comments