Commit Graph

43 Commits

Author SHA1 Message Date
Tim Crawford
1e02be1cbe Format with uncrustify
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-03 15:58:28 -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
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
946415f3a7 peci: Add timeouts to infinitely blocking waits
Add timeouts to the legacy PECI implementation to prevent the EC locking
up when PECI stops working, such as during S0ix opportunistic suspend.

This is not the optimal solution, as PECI should not be available at all
to cause the lock up in the first place, but it at least prevents the
issue.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-12 09:09:20 -06:00
Tim Crawford
b63e2092ce peci: Check PECI available based on eSPI usage
If eSPI is used, use Virtual Wires to determine if PECI is available.

Fixes incorrectly reporting PECI as available on systems using S0ix, as
the CPU would be in C10 but `PLTRST#` would not be asserted.

Requires enabling `HOST_C10` reporting in FSP-S.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-08-01 14:24:21 -06:00
Tim Crawford
dd555b9012 peci: Clear status on completion
The PECI-over-eSPI implementation, like the legacy implementation, must
acknowledge when the transaction is done by clearing the bit in the
register.

Fixes a hang during shutdown on oryp11 after unplugging a TBT display.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-21 12:44:12 -06:00
Tim Crawford
3eaa5e6e06 Only use PECI over eSPI on oryp11
Make all boards except oryp11 use the legacy PECI implementation. The
oryp11 removed the legacy pin (H_PECI) and must use PECI over eSPI.

All boards that use eSPI should switch to using PECI over eSPI once the
implementation is working correctly.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-04-03 13:06:16 -06:00
Jeremy Soller
8228362c5d Do not try to use peci between VW_HOST_RST_WARN and VW_PLTRST_N 2023-04-03 13:06:16 -06:00
Tim Crawford
4567f99015 peci: Clear status after command completion
Per the flow charts for PECI programming guide, clear the status
register after the command has completed.

Ref: IT5570E V0.3.2 datasheet
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-04-03 13:06:16 -06:00
Tim Crawford
3dde812dba peci: Check FINISH for completed transaction
Per the IT5570E datasheet, FINISH should be used to check if a
transaction completed, not HOBY.

> For the polling mode, software continues reading the Host Status
> Register to check whether the transaction is completed or not (the
> Finish bit in the Host Status Register will be set when the
> transaction is completed).

Ref: IT5570E V0.3.2 datasheet
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-04-03 13:06:16 -06:00
Tim Crawford
dd97946056 peci: Check for hardware error
Check if any hardware error bits are set instead of checking for only
command completion.

Move logging of WrPkgConfig() errors from power to peci.

Ref: IT5570E V0.3.2 datasheet
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-04-03 13:06:16 -06:00
Jeremy Soller
4aeb3669a0 Fix formatting 2023-04-03 13:06:16 -06:00
Jeremy Soller
ba5438a79a Update power state prior to using PECI 2023-04-03 13:06:16 -06:00
Jeremy Soller
cb8e0971c6 PECI ESPI timeout of 10ms 2023-04-03 13:06:16 -06:00
Jeremy Soller
0d438a3314 Make sure power_state is S0 before attempting PECI 2023-04-03 13:06:16 -06:00
Jeremy Soller
962d55309a Gate peci_available on ESPI availability 2023-04-03 13:06:16 -06:00
Jeremy Soller
35d3c4f161 Fix style 2023-04-03 13:06:16 -06:00
Jeremy Soller
a0c81f6304 Improvements for determining CPU state using virtual wires 2023-04-03 13:06:16 -06:00
Jeremy Soller
4e11f6220b Fix comparisons of vw_get values 2023-04-03 13:06:16 -06:00
Jeremy Soller
cea89a78d8 Use ESPI VW signals wherever possible 2023-04-03 13:06:16 -06:00
Jeremy Soller
cda67e6d1e Fix stalls in getting PECI information over eSPI 2023-04-03 13:06:16 -06:00
Jeremy Soller
9abd9d853a common: peci: WIP peci_get_temp over espi 2023-04-03 13:06:16 -06:00
Jeremy Soller
95a654aaff common: peci: Remove extra shift in peci_get_temp 2023-04-03 13:06:16 -06:00
Jeremy Soller
53f22a6658 common: Break out PECI GetTemp logic, prepare for PECI over ESPI 2023-04-03 13:06:16 -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
Michał Kopeć
cc3effb6a4 board/system76/common: use SLP_S0# pin for modern standby detection
Previously, CPU_C10_GATE# was used for detecting entry into s0ix /
Modern Standby.

Intel documentation says that SLP_S0# should be used for s0ix detection
instead, and CPU_C10_GATE# is intended for VCCSTG power gating, so
switch the pin to improve s0ix detection reliability.

Fixes https://github.com/system76/firmware-open/issues/199

References:

- Intel docs #575570 rev 0.5, #607872 rev 2.2
- Chromium EC: https://chromium.googlesource.com/chromiumos/platform/ec/+/master/power/intel_x86.c#41

Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2022-08-30 08:47:30 -06:00
Tim Crawford
49abf83c08 Add config for using S0ix
S0ix does not require eSPI, and eSPI does not mandate S0ix.

Enable S0ix for:

- darp7 (TGL-U)
- darp8 (ADL-P)
- galp5 (TGL-U)
- galp6 (ADL-P)
- lemp10 (TGL-U)
- lemp11 (ADL-U)

It is also currently enabled on ADL-H due to a bug with S3:

- gaze17-3050
- gaze17-3060-b
- oryp9

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-08-30 08:47:30 -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
Tim Crawford
720af4b2b0 Use BIT macro
Mostly done with the cocci script. macro.h was then added manually.
2021-05-07 11:24:25 -06:00
Winston Hoy
f0c42f5839 Sync dGPU and PECI fans (at highest requested duty) 2021-05-01 06:33:40 -06:00
Jeremy Soller
a04d353096 Fix fan_max keeping fan on when in S0iX 2021-04-02 13:38:28 -06:00
Jeremy Soller
c3fa2a27a7 system76/common/peci.c: Do not use PECI when in C10 state and using ESPI 2021-01-05 12:17:16 -07:00
Jeremy Soller
d35e375277 Add fan abstraction 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
Tim Crawford
5fd9df0ed0 Add SPDX license identifiers
Add license information to files. Mostly automated with:

    find src/ -name '*.[c,h]' | xargs sed -i '1s,^,// SPDX-License-Identifier: GPL-3.0-only\n\n,'
    find src/ -name '*.mk' | xargs sed -i '1s,^,# SPDX-License-Identifier: GPL-3.0-only\n\n,'
2020-09-17 09:17:08 -06:00
Jeremy Soller
42e88d03b3 Move most code in system76 boards into system76/common 2020-06-24 17:43:39 -06:00
Jeremy Soller
35dd23091e system76/common/peci.c: allow board overrides 2020-06-24 09:14:50 -06:00
Jeremy Soller
90bdcb3818 Set power limits on AC plug event 2020-06-17 11:51:08 -06:00
Jeremy Soller
3a31121625 Add another fan point of 65% at 85C 2020-04-18 15:58:36 -06:00
Jeremy Soller
53d4c31798 lemp9: lower maximum fan speed 2020-04-17 15:28:35 -06:00
Jeremy Soller
357fae86fc System76 common board directory (#53)
* Move configuration for battery into board.mk

* lemp9: remove tcpm code

* Move touchpad to its own module

* Add kbled_reset to all platforms, move items to run on CPU reset to a function

* Add defines for battery and charger address

* Add I2C_0 export to it5570e

* Move common system76 board functions into src/board/system76/common
2020-04-14 17:23:29 -06:00