Lines 1-6
Link Here
|
1 |
/*- |
1 |
/*- |
2 |
* Copyright (c) 2004 Takanori Watanabe |
2 |
* Copyright (c) 2004 Takanori Watanabe |
3 |
* Copyright (c) 2005 Markus Brueffer <markus@FreeBSD.org> |
3 |
* Copyright (c) 2005 Markus Brueffer <markus@FreeBSD.org> |
|
|
4 |
* Copyright (c) 2020 Ali Abdallah <ali.abdallah@suse.com> |
4 |
* All rights reserved. |
5 |
* All rights reserved. |
5 |
* |
6 |
* |
6 |
* Redistribution and use in source and binary forms, with or without |
7 |
* Redistribution and use in source and binary forms, with or without |
Lines 256-262
Link Here
|
256 |
{ |
257 |
{ |
257 |
.name = "fan_level", |
258 |
.name = "fan_level", |
258 |
.method = ACPI_IBM_METHOD_FANLEVEL, |
259 |
.method = ACPI_IBM_METHOD_FANLEVEL, |
259 |
.description = "Fan level", |
260 |
.description = "Fan level, 0-7 (recommended max), 8 (disengaged, full-speed)", |
260 |
}, |
261 |
}, |
261 |
{ |
262 |
{ |
262 |
.name = "fan", |
263 |
.name = "fan", |
Lines 800-806
Link Here
|
800 |
*/ |
801 |
*/ |
801 |
if (!sc->fan_handle) { |
802 |
if (!sc->fan_handle) { |
802 |
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1); |
803 |
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1); |
803 |
val = val_ec & IBM_EC_MASK_FANLEVEL; |
804 |
if (val_ec & IBM_EC_MASK_FANDISENGAGED) |
|
|
805 |
val = 8; |
806 |
else |
807 |
val = val_ec & IBM_EC_MASK_FANLEVEL; |
804 |
} |
808 |
} |
805 |
break; |
809 |
break; |
806 |
|
810 |
|
Lines 875-889
Link Here
|
875 |
break; |
879 |
break; |
876 |
|
880 |
|
877 |
case ACPI_IBM_METHOD_FANLEVEL: |
881 |
case ACPI_IBM_METHOD_FANLEVEL: |
878 |
if (arg < 0 || arg > 7) |
882 |
if (arg < 0 || arg > 8) |
879 |
return (EINVAL); |
883 |
return (EINVAL); |
880 |
|
884 |
|
881 |
if (!sc->fan_handle) { |
885 |
if (!sc->fan_handle) { |
882 |
/* Read the current fanstatus */ |
886 |
/* Read the current fanstatus */ |
883 |
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1); |
887 |
ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1); |
884 |
val = val_ec & (~IBM_EC_MASK_FANLEVEL); |
888 |
val = val_ec & (~IBM_EC_MASK_FANLEVEL) & (~IBM_EC_MASK_FANDISENGAGED); |
885 |
|
889 |
|
886 |
return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val | arg, 1); |
890 |
/* Full speed, set the disengaged bit */ |
|
|
891 |
if (arg == 8) |
892 |
val |= 7 | IBM_EC_MASK_FANDISENGAGED; |
893 |
else |
894 |
val |= arg; |
895 |
|
896 |
return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val, 1); |
887 |
} |
897 |
} |
888 |
break; |
898 |
break; |
889 |
|
899 |
|