Commit Graph

925 Commits

Author SHA1 Message Date
ef4eeae2df ite: Add support for 256K flash
The upcoming addw4 will use the IT5570E-256, which requires removing the
assumption that every ITE chip is 128K. Introduce new configs so boards
may select which flash size they use.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-25 13:26:43 -07:00
4b86176659 main: Replace MOD with bitwise AND
This prevents `moduint` from being called for the superloop.

A bitwise AND is used instead of using the equivalent `% 4` as an
indication that modulo should not be used, as not using a power of 2
(which is optimized) will result in an expensive call to SDCC library
functions.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-05 15:04:28 -07:00
766fb738a0 kbscan: Remove unused array
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-04 15:05:40 -07:00
0ccb8079ae kbscan: Do not read matrix if lid is closed
Pull the lid check out to the loop to avoid accessing the matrix when we
know we do not need the data. It is left in kbscan (instead of simply
disabling reading) to clear the state of the matrix data.

The lid check for wake is removed as it will never be true.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-04 15:05:40 -07:00
0e1a748b16 kbscan: Disable reading columns at init
The functionality is split into a separate function to optimize the use
case for each.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-04 11:55:56 -07:00
11b1e724b5 docs: Add note about write lock for flashing
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-01-03 09:45:34 -07:00
47b070418a ectool: Use clap derive syntax
Co-authored-by: Tim Crawford <tcrawford@system76.com>
2023-12-08 16:04:37 -07:00
cbad8e09be smfi: Remove always true conditional
SDCC 4.3.3 (terribly) reports this as an error:

    src/board/system76/common/smfi.c:244: error 110: conditional flow changed by optimizer: so said EVELYN the modified DOG

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-19 08:02:41 -06:00
713e1d9681 Add void to function declarations with no args
SDCC 4.3.3 complains about the declaration not matching the prototype:

    error 283: function declarator with no prototype

Add `void` to the AVR functions as well, even though no warning is
issued by GCC.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-19 08:02:41 -06:00
01be30f107 Only support building a single board at a time
As a follow up to c461e20df3 ("make: Remove version from build output
path"), only support building a single version of a single board by
default. The build directory can still be specified by passing `BUILD`.

Fixes running the `clean` target when `BUILD` is a custom value or
`BOARD` isn't set.

Fixes: b03c960b4f ("make: Reduce build output")
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-12 12:49:43 -06:00
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
a3fb9e1c77 avr: Fix compiling with GCC 13
Apply the CFLAGS workaround for GCC 13.

The issue is fixed in GCC 14, so only 12 and 13 are affected.

Ref: 84fe76cad4 ("avr: Fix compiling with GCC 12")
Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-06 13:58:27 -06:00
166e03972b tool: Derive Eq, PartialEq on enums
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-05 14:32:15 -06:00
4fa389e1bd tool: Fix clippy warnings
Fix:

- clippy::unnecessary_cast
- clippy::needless_borrow

Allow:

- clippy::uninlined_format_args
- clippy::get_first

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-05 14:32:15 -06:00
782f18a3f6 tool: Update toolchain, edition, deps
- Update toolchain to nightly-2023-09-07
- Update edition to 2021
- Update deps

`OpenHidDeviceError` is deprecated, and is removed in newer versions.
Replace it with `HidApiErrorEmpty`, because there are no descriptions
for what anything means so I just picked one that didn't require fields.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-05 14:32:15 -06:00
c461e20df3 make: Remove version from build output path
Support building only a single version for a model. This removes the
need to determine the git commit hash and date in order to access build
artifacts.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-10-03 09:40:42 -06:00
bb1ce2273b fix sdcc 4.3.0 #14184 build error - error 283: function declarator with no prototype 2023-09-20 09:36:34 -06:00
181d4c5d59 kbscan: Increase debounce time from 5ms to 10ms
Some users are reporting that a debounce time of 5ms is not enough to
prevent keys from registering twice. Split the difference between the
old and the new debounce times and set it to 10ms.

Ref: https://github.com/system76/firmware-open/issues/471
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-09-07 17:14:44 -06:00
1097fd999a Do not force charging if end threshold is not set 2023-08-17 17:55:04 -06:00
34dd9ccbac battery: Disable charger if full or not on AC
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-08-17 17:55:04 -06:00
894b82d4fb Set default battery start threshold to 90% 2023-08-17 17:55:04 -06:00
dc482dd11a Add basic support for IT5571E
The IT5571E is nearly identical to the IT5570E.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-08-15 08:24:02 -06:00
13dd6a1038 Update debugging.md 2023-08-02 09:14:35 -06:00
c0bfb257db Update debugging.md 2023-08-02 09:14:35 -06:00
8d844cf966 add console_internal debugging instructions 2023-08-02 09:14:35 -06:00
01907011bb Add a FnLock key
Implement a FnLock toggle that behaves as follows:

- Disabled: F1-F12 are normal
- Enabled: F1-F12 are the alternate function

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-08-01 14:39:59 -06:00
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
ebc5168cb0 Remove the use of symlinks
Replace symlinks with directories with `board.mk`, using relative paths
to include the files rather than duplicate them.

This allows making board-specific changes without affecting other
boards, such as when firmware security had to be enabled on galp6 when
it was enabled on galp7 (2d5cbadf71).

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:06:23 -06:00
9b7c6704c3 docs: Build with mdBook
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:05:53 -06:00
bd291871f4 Rename doc/ to docs/
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:05:53 -06:00
9302a30a2d pmc: Add interrupt control and enable registers
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:04:52 -06:00
459e5a3614 ec/ite: Add WUC functions to handle interrupts
Add functions to enable, disable, and clear an interrupt.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:04:20 -06:00
120ed1e2c5 ec/ite: Add INTC functions to handle interrupts
Add functions to enable, disable, and clear an interrupt.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-31 09:04:20 -06:00
d4ecd8a79a kbscan: Remove comparing matrix to keymap
Remove checking against the real keys declared in the keymap. It appears
to have no effect on behavior.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-28 20:07:24 -06:00
0f2ff7e540 kbscan: Switch from GPIO mode to KBS (Normal) mode
Use the default mode for reading the keyboard scan matrix when being
used as a keyboard. There should be no perceived change in behavior, but
should make the code easier to understand.

Note: `KSO[17:16]` are configured by `GPCRC` on boards that use them.
They are now set to alternate function to use in KBS mode rather than
GPIO mode, with the pull-up enabled to prevent them from floating when
configured as open-drain.

As part of this change, we now only read the hardware matrix state once
upfront, instead of on every iteration through the loop applying the
logic.

Tested by verifying that typing still works on darp9.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-28 20:07:24 -06:00
546458e368 kbscan: Return early if debouncing
A single timer is used for debouncing all keys, so there is no reason to
perform any operations if the matrix is being debounced. Just return
early and remove some of the convoluted logic.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-25 13:03:25 -06:00
8a1adc2bdc Enable power switch WDT on IT5570E boards
Enable PWRSW WDT 2 and use the default timeout of 10 seconds.

Allows forcing an EC reset in case it gets into an invalid state.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-22 06:35:42 -06:00
45520646aa power: Reset KBC on CPU reset
Ensure the keyboard controller is not left locked/disabled.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-22 06:32:07 -06:00
de546fa761 kbc: Add reset function
This function can be called after EC init to put the KBC into a known
working state.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-22 06:32:07 -06:00
0d83819a21 Pad binary file to total flash size
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-19 06:13:17 -06:00
64e5b8308d lemp: Remove pull-down from CPU fan sense
Matches the GPIO for all other boards.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-17 18:06:35 -06:00
1ebc0bc6c2 galp6: Set CPU/VGA fan sense to TACH functionality
Set D6 and D7 to ALT to use as tachometers inputs from the fans.

Matches config for all other boards.

Ref: IT5570E V0.3.2 datasheet; 7.5.4 Alternate Function Selection
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-17 18:06:35 -06:00
e093952dd2 kbscan: Reduce debounce time from 15ms to 5ms
Allows increased typing speed while avoiding repeating keys due to
contact bounce and keys being rejected by ghost key detection.

This is the default value for QMK.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-17 13:38:15 -06:00
1fded3f7bf Use %cs format when getting the commit date
From the man page:

    %cs
        committer date, short format (YYYY-MM-DD)

This is identical to what we use, without having to specify a custom
date format for it.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-07 23:20:51 -06:00
4458d5dbe2 bonw15: Set battery Rsense to 5
PRS3 is 0.005 Ohms.

However, I am unsure about this change because PRS1 and PRS2 are also
both 0.005 Ohms, but are in *parallel*.

Ref: bonw15 schematics, Charger (Sheet 70)
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-06 12:31:03 -06:00
42a19b3d6b oryp11,serw13: Set adapter Rsense to 10 milliohms
PRS1 is 5, but it is in series with PRS3, which is also 5. PRS1 by
itself is only connected to ACP/ACN.

Ref: oryp11 schematics, AC In Charger (Sheet 59)
Ref: serw13 schematics, AC_In, Charger (Sheet 70)
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-06 12:31:03 -06:00
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
c7288a5a60 darp9,oryp11: Update keyboard
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-16 14:49:54 -06:00
8e6d938f90 Add new keyboards
Replace micmute and darp9 layouts with new keyboards.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-16 14:40:43 -06:00
347bbf0d9a reuse make target for board list 2023-06-15 13:45:12 -06:00