Commit Graph

19 Commits

Author SHA1 Message Date
Tim Crawford
a7bd81432e fan: Allow FAN2 without dGPU
Fully support fan points for the second fan on darp10.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
ffd0b7cbde fan: Do not make functions reentrant
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
e75a2f1e10 Improve handling of second fan
Replace hard-coded PWM channels with defines so the second fan on darp10
can be handled like the second fan on units with a dGPU.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
f8697a7ec4 Make fan names more generic
darp10 demonstrates that a board without a dGPU may still have a second
fan, so rename the CPU (PECI) fan to FAN1 and dGPU fan to FAN2.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
ceba69d7fa Refactor reading thermals, updating fan duty
Move the fan-related logic from the PECI and dGPU modules to the fan
module. The PECI and dGPU modules are now only responsible for reading
the thermal data, and the fan module handles calculating and updating
the fans duties based on that data.
2024-07-17 16:28:39 -06:00
Tim Crawford
d3894392d5 Replace clang-format with uncrustify
LLVM/clang is not used for any compilation due to it not supporting the
8-bit architectures we use (MCS-51, AVR). This means we are effectively
installing 250+ MiB of dependencies for a C formatting tool.

Replace it with uncrustify, which uses only ~600 KiB of space and has
more granular control of formatting (800+ options).

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-03 15:58:28 -06:00
Tim Crawford
b744529960 [HACK] darp10: Set FAN2 duty to FAN1
This model has a second CPU fan connected to PWM3.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-05-07 14:35:29 -06:00
Tim Crawford
9fb08ffa46 Mark pointers as const
Resulting binaries are identical.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-03-18 14:27:36 -06:00
Tim Crawford
e032c5f0f2 Update .clang-format and apply
Update .clang-format for LLVM 14.0, available on Ubuntu 22.04.

There is still plenty that clang-format sucks at or does wrong, so
either add some more blocks to disable it, or just put up with it.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-01-10 12:02:21 -07:00
Tim Crawford
ee8ba5b72e fan: Replace 'static const' with defines
SDCC is not able to optimize statics [1]. Replace their use with defines
so significantly better code is generated.

[1]: https://sourceforge.net/p/sdcc/feature-requests/414/

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-03-18 12:47:20 -06:00
Tim Crawford
784202383e fan: Use u8 for array access
The index will never be negative and will never exceed 255. Change them
from i16 to u8 so SDCC will generate more efficient code.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-08-02 14:37:08 -06:00
Tim Crawford
99af8a35f5 Use explicitly sized types from stdint
Replace bare int types with stdint types. This was done with:

    grep -rwl 'int' src/ | xargs sed -i 's/\<int\>/int16_t/g'
    grep -rwl 'unsigned long' src/ | xargs sed -i 's/\<unsigned long\>/uint32_t/g'
    grep -rwl 'unsigned char' src/ | xargs sed -i 's/\<unsigned char\>/uint8_t/g'

Then reverted for *main(), putchar(), and getchar().

The Arduino declarations for parallel_main() were also corrected to
match their definitions.

SDCC does *not* generate the same code in all instances, due to `int`
being treated different than `short int`.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-08-02 07:46:44 -06:00
Jeremy Soller
90057df94f Change repetitive prints from DEBUG to TRACE 2021-07-20 10:49:08 -06:00
Winston Hoy
8ea0403850 Smooth fan speed changes (#190)
* SMOOTH_FANS, SMOOTH_FANS_UP, SMOOTH_FANS_DOWN build flags to smooth fan speed changes.
Defaults 40, set SMOOTH_FANS=0 to disable and keep sharp fan speed changes

* fix for ACPI CPU temperature

* allow for a floor to be set for fan smoothing and specifically configure oryp6/7 to start smoothing at 25% to mitigate fan buzzing below 25%

* update default config values for fans

* update all devices to use defaults for heatup, cooldown, update galp5 fan curves

* Decrease default cooldown time from 20 to 10

Co-authored-by: Jacob Kauffmann <jacob@system76.com>
2021-06-14 14:22:29 -06:00
Winston Hoy
606ba01b48 default to fan syncing but support disabling fan syncing with SYNC_FANS=0 build flag 2021-05-01 06:33:40 -06:00
Winston Hoy
f0c42f5839 Sync dGPU and PECI fans (at highest requested duty) 2021-05-01 06:33:40 -06:00
Jeremy Soller
d35e375277 Add fan abstraction 2020-10-05 10:50:11 -07:00
Jeremy Soller
788fa927ef Add SPDX license header to fan.c 2020-10-05 10:50:11 -07:00
Jeremy Soller
a8f5fc5ec0 Add fan module and implement fan_max switch 2020-10-05 10:50:11 -07:00