Compare commits

...

36 Commits

Author SHA1 Message Date
Sravan Balaji
e41716575c Fan Curve Adjustment to avoid CPU Throttling
- Modify fan curve to avoid CPU throttling
- Reduce fan curve cooldown time for oryp7
2024-10-06 17:08:07 -04:00
Tim Crawford
3d8204c3f4 Require Intel for PECI, add empty AMD power module
PECI is an Intel-only mechanism for getting CPU temp. AMD will use
SB-TSI to get temps.

Add empty power functions for AMD so the project will compile with AMD
selected.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-09-05 17:19:42 -06:00
Tim Crawford
2c6977bc6b Add config for host platform
Introduce a new config to determine the host platform and use it to
conditionally include power sequence logic.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-09-05 17:19:42 -06:00
Tim Crawford
ae63a9e3fb fan: Replace interpolation, smoothing with stepping
Fan noise is one of the top complaints reported. The existing
interpolation and smoothing logic has not sufficiently addressed the
issues with fans changing speeds too quickly in response to rapid
changes in thermals (particularly from PECI).

This behavior can be observed by with very basic tasks, such as:

- Powering on a system and logging into GNOME
- Starting a GUI application such as Firefox

Replace them with a fixed step update per event interval. Fans now have
a maximum amount they change change over time (3.9%/sec) as they move
towards a target duty.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-08-29 08:44:23 -06:00
Tim Crawford
88ad52491a Use CTR0 for max fan
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-08-29 08:44:23 -06:00
Tim Crawford
85cd3aa9ce Move fan-specific PWM logic to fan module
Better define the scope of the tachometer variables by moving them to
the fan module. `fan_update_duty` is renamed to `fan_event` to reflect
that it handles more than just updating the PWM duties.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-08-29 08:44:23 -06:00
Tim Crawford
710b4795fb Sync fans based on temp instead of duty
Fans may be different sizes, placed in asymmetrical positions, or have
different amounts of venting through the chassis. These characteristics
affect the ability for each fan, separately, to dissipate heat and
generate noise.

Replace syncing fans to the highest duty calculated for each fan, based
on separate thermal sensors, to using the highest reported temperature
across all sensors to calculate each fan's duty for that highest
temperature.

In other words: The old behavior synced fans based on the *output* value
(duty), while this new behavior syncs fans based on the *input* value
(temperature).

This allows tuning fans separately to better manage total system
thermals and mitigate noise.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-08-15 09:34:36 -06:00
Tim Crawford
2925376b6b bonw15-b: Add new Bonobo
The new Bonobo has the same pin layout as the original bonw15, but
uses the larger IT5570E-256 instead of keeping the IT5570E-128.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-08-07 11:36:53 -06:00
Tim Crawford
51d35cb272 Remove GPH7 on IT8587E
On IT8587E, pin 3 is VBAT and not a GPIO pin.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-29 18:41:30 -06:00
Tim Crawford
716efd4eb5 kbscan: Work around IT8587E hang
IT8587E is hanging when reading the keyboard matrix.

- Increasing the delay does not fix it
- Placing delays between KSO* writes does not fix it
- Code generated by SDCC looks valid to me

Rewriting it like this does fix it, although I don't know why.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-29 17:17:46 +02:00
Tim Crawford
984428b6a8 darp10: Add custom fan points
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-26 14:04:11 -06:00
Tim Crawford
0f7642defb Use a 16-bit system tick
The maximum interval when configured for a 1ms tick:

- 16-bit: ~65 seconds
- 32-bit: ~49.7 days

The value is used for scheduling and timeouts, and not to track the
uptime of the system, so the 32-bit value is excessive.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-25 11:38:35 -06:00
Tim Crawford
9e7f1952fa Add enum for PECI command codes
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-24 08:06:59 -06:00
Tim Crawford
face381354 Require boards to declare fan points
Thermal properties of each model differ and they should not rely on an
arbitrary, unoptimized set of fan points.

It is one thing to copy the points from the previous generation for a
model, as a lot of the time the chassis design is nearly identical, but
it should be always be explicit.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
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
e01536005a peci: Perform offset calculation in temp function
Have peci_get_temp() return the actual temp instead of the offset,
requiring the caller to make another calculation for the temp.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
8f88c0c7aa dgpu: Split out getting temp to a function
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
80cfa91b9f acpi: Report RPM values instead of raw tachometer values
Ref: IT5570E V0.3.2 datasheet; 7.12.3.2 Manual Fan Control Mode
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 16:28:39 -06:00
Tim Crawford
2a44e03a40 Update Rust toolchain config
Remove rust-src as it is not required. Use a minimal profile with
clippy and rustfmt installed, instead of the default profile, as
rust-docs is not needed.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-17 13:00:13 -06:00
Tim Crawford
70c8678a5f tool: Add error for write locked
Add a new error for the case of trying to flash when security is enabled
and it is still locked and update the related docs.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-15 11:49:32 -06:00
Tim Crawford
54d795480c ci: Show memory layout
I regularly use the `.mem` file to determine the impact changes have on
the RAM and flash usage. Print it as part of CI so I can easily see it
for all boards.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-12 08:17:26 -06:00
Tim Crawford
426dc99f10 tool: Update clap to 4.5
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-10 13:20:53 -06:00
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
6c3b34ee6e ci: Update runner to Ubuntu 24.04
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-03 15:58:28 -06:00
Tim Crawford
3d09a0b546 Conditionally compile dGPU support
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-03 13:47:40 -06:00
Jeremy Soller
5b0766a209 USe debounce bit and do not use interrupts for touchpad 2024-06-21 18:18:02 -06:00
Jeremy Soller
d88a175e23 Clear PS/2 touchpad status when waiting for write to finish 2024-06-21 18:18:02 -06:00
Tim Crawford
2c5c708569 oryp12: Fix USB-PD config
Fixes: 1e4667f1d3 ("Conditionally compile USB-PD support")
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-06-17 17:12:38 -06:00
Tim Crawford
a67b0c98b8 lemp13-b: Remove GPB7
Fixes: f79f4d1157 ("Remove GPB7 on IT5570E")
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-06-17 16:38:22 -06:00
Tim Crawford
f79f4d1157 Remove GPB7 on IT5570E
On IT5570E, pin A1 is VSTBY0 and not a GPIO pin.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-06-17 15:37:01 -06:00
Tim Crawford
1e4667f1d3 Conditionally compile USB-PD support
Boards may not have USB-PD. Remove the need for a "none" option by only
adding USB-PD sources when enabled.

The resulting binary for boards with USB-PD enabled (addw3, bonw15,
serw13) are identical. The binary for boards without USB-PD now have the
empty calls optimized out.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-06-17 14:52:34 -06:00
195 changed files with 1859 additions and 1503 deletions

View File

@@ -1,141 +0,0 @@
# https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html
# LLVM 14 used to support Ubuntu 22.04 LTS.
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: false
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterJavaFieldAnnotations: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- 'foreach'
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(_test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseBlocks: true
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: Wrapped
JavaScriptQuotes: Double
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 1000
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementMacros:
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- 'STRINGIZE'
...

View File

@@ -6,7 +6,7 @@ on:
jobs:
lint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
outputs:
boards: ${{ steps.board-matrix.outputs.boards }}
steps:
@@ -19,7 +19,7 @@ jobs:
run: ./scripts/lint/01-spdx-tags.sh
- name: Check formatting
run: ./scripts/lint/02-clang-format.sh
run: ./scripts/lint/02-uncrustify.sh
- name: Check shell scripts
run: ./scripts/lint/03-shellcheck.sh
@@ -35,7 +35,7 @@ jobs:
- features:
- features: --no-default-features --features="redox_hwio"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
@@ -46,7 +46,7 @@ jobs:
run: cargo build ${{ matrix.features }} --release --manifest-path tool/Cargo.toml
ec:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: lint
strategy:
matrix:
@@ -61,3 +61,7 @@ jobs:
- name: Build firmware
run: make BOARD=${{ matrix.boards }} VERBOSE=1
- name: Show memory layout
run: cat build/ec.mem
continue-on-error: true

156
.uncrustify.cfg Normal file
View File

@@ -0,0 +1,156 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: NONE
# Uncrustify-0.78.1_f
# https://github.com/uncrustify/uncrustify/blob/uncrustify-0.78.1/documentation/htdocs/config.txt
newlines = lf
input_tab_size = 4
output_tab_size = 4
disable_processing_cmt = "uncrustify:off"
enable_processing_cmt = "uncrustify:on"
utf8_bom = remove
sp_arith_additive = force
sp_assign = force
sp_enum_brace = force
sp_enum_after_assign = force
sp_pp_concat = ignore
sp_bool = force
sp_compare = force
sp_inside_paren = remove
sp_paren_paren = remove
sp_cparen_oparen = remove
sp_paren_brace = force
sp_before_ptr_star = force
sp_between_ptr_star = remove
sp_between_ptr_ref = remove
sp_after_ptr_star = remove
sp_after_type = ignore # XXX: Fixes using macros in assignments
sp_before_sparen = force
sp_inside_sparen = remove
sp_inside_for = remove
sp_sparen_paren = remove
sp_sparen_brace = force
sp_do_brace_open = force
sp_brace_close_while = force
sp_before_semi_for = remove
sp_before_semi_for_empty = remove
sp_between_semi_for_empty = remove
sp_after_semi_for_empty = remove
sp_before_square = remove
sp_before_squares = remove
sp_inside_square = remove
sp_after_comma = add
sp_after_cast = remove
sp_inside_paren_cast = remove
sp_sizeof_paren = remove
sp_inside_braces = add
sp_inside_braces_empty = remove
sp_func_proto_paren = remove
sp_func_def_paren = remove
sp_inside_fparens = remove
sp_inside_fparen = remove
sp_inside_tparen = remove
sp_after_tparen_close = remove
sp_fparen_brace = force
sp_func_call_paren = remove
sp_return_paren = force
sp_attribute_paren = remove
sp_defined_paren = remove
sp_else_brace = force
sp_brace_else = force
sp_brace_typedef = force
sp_before_nl_cont = force
sp_cond_colon = force
sp_cond_question = force
sp_endif_cmt = force
sp_before_tr_cmt = add
sp_num_before_tr_cmt = 1
indent_columns = 4
indent_with_tabs = 0
indent_macro_brace = false
indent_ignore_label = true
indent_paren_close = 2
indent_align_assign = false
indent_align_paren = false
indent_compound_literal_return = false
nl_collapse_empty_body = true
nl_collapse_empty_body_functions = true
nl_start_of_file = remove
nl_end_of_file = force
nl_end_of_file_min = 1
nl_assign_brace = remove
nl_fcall_brace = remove
nl_enum_brace = remove
nl_struct_brace = remove
nl_union_brace = remove
nl_if_brace = remove
nl_brace_else = remove
nl_else_brace = remove
nl_else_if = remove
nl_for_brace = remove
nl_while_brace = remove
nl_do_brace = remove
nl_brace_while = remove
nl_switch_brace = remove
nl_after_case = true
nl_enum_own_lines = force
nl_func_type_name = remove
nl_func_proto_type_name = remove
nl_func_paren = remove
nl_func_def_paren = remove
nl_func_call_paren = remove
nl_fdef_brace = remove
nl_return_expr = remove
nl_after_semicolon = true
nl_brace_struct_var = remove
nl_ds_struct_enum_close_brace = true
nl_split_if_one_liner = true
nl_split_for_one_liner = true
nl_split_while_one_liner = true
nl_max = 2
eat_blanks_after_open_brace = true
eat_blanks_before_close_brace = true
code_width = 100
ls_for_split_full = true
ls_func_split_full = true
align_on_tabstop = true
align_var_def_star_style = 1
align_var_def_amp_style = 1
align_typedef_star_style = 1
align_typedef_amp_style = 1
align_func_proto_star_style = 1
align_func_proto_amp_style = 1
align_pp_define_together = true
cmt_width = 100
cmt_convert_tab_to_spaces = true
cmt_trailing_single_line_c_to_cpp = true
mod_paren_on_return = remove
mod_remove_extra_semicolon = true
mod_remove_duplicate_include = true
mod_sort_incl_import_prioritize_filename = true
mod_move_case_break = true
mod_move_case_return = true
mod_remove_empty_return = true
mod_enum_last_comma = add
pp_multiline_define_body_indent = 4
pp_indent_case = false
pp_indent_func_def = false
pp_indent_extern = false
#set QUALIFIER __at # XXX: Allow it to be treated as a function call
set QUALIFIER __code
set QUALIFIER __critical
set QUALIFIER __data
set QUALIFIER __idata
set QUALIFIER __pdata
set QUALIFIER __reentrant
set QUALIFIER __xdata
set TYPE __bit
set TYPE __sbit
set TYPE __sfr
set TYPE __sfr16
set TYPE __sfr32
set FUNC_CALL __asm__

View File

@@ -74,7 +74,7 @@ clean:
.PHONY: fmt
fmt:
./scripts/clang-format.sh apply
uncrustify -c .uncrustify.cfg -q --no-backup $(shell git ls-files '*.c' '*.h')
.PHONY: lint
lint:

View File

@@ -1,15 +1,27 @@
# Flashing firmware
## UEFI application
The `flash.sh` script from the top-level firmware-open project will use
firmware-update, the UEFI application which is used for normal system updates.
This will flash both the SBIOS and the EC after building the firmware. To
flash just the EC, delete the built `firmware.rom` before running `flash.sh`.
## Internal programmer
Use this method for flashing a system already running System76 EC.
This method will only work if the running firmware is not locked. Firmware is
write locked if it was built with `CONFIG_SECURITY=y`. firmware-update must be
used to flash from UEFI in this state (see `flash.sh` in firmware-open).
write locked if it was built with `CONFIG_SECURITY=y`. The firmware can be
unlocked using ectool for a single boot:
This will trigger a watchdog reset causing the system to **immediately power
off**. OS data may be lost or corrupted as a result. Save and close all
```
./scripts/ectool.sh security unlock
```
This method will trigger a watchdog reset causing the system to **immediately
power off**. OS data may be lost or corrupted as a result. Save and close all
applications before flashing.
```

View File

@@ -104,10 +104,6 @@ make
See [flashing firmware](./flashing.md) for details.
```sh
make flash_internal
```
Do not use the keyboard or touchpad while it is flashing.
The system will power off as part of the flash process. Turn it back on after

View File

@@ -1,3 +1,4 @@
[toolchain]
channel = "nightly-2024-05-11"
components = ["rust-src"]
components = ["clippy", "rustfmt"]
profile = "minimal"

View File

@@ -1,16 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
readarray -t FILES < <(git ls-files '*.c' '*.h')
FMT_OPTS=(
"-style=file"
"--fallback-style=none"
"--Werror"
)
if [[ "$1" = "apply" ]]; then
clang-format "${FMT_OPTS[@]}" -i "${FILES[@]}"
else
clang-format "${FMT_OPTS[@]}" --dry-run "${FILES[@]}"
fi

View File

@@ -19,7 +19,6 @@ if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
--yes \
avr-libc \
avrdude \
clang-format \
curl \
gcc \
gcc-avr \
@@ -30,6 +29,7 @@ if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
pkgconf \
sdcc \
shellcheck \
uncrustify \
xxd
elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
sudo dnf install \
@@ -37,13 +37,13 @@ elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
avr-gcc \
avr-libc \
avrdude \
clang-tools-extra \
curl \
gcc \
make \
sdcc \
ShellCheck \
systemd-devel \
uncrustify \
vim-common
elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
sudo pacman -S \
@@ -51,7 +51,6 @@ elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
avr-gcc \
avr-libc \
avrdude \
clang \
curl \
gcc \
make \
@@ -59,6 +58,7 @@ elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
sdcc \
shellcheck \
systemd-libs \
uncrustify \
vim
else
msg "Please add support for your distribution to:"

View File

@@ -2,5 +2,5 @@
# SPDX-License-Identifier: GPL-3.0-only
set -e
cargo build --release --manifest-path tool/Cargo.toml
cargo build --release --quiet --manifest-path tool/Cargo.toml
sudo tool/target/release/system76_ectool "$@"

View File

@@ -1,34 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
# Check if any C files or headers need to be formatted.
LINT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
. "$LINT_DIR/util.sh"
echo -n "Checking C style..."
if ! command -v clang-format > /dev/null; then
skipped "clang-format not found"
exit 0
fi
readarray -t FILES < <(git ls-files '*.c' '*.h')
FMT_OPTS=(
"-style=file"
"--fallback-style=none"
"--dry-run"
"--Werror"
)
# NOTE: It is too slow to run clang-format on every file individually to report
# which ones fail. Leave it up to the user to apply formatting via `make fmt`.
_output=$(clang-format "${FMT_OPTS[@]}" "${FILES[@]}" 2>&1)
if [[ $_output != "" ]]; then
failed
exit 1
fi
passed

36
scripts/lint/02-uncrustify.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
# Check if any C files or headers need to be formatted.
# shellcheck disable=SC1091
LINT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
. "$LINT_DIR/util.sh"
echo -n "Checking C style..."
if ! command -v uncrustify > /dev/null; then
skipped "uncrustify not found"
exit 0
fi
needs_formatting=()
for file in $(git ls-files '*.c' '*.h'); do
if ! uncrustify -c .uncrustify.cfg -q --check "$file" >/dev/null 2>&1; then
needs_formatting+=("$file")
fi
done
if [[ "${#needs_formatting[@]}" != "0" ]]; then
failed
for file in "${needs_formatting[@]}"; do
echo "- $file"
done
exit 1
fi
passed

View File

@@ -5,7 +5,9 @@
#include <stdint.h>
typedef uint16_t systick_t;
void time_init(void);
uint32_t time_get(void);
systick_t time_get(void);
#endif // _ARCH_TIME_H

View File

@@ -8,9 +8,9 @@
#define OSC_DIVISOR 12
#define TICK_INTERVAL_MS 1
// Value to reload into the timer when the overflow interrupt is triggered.
#define TIMER_RELOAD (0xFFFF - ((TICK_INTERVAL_MS) * ((CONFIG_CLOCK_FREQ_KHZ) / OSC_DIVISOR)))
#define TIMER_RELOAD (0xFFFF - (TICK_INTERVAL_MS * (CONFIG_CLOCK_FREQ_KHZ / OSC_DIVISOR)))
static volatile uint32_t time_overflows = 0;
static volatile systick_t time_overflows = 0;
void timer_0(void) __interrupt(1) {
// Hardware automatically clears the the interrupt
@@ -52,6 +52,6 @@ void time_init(void) __critical {
TR0 = 1;
}
uint32_t time_get(void) __critical {
systick_t time_get(void) __critical {
return time_overflows;
}

View File

@@ -11,9 +11,11 @@
#include <arch/i2c_slave.h>
#include <common/macro.h>
// uncrustify:off
static void (*volatile i2c_slave_new_cb)() = NULL;
static void (*volatile i2c_slave_recv_cb)(uint8_t) = NULL;
static uint8_t (*volatile i2c_slave_send_cb)() = NULL;
// uncrustify:on
void i2c_slave_init(
uint8_t address,

View File

@@ -16,14 +16,12 @@ struct Gpio {
uint8_t value;
};
// clang-format off
#define GPIO(BLOCK, NUMBER) { \
.pin = &PIN ## BLOCK, \
.ddr = &DDR ## BLOCK, \
.port = &PORT ## BLOCK, \
.value = BIT(NUMBER), \
}
// clang-format on
bool gpio_get(const struct Gpio *const gpio);
void gpio_set(struct Gpio *const gpio, bool value);

View File

@@ -6,7 +6,6 @@
#include <arch/uart.h>
#include <board/cpu.h>
// clang-format off
#define UART(N) \
{ \
&UCSR ## N ## A, \
@@ -23,24 +22,23 @@
}
#if defined(__AVR_ATmega328P__)
static struct Uart UARTS[] = {
static struct Uart UARTS[] = {
UART(0)
};
};
#elif defined(__AVR_ATmega32U4__)
static struct Uart UARTS[] = {
static struct Uart UARTS[] = {
UART(1)
};
};
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
static struct Uart UARTS[] = {
static struct Uart UARTS[] = {
UART(0),
UART(1),
UART(2),
UART(3)
};
};
#else
#error "Could not find UART definitions"
#endif
// clang-format on
int16_t uart_count(void) {
return sizeof(UARTS) / sizeof(struct Uart);

View File

@@ -11,7 +11,6 @@
#include <arch/gpio.h>
#include <arch/uart.h>
// clang-format off
// Mapping of 24-pin ribbon cable to parallel pins. See schematic
#define PINS \
/* Data (KSO0 - KSO7) - bi-directional */ \
@@ -114,8 +113,6 @@ static struct Parallel PORT = {
.state = PARALLEL_STATE_UNKNOWN,
};
// clang-format on
// Set port to all high-impedance inputs
void parallel_hiz(struct Parallel *const port) {
#define PIN(N, P) \
@@ -137,8 +134,10 @@ void parallel_data_dir(struct Parallel *const port, bool dir) {
void parallel_data_set_high(struct Parallel *const port, uint8_t byte) {
// By convention all lines are high, so only set the ones needed
#define DATA_BIT(B) \
if (!(byte & (1 << B))) \
gpio_set(port->d##B, true);
if (!(byte & (1 << B))) { \
gpio_set(port->d##B, true); \
}
DATA_BITS
#undef DATA_BIT
}
@@ -205,8 +204,10 @@ void parallel_state(struct Parallel *const port, enum ParallelState state) {
uint8_t parallel_read_data(struct Parallel *const port) {
uint8_t byte = 0;
#define DATA_BIT(B) \
if (gpio_get(port->d##B)) \
byte |= (1 << B);
if (gpio_get(port->d##B)) { \
byte |= (1 << B); \
}
DATA_BITS
#undef DATA_BIT
return byte;
@@ -216,8 +217,10 @@ void parallel_write_data(struct Parallel *const port, uint8_t byte) {
// By convention all lines are high, so only set the ones needed
#define DATA_BIT(B) \
if (!(byte & (1 << B))) \
gpio_set(port->d##B, false);
if (!(byte & (1 << B))) { \
gpio_set(port->d##B, false); \
}
DATA_BITS
#undef DATA_BIT
}

View File

@@ -11,8 +11,6 @@
#include <arch/gpio.h>
#include <arch/uart.h>
// clang-format off
// Mapping of 24-pin ribbon cable to parallel pins. See schematic
#define PINS \
/* Data (KSO0 - KSO7) - bi-directional */ \
@@ -67,8 +65,6 @@ static struct Gpio GPIOS[13] = {
GPIO(C, 0),
};
// clang-format on
// Parallel struct definition
// See http://efplus.com/techref/io/parallel/1284/eppmode.htm
struct Parallel {
@@ -89,6 +85,7 @@ void parallel_hiz(struct Parallel *const port) {
#define PIN(N, P) \
gpio_set_dir(port->N, false); \
gpio_set(port->N, false);
PINS
#undef PIN
}
@@ -105,8 +102,10 @@ void parallel_data_dir(struct Parallel *const port, bool dir) {
void parallel_data_set_high(struct Parallel *const port, uint8_t byte) {
// By convention all lines are high, so only set the ones needed
#define DATA_BIT(B) \
if (!(byte & (1 << B))) \
gpio_set(port->d##B, true);
if (!(byte & (1 << B))) { \
gpio_set(port->d##B, true); \
}
DATA_BITS
#undef DATA_BIT
}
@@ -154,8 +153,10 @@ void parallel_reset(struct Parallel *const port, bool host) {
uint8_t parallel_read_data(struct Parallel *const port) {
uint8_t byte = 0;
#define DATA_BIT(B) \
if (gpio_get(port->d##B)) \
byte |= (1 << B);
if (gpio_get(port->d##B)) { \
byte |= (1 << B); \
}
DATA_BITS
#undef DATA_BIT
return byte;
@@ -164,8 +165,10 @@ uint8_t parallel_read_data(struct Parallel *const port) {
void parallel_write_data(struct Parallel *const port, uint8_t byte) {
// By convention all lines are high, so only set the ones needed
#define DATA_BIT(B) \
if (!(byte & (1 << B))) \
gpio_set(port->d##B, false);
if (!(byte & (1 << B))) { \
gpio_set(port->d##B, false); \
}
DATA_BITS
#undef DATA_BIT
}

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT8587E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102
@@ -14,9 +17,6 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_0
@@ -36,23 +36,27 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=180 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 6);
struct Gpio __code AC_PRESENT = GPIO(E, 7);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -42,7 +42,7 @@ struct Gpio __code USB_PWR_EN_N = GPIO(F, 7);
struct Gpio __code VA_EC_EN = GPIO(J, 0); // renamed to SLP_SUS_EC#
struct Gpio __code WLAN_EN = GPIO(J, 2);
struct Gpio __code WLAN_PWR_EN = GPIO(B, 0);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// Enable LPC reset on GPD2
@@ -192,8 +192,6 @@ void gpio_init(void) {
GPCRH5 = GPIO_OUT | GPIO_UP;
// SUSB#_PCH
GPCRH6 = GPIO_IN;
// TODO
GPCRH7 = GPIO_IN;
// BAT_DET
GPCRI0 = GPIO_ALT;
// BAT_VOLT

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -53,6 +52,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
#define HAVE_XLP_OUT 0
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102
@@ -14,9 +17,6 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -36,23 +36,27 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=180 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -40,7 +40,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(J, 7);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -105,8 +105,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EN
GPCRB6 = GPIO_OUT | GPIO_UP;
//
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -50,6 +49,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,7 +7,8 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI=y
# Enable firmware security
@@ -20,9 +21,6 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -45,27 +43,31 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=280 \
-DPOWER_LIMIT_DC=55
# Custom fan curve
CFLAGS+=-DBOARD_HEATUP=5
CFLAGS+=-DBOARD_COOLDOWN=20
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_HEATUP=5
CFLAGS += -DBOARD_FAN1_COOLDOWN=20
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_HEATUP=5
CFLAGS+=-DBOARD_DGPU_COOLDOWN=20
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_HEATUP=5
CFLAGS += -DBOARD_FAN2_COOLDOWN=20
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -32,7 +32,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(D, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -118,8 +118,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
// Not connected
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;

View File

@@ -7,7 +7,8 @@ EC = ite
CONFIG_EC_ITE_IT5570E = y
CONFIG_EC_FLASH_SIZE_256K = y
# Enable eSPI
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
CONFIG_PECI_OVER_ESPI = y
@@ -38,32 +39,35 @@ CFLAGS += \
-DPOWER_LIMIT_AC=230 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS += -DBOARD_HEATUP=5
CFLAGS += -DBOARD_COOLDOWN=20
CFLAGS += -DBOARD_FAN_POINTS="\
# Enable DGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_HEATUP=5
CFLAGS += -DBOARD_FAN1_COOLDOWN=20
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 28), \
FAN_POINT(65, 28), \
FAN_POINT(70, 40), \
FAN_POINT(75, 60), \
FAN_POINT(80, 75), \
FAN_POINT(85, 90), \
FAN_POINT(90, 100) \
FAN_POINT(90, 100), \
"
# Enable DGPU support
CFLAGS += -DHAVE_DGPU=1
CFLAGS += -DI2C_DGPU=I2C_1
CFLAGS += -DBOARD_DGPU_HEATUP=5
CFLAGS += -DBOARD_DGPU_COOLDOWN=20
CFLAGS += -DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_HEATUP=5
CFLAGS += -DBOARD_FAN2_COOLDOWN=20
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 28), \
FAN_POINT(65, 28), \
FAN_POINT(70, 40), \
FAN_POINT(75, 60), \
FAN_POINT(80, 75), \
FAN_POINT(85, 90), \
FAN_POINT(90, 100) \
FAN_POINT(90, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -32,7 +32,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
//struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(H, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -105,8 +105,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_IN;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
// Not connected
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102_nkey
@@ -14,9 +17,6 @@ KEYBOARD=15in_102_nkey
CONFIG_HAVE_KBLED = y
KBLED=bonw14
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -36,23 +36,27 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=180 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code AC_V1_EC = GPIO(J, 7);
@@ -39,7 +39,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4); // renamed to SLP_SUS#
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4); // renamed to EN_3V
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -97,8 +97,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// EC_EN
GPCRB6 = GPIO_OUT | GPIO_UP;
// NO PIN
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// KBC_SMBus_CLK1

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code AC_V1_EC;
@@ -48,6 +47,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -0,0 +1,81 @@
# SPDX-License-Identifier: GPL-3.0-only
board-y += ../bonw15/board.c
board-y += ../bonw15/gpio.c
# FIXME: Handle this better
CFLAGS += -I$(BOARD_DIR)/../bonw15/include
EC = ite
CONFIG_EC_ITE_IT5570E = y
CONFIG_EC_FLASH_SIZE_256K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
CONFIG_SECURITY = y
# Include keyboard
KEYBOARD = 15in_102
# Set keyboard LED mechanism
CONFIG_HAVE_KBLED = y
KBLED = bonw14
# Set battery I2C bus
CFLAGS += -DI2C_SMBUS=I2C_4
# Set touchpad PS2 bus
CFLAGS += -DPS2_TOUCHPAD=PS2_3
# Set smart charger parameters
# XXX: PRS1 and PRS2 are in parallel for adapter Rsense?
CHARGER = oz26786
CFLAGS += \
-DCHARGER_ADAPTER_RSENSE=5 \
-DCHARGER_BATTERY_RSENSE=5 \
-DCHARGER_CHARGE_CURRENT=3072 \
-DCHARGER_CHARGE_VOLTAGE=17400 \
-DCHARGER_INPUT_CURRENT=16920
# Set USB-PD parameters
CONFIG_HAVE_USBPD = y
CONFIG_USBPD_TPS65987 = y
CFLAGS += -DI2C_USBPD=I2C_1
# Set CPU power limits in watts
CFLAGS += \
-DPOWER_LIMIT_AC=330 \
-DPOWER_LIMIT_DC=55
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_HEATUP=5
CFLAGS += -DBOARD_FAN1_COOLDOWN=20
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100), \
"
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_HEATUP=5
CFLAGS += -DBOARD_FAN2_COOLDOWN=20
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
CONFIG_SECURITY=y
@@ -20,17 +21,12 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=bonw14
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
# Set touchpad PS2 bus
CFLAGS+=-DPS2_TOUCHPAD=PS2_3
# Set USB-PD I2C bus
CFLAGS+=-DI2C_USBPD=I2C_1
# Set smart charger parameters
# XXX: PRS1 and PRS2 are in parallel for adapter Rsense?
@@ -43,34 +39,40 @@ CFLAGS+=\
-DCHARGER_INPUT_CURRENT=16920
# Set USB-PD parameters
USBPD=tps65987
CONFIG_HAVE_USBPD = y
CONFIG_USBPD_TPS65987 = y
CFLAGS += -DI2C_USBPD=I2C_1
# Set CPU power limits in watts
CFLAGS+=\
-DPOWER_LIMIT_AC=330 \
-DPOWER_LIMIT_DC=55
# Custom fan curve
CFLAGS+=-DBOARD_HEATUP=5
CFLAGS+=-DBOARD_COOLDOWN=20
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_HEATUP=5
CFLAGS += -DBOARD_FAN1_COOLDOWN=20
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_HEATUP=5
CFLAGS+=-DBOARD_DGPU_COOLDOWN=20
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_HEATUP=5
CFLAGS += -DBOARD_FAN2_COOLDOWN=20
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -34,7 +34,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(B, 5);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -121,8 +121,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
// Not connected
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -43,6 +42,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -3,13 +3,17 @@
#include <board/acpi.h>
#include <board/battery.h>
#include <board/dgpu.h>
#include <board/fan.h>
#include <board/gpio.h>
#include <board/kbled.h>
#include <board/lid.h>
#include <board/peci.h>
#include <common/macro.h>
#include <board/pwm.h>
#include <common/debug.h>
#include <ec/pwm.h>
#include <common/macro.h>
#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif
#ifndef HAVE_LED_AIRPLANE_N
#define HAVE_LED_AIRPLANE_N 1
@@ -43,22 +47,22 @@ void fcommand(void) {
break;
// Set color
case 3:
// clang-format off
kbled_set_color(
((uint32_t)fbuf[0]) |
((uint32_t)fbuf[1] << 16) |
((uint32_t)fbuf[2] << 8)
);
// clang-format on
break;
// Get color
case 4:
// uncrustify:off
{
uint32_t color = kbled_get_color();
fbuf[0] = color & 0xFF;
fbuf[1] = (color >> 16) & 0xFF;
fbuf[2] = (color >> 8) & 0xFF;
}
// uncrustify:on
break;
// DUPLICATE: Set brightness
case 6:
@@ -83,7 +87,7 @@ void acpi_reset(void) {
#endif
}
// clang-format off
// uncrustify:off
uint8_t acpi_read(uint8_t addr) {
uint8_t data = 0;
@@ -112,7 +116,9 @@ uint8_t acpi_read(uint8_t addr) {
}
break;
#if CONFIG_PLATFORM_INTEL
ACPI_8(0x07, peci_temp);
#endif
// Handle AC adapter and battery present
case 0x10:
@@ -161,15 +167,15 @@ uint8_t acpi_read(uint8_t addr) {
ACPI_8(0xCC, sci_extra);
ACPI_8(0xCE, DCR2);
ACPI_8(0xD0, F1TLRR);
ACPI_8(0xD1, F1TMRR);
#if HAVE_DGPU
ACPI_8(0xCE, fan1_pwm_actual);
ACPI_16(0xD0, fan1_rpm);
#if CONFIG_HAVE_DGPU
ACPI_8(0xCD, dgpu_temp);
ACPI_8(0xCF, DCR4);
ACPI_8(0xD2, F2TLRR);
ACPI_8(0xD3, F2TMRR);
#endif // HAVE_DGPU
#endif // CONFIG_HAVE_DGPU
#ifdef FAN2_PWM
ACPI_8(0xCF, fan2_pwm_actual);
ACPI_16(0xD2, fan2_rpm);
#endif // FAN2_PWM
#if HAVE_LED_AIRPLANE_N
// Airplane mode LED
@@ -181,20 +187,20 @@ uint8_t acpi_read(uint8_t addr) {
#endif // HAVE_LED_AIRPLANE_N
// Set size of flash (from old firmware)
ACPI_8 (0xE5, 0x80);
ACPI_8(0xE5, 0x80);
ACPI_8 (0xF8, fcmd);
ACPI_8 (0xF9, fdat);
ACPI_8 (0xFA, fbuf[0]);
ACPI_8 (0xFB, fbuf[1]);
ACPI_8 (0xFC, fbuf[2]);
ACPI_8 (0xFD, fbuf[3]);
ACPI_8(0xF8, fcmd);
ACPI_8(0xF9, fdat);
ACPI_8(0xFA, fbuf[0]);
ACPI_8(0xFB, fbuf[1]);
ACPI_8(0xFC, fbuf[2]);
ACPI_8(0xFD, fbuf[3]);
}
TRACE("acpi_read %02X = %02X\n", addr, data);
return data;
}
// clang-format on
// uncrustify:on
void acpi_write(uint8_t addr, uint8_t data) {
TRACE("acpi_write %02X = %02X\n", addr, data);

View File

@@ -8,7 +8,7 @@
#include <common/macro.h>
#include <common/debug.h>
// clang-format off
// uncrustify:off
// Registers
#define REG_CHARGE_CURRENT 0x14
@@ -86,7 +86,7 @@
#error Invalid adapter:battery RSENSE ratio
#endif
// clang-format on
// uncrustify:on
// XXX: Assumption: ac_last is initialized high.
static bool charger_enabled = false;

View File

@@ -8,7 +8,7 @@
#include <common/debug.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
// Registers
#define REG_CHARGE_CURRENT 0x14
@@ -71,7 +71,8 @@
#else
#error Invalid CHARGER_PSYS_GAIN value
#endif
// clang-format on
// uncrustify:on
// Sense resistor values in milliohms.
enum sense_resistor {

View File

@@ -3,7 +3,7 @@
board-common-y += acpi.c
board-common-y += battery.c
board-common-y += config.c
board-common-y += dgpu.c
board-common-$(CONFIG_HAVE_DGPU) += dgpu.c
board-common-y += ecpm.c
board-common-$(CONFIG_BUS_ESPI) += espi.c
board-common-y += fan.c
@@ -14,10 +14,8 @@ board-common-y += keymap.c
board-common-y += lid.c
board-common-y += main.c
board-common-y += parallel.c
board-common-y += peci.c
board-common-y += pmc.c
board-common-y += pnp.c
board-common-y += power.c
board-common-y += ps2.c
board-common-y += pwm.c
board-common-y += scratch.c
@@ -42,6 +40,17 @@ CFLAGS+=-DLEVEL=4
# Uncomment to enable I2C debug on 0x76
#CFLAGS+=-DI2C_DEBUGGER=0x76
ifeq ($(CONFIG_PLATFORM_INTEL),y)
board-common-y += peci.c
board-common-y += power/intel.c
CFLAGS += -DCONFIG_PLATFORM_INTEL=1
else ifeq ($(CONFIG_PLATFORM_AMD),y)
board-common-y += power/amd.c
CFLAGS += -DCONFIG_PLATFORM_AMD=1
else
$(error PLATFORM not specified)
endif
ifeq ($(CONFIG_SECURITY),y)
CFLAGS+=-DCONFIG_SECURITY=1
endif
@@ -58,6 +67,10 @@ CFLAGS += -DCONFIG_PECI_OVER_ESPI=1
endif
endif
ifeq ($(CONFIG_HAVE_DGPU),y)
CFLAGS += -DCONFIG_HAVE_DGPU=1
endif
# Include system76 common source
SYSTEM76_COMMON_DIR=src/board/system76/common
INCLUDE += $(SYSTEM76_COMMON_DIR)/common.mk
@@ -76,8 +89,10 @@ CHARGER?=bq24780s
board-common-y += charger/$(CHARGER).c
# Add USB-PD
USBPD?=none
board-common-y += usbpd/$(USBPD).c
ifeq ($(CONFIG_HAVE_USBPD),y)
CFLAGS += -DCONFIG_HAVE_USBPD=1
board-common-$(CONFIG_USBPD_TPS65987) += usbpd/tps65987.c
endif
# Add keyboard
ifndef KEYBOARD

View File

@@ -1,107 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/dgpu.h>
#include <board/fan.h>
#if HAVE_DGPU
#include <board/gpio.h>
#include <board/peci.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/i2c.h>
#include <ec/pwm.h>
// Fan speed is the lowest requested over HEATUP seconds
#ifndef BOARD_DGPU_HEATUP
#define BOARD_DGPU_HEATUP 4
#endif
static uint8_t FAN_HEATUP[BOARD_DGPU_HEATUP] = { 0 };
// Fan speed is the highest HEATUP speed over COOLDOWN seconds
#ifndef BOARD_DGPU_COOLDOWN
#define BOARD_DGPU_COOLDOWN 10
#endif
static uint8_t FAN_COOLDOWN[BOARD_DGPU_COOLDOWN] = { 0 };
int16_t dgpu_temp = 0;
#define DGPU_TEMP(X) ((int16_t)(X))
#define FAN_POINT(T, D) \
{ .temp = DGPU_TEMP(T), .duty = PWM_DUTY(D) }
// Fan curve with temperature in degrees C, duty cycle in percent
static struct FanPoint __code FAN_POINTS[] = {
#ifdef BOARD_DGPU_FAN_POINTS
BOARD_DGPU_FAN_POINTS
#else
FAN_POINT(70, 40),
FAN_POINT(75, 50),
FAN_POINT(80, 60),
FAN_POINT(85, 65),
FAN_POINT(90, 65)
#endif
};
static struct Fan __code FAN = {
.points = FAN_POINTS,
.points_size = ARRAY_SIZE(FAN_POINTS),
.heatup = FAN_HEATUP,
.heatup_size = ARRAY_SIZE(FAN_HEATUP),
.cooldown = FAN_COOLDOWN,
.cooldown_size = ARRAY_SIZE(FAN_COOLDOWN),
.interpolate = SMOOTH_FANS != 0,
};
void dgpu_init(void) {
// Set up for i2c usage
i2c_reset(&I2C_DGPU, true);
}
uint8_t dgpu_get_fan_duty(void) {
uint8_t duty;
if (power_state == POWER_STATE_S0 && gpio_get(&DGPU_PWR_EN) && !gpio_get(&GC6_FB_EN)) {
// Use I2CS if in S0 state
bool dgpu_get_temp(int16_t *const data) {
if (gpio_get(&DGPU_PWR_EN) && !gpio_get(&GC6_FB_EN)) {
int8_t rlts;
int16_t res = i2c_get(&I2C_DGPU, 0x4F, 0x00, &rlts, 1);
if (res == 1) {
dgpu_temp = (int16_t)rlts;
duty = fan_duty(&FAN, dgpu_temp);
*data = (int16_t)rlts;
return true;
} else {
DEBUG("DGPU temp error: %d\n", res);
// Default to 50% if there is an error
dgpu_temp = 0;
duty = PWM_DUTY(50);
*data = 0;
return false;
}
} else {
// Turn fan off if not in S0 state or GPU power not on
dgpu_temp = 0;
duty = PWM_DUTY(0);
}
if (peci_on && fan_max) {
// Override duty if fans are manually set to maximum
duty = PWM_DUTY(100);
} else {
// Apply heatup and cooldown filters to duty
duty = fan_heatup(&FAN, duty);
duty = fan_cooldown(&FAN, duty);
}
TRACE("DGPU temp=%d\n", dgpu_temp);
return duty;
*data = 0;
return true;
}
#else
void dgpu_read_temp(void) {
if (power_state == POWER_STATE_S0) {
if (dgpu_get_temp(&dgpu_temp)) {
return;
}
}
void dgpu_init(void) {}
uint8_t dgpu_get_fan_duty(void) {
return PWM_DUTY(0);
dgpu_temp = 0;
}
#endif // HAVE_DGPU

View File

@@ -16,7 +16,7 @@
#define DEBUG_SET(REG, MASK, BITS) \
{ \
DEBUG("%s: %X", #REG, REG); \
REG = ((REG) & ~(MASK)) | (BITS); \
REG = (REG & ~(MASK)) | (BITS); \
DEBUG(" set to %X\n", REG); \
}

View File

@@ -1,31 +1,121 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/fan.h>
#include <board/dgpu.h>
#include <board/power.h>
#include <common/debug.h>
#include <common/macro.h>
#include <ec/pwm.h>
#if SMOOTH_FANS != 0
#define MAX_JUMP_UP ((MAX_FAN_SPEED - MIN_FAN_SPEED) / (uint8_t)SMOOTH_FANS_UP)
#define MAX_JUMP_DOWN ((MAX_FAN_SPEED - MIN_FAN_SPEED) / (uint8_t)SMOOTH_FANS_DOWN)
#else
#define MAX_JUMP_UP (MAX_FAN_SPEED - MIN_FAN_SPEED)
#define MAX_JUMP_DOWN (MAX_FAN_SPEED - MIN_FAN_SPEED)
#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif
#define MIN_SPEED_TO_SMOOTH PWM_DUTY(SMOOTH_FANS_MIN)
bool fan_max = false;
uint8_t last_duty_dgpu = 0;
uint8_t last_duty_peci = 0;
uint8_t fan1_pwm_actual = 0;
uint8_t fan1_pwm_target = 0;
uint16_t fan1_rpm = 0;
uint8_t fan2_pwm_actual = 0;
uint8_t fan2_pwm_target = 0;
uint16_t fan2_rpm = 0;
#define TACH_FREQ (CONFIG_CLOCK_FREQ_KHZ * 1000UL)
// Fan Speed (RPM) = 60 / (1/fs sec * {FnTMRR, FnRLRR} * P)
// - n: 1 or 2
// - P: the numbers of square pulses per revolution
// - fs: sample rate (FreqEC / 128)
// - {FnTMRR, FnTLRR} = 0000h: Fan Speed is zero
#define TACH_TO_RPM(x) (60UL * TACH_FREQ / 128UL / 2UL / (x))
#define FAN_POINT(T, D) { .temp = (int16_t)(T), .duty = PWM_DUTY(D) }
#ifndef FAN1_PWM_MIN
#define FAN1_PWM_MIN 0
#endif
// Fan speed is the lowest requested over HEATUP seconds
#ifndef BOARD_FAN1_HEATUP
#define BOARD_FAN1_HEATUP 4
#endif
static uint8_t FAN1_HEATUP[BOARD_FAN1_HEATUP] = { 0 };
// Fan speed is the highest HEATUP speed over COOLDOWN seconds
#ifndef BOARD_FAN1_COOLDOWN
#define BOARD_FAN1_COOLDOWN 10
#endif
static uint8_t FAN1_COOLDOWN[BOARD_FAN1_COOLDOWN] = { 0 };
// Fan curve with temperature in degrees C, duty cycle in percent
static const struct FanPoint __code FAN1_POINTS[] = {
#ifndef BOARD_FAN1_POINTS
#error Board must declare fan points
#else
BOARD_FAN1_POINTS
#endif
};
static const struct Fan __code FAN1 = {
.points = FAN1_POINTS,
.points_size = ARRAY_SIZE(FAN1_POINTS),
.heatup = FAN1_HEATUP,
.heatup_size = ARRAY_SIZE(FAN1_HEATUP),
.cooldown = FAN1_COOLDOWN,
.cooldown_size = ARRAY_SIZE(FAN1_COOLDOWN),
.pwm_min = PWM_DUTY(FAN1_PWM_MIN),
};
#ifdef FAN2_PWM
#ifndef FAN2_PWM_MIN
#define FAN2_PWM_MIN 0
#endif
// Fan speed is the lowest requested over HEATUP seconds
#ifndef BOARD_FAN2_HEATUP
#define BOARD_FAN2_HEATUP 4
#endif
static uint8_t FAN2_HEATUP[BOARD_FAN2_HEATUP] = { 0 };
// Fan speed is the highest HEATUP speed over COOLDOWN seconds
#ifndef BOARD_FAN2_COOLDOWN
#define BOARD_FAN2_COOLDOWN 10
#endif
static uint8_t FAN2_COOLDOWN[BOARD_FAN2_COOLDOWN] = { 0 };
// Fan curve with temperature in degrees C, duty cycle in percent
static const struct FanPoint __code FAN2_POINTS[] = {
#ifndef BOARD_FAN2_POINTS
#error Board must declare fan points
#else
BOARD_FAN2_POINTS
#endif
};
static const struct Fan __code FAN2 = {
.points = FAN2_POINTS,
.points_size = ARRAY_SIZE(FAN2_POINTS),
.heatup = FAN2_HEATUP,
.heatup_size = ARRAY_SIZE(FAN2_HEATUP),
.cooldown = FAN2_COOLDOWN,
.cooldown_size = ARRAY_SIZE(FAN2_COOLDOWN),
.pwm_min = PWM_DUTY(FAN2_PWM_MIN),
};
#endif // FAN2_PWM
void fan_reset(void) {
// Do not manually set fans to maximum speed
fan_max = false;
}
// Get duty cycle based on temperature, adapted from
// https://github.com/pop-os/system76-power/blob/master/src/fan.rs
uint8_t fan_duty(const struct Fan *const fan, int16_t temp) __reentrant {
static uint8_t fan_duty(const struct Fan *const fan, int16_t temp) {
for (uint8_t i = 0; i < fan->points_size; i++) {
const struct FanPoint *cur = &fan->points[i];
@@ -35,61 +125,19 @@ uint8_t fan_duty(const struct Fan *const fan, int16_t temp) __reentrant {
} else if (temp < cur->temp) {
// If lower than first temp, return 0%
if (i == 0) {
return MIN_FAN_SPEED;
return 0;
} else {
const struct FanPoint *prev = &fan->points[i - 1];
if (fan->interpolate) {
// If in between current temp and previous temp, interpolate
if (temp > prev->temp) {
int16_t dtemp = (cur->temp - prev->temp);
int16_t dduty = ((int16_t)cur->duty) - ((int16_t)prev->duty);
// clang-format off
return (uint8_t)(
((int16_t)prev->duty) +
((temp - prev->temp) * dduty) / dtemp
);
// clang-format on
}
} else {
return prev->duty;
}
}
}
}
// If no point is found, return 100%
return MAX_FAN_SPEED;
return CTR0;
}
void fan_duty_set(uint8_t peci_fan_duty, uint8_t dgpu_fan_duty) __reentrant {
#if SYNC_FANS != 0
peci_fan_duty = peci_fan_duty > dgpu_fan_duty ? peci_fan_duty : dgpu_fan_duty;
dgpu_fan_duty = peci_fan_duty > dgpu_fan_duty ? peci_fan_duty : dgpu_fan_duty;
#endif
// set PECI fan duty
if (peci_fan_duty != DCR2) {
TRACE("PECI fan_duty_raw=%d\n", peci_fan_duty);
last_duty_peci = peci_fan_duty = fan_smooth(last_duty_peci, peci_fan_duty);
DCR2 = fan_max ? MAX_FAN_SPEED : peci_fan_duty;
#if HAVE_CPU_FAN2
// FIXME: Handle better
DCR3 = fan_max ? MAX_FAN_SPEED : peci_fan_duty;
#endif
TRACE("PECI fan_duty_smoothed=%d\n", peci_fan_duty);
}
// set dGPU fan duty
if (dgpu_fan_duty != DCR4) {
TRACE("DGPU fan_duty_raw=%d\n", dgpu_fan_duty);
last_duty_dgpu = dgpu_fan_duty = fan_smooth(last_duty_dgpu, dgpu_fan_duty);
DCR4 = fan_max ? MAX_FAN_SPEED : dgpu_fan_duty;
TRACE("DGPU fan_duty_smoothed=%d\n", dgpu_fan_duty);
}
}
uint8_t fan_heatup(const struct Fan *const fan, uint8_t duty) __reentrant {
static uint8_t fan_heatup(const struct Fan *const fan, uint8_t duty) {
uint8_t lowest = duty;
uint8_t i;
@@ -105,7 +153,7 @@ uint8_t fan_heatup(const struct Fan *const fan, uint8_t duty) __reentrant {
return lowest;
}
uint8_t fan_cooldown(const struct Fan *const fan, uint8_t duty) __reentrant {
static uint8_t fan_cooldown(const struct Fan *const fan, uint8_t duty) {
uint8_t highest = duty;
uint8_t i;
@@ -121,38 +169,109 @@ uint8_t fan_cooldown(const struct Fan *const fan, uint8_t duty) __reentrant {
return highest;
}
uint8_t fan_smooth(uint8_t last_duty, uint8_t duty) __reentrant {
uint8_t next_duty = duty;
static uint8_t fan_get_duty(const struct Fan *const fan, int16_t temp) {
uint8_t duty;
// ramping down
if (duty < last_duty) {
// out of bounds (lower) safeguard
// clang-format off
uint8_t smoothed = last_duty < MIN_FAN_SPEED + MAX_JUMP_DOWN
? MIN_FAN_SPEED
: last_duty - MAX_JUMP_DOWN;
// clang-format on
duty = fan_duty(fan, temp);
duty = fan_heatup(fan, duty);
duty = fan_cooldown(fan, duty);
// use smoothed value if above min and if smoothed is closer than raw
if (last_duty > MIN_SPEED_TO_SMOOTH && smoothed > duty) {
next_duty = smoothed;
}
}
// ramping up
if (duty > last_duty) {
// out of bounds (higher) safeguard
// clang-format off
uint8_t smoothed = last_duty > MAX_FAN_SPEED - MAX_JUMP_UP
? MAX_FAN_SPEED
: last_duty + MAX_JUMP_UP;
// clang-format on
// use smoothed value if above min and if smoothed is closer than raw
if (duty > MIN_SPEED_TO_SMOOTH && smoothed < duty) {
next_duty = smoothed;
}
}
return next_duty;
return duty;
}
static uint16_t fan_get_tach0_rpm(void) {
uint16_t rpm = (F1TMRR << 8) | F1TLRR;
if (rpm)
rpm = TACH_TO_RPM(rpm);
return rpm;
}
static uint16_t fan_get_tach1_rpm(void) {
uint16_t rpm = (F2TMRR << 8) | F2TLRR;
if (rpm)
rpm = TACH_TO_RPM(rpm);
return rpm;
}
void fan_event(void) {
#if CONFIG_PLATFORM_INTEL
#if CONFIG_HAVE_DGPU
int16_t sys_temp = MAX(peci_temp, dgpu_temp);
#else
int16_t sys_temp = peci_temp;
#endif
#elif CONFIG_PLATFORM_AMD
// TODO: AMD SB-TSI temp
int16_t sys_temp = 50;
#endif
// Fan update interval is 100ms (main.c). The event changes PWM duty
// by 1 every interval to give a smoothing effect.
// Enabling fan max toggle and exiting S0 will cause duty to immediately
// change instead of stepping to provide the desired effects.
// Set FAN1 duty
fan1_pwm_target = fan_get_duty(&FAN1, sys_temp);
if (fan_max) {
fan1_pwm_target = CTR0;
fan1_pwm_actual = CTR0;
} else if (power_state != POWER_STATE_S0) {
fan1_pwm_target = 0;
fan1_pwm_actual = 0;
} else {
if (fan1_pwm_actual < fan1_pwm_target) {
if (fan1_pwm_actual < CTR0) {
fan1_pwm_actual++;
if (fan1_pwm_actual < FAN1.pwm_min) {
fan1_pwm_actual = FAN1.pwm_min;
}
}
} else if (fan1_pwm_actual > fan1_pwm_target) {
if (fan1_pwm_actual > 0) {
fan1_pwm_actual--;
if (fan1_pwm_actual < FAN1.pwm_min) {
fan1_pwm_actual = 0;
}
}
}
}
TRACE("FAN1 duty=%d\n", fan1_pwm_actual);
FAN1_PWM = fan1_pwm_actual;
fan1_rpm = fan_get_tach0_rpm();
#ifdef FAN2_PWM
// set FAN2 duty
fan2_pwm_target = fan_get_duty(&FAN2, sys_temp);
if (fan_max) {
fan2_pwm_target = CTR0;
fan2_pwm_actual = CTR0;
} else if (power_state != POWER_STATE_S0) {
fan2_pwm_target = 0;
fan2_pwm_actual = 0;
} else {
if (fan2_pwm_actual < fan2_pwm_target) {
if (fan2_pwm_actual < CTR0) {
fan2_pwm_actual++;
if (fan2_pwm_actual < FAN2.pwm_min) {
fan2_pwm_actual = FAN2.pwm_min;
}
}
} else if (fan2_pwm_actual > fan2_pwm_target) {
if (fan2_pwm_actual > 0) {
fan2_pwm_actual--;
if (fan2_pwm_actual < FAN2.pwm_min) {
fan2_pwm_actual = 0;
}
}
}
}
TRACE("FAN2 duty=%d\n", fan2_pwm_actual);
FAN2_PWM = fan2_pwm_actual;
fan2_rpm = fan_get_tach1_rpm();
#endif
}

View File

@@ -15,7 +15,6 @@ volatile uint8_t __xdata __at(0x103D) ECINDAR2;
volatile uint8_t __xdata __at(0x103E) ECINDAR3;
volatile uint8_t __xdata __at(0x103F) ECINDDR;
// clang-format off
#define SPI_DEVICE (0x70)
#define SPI_FOLLOW_MODE (0x0F)
#define SPI_CHIP_SELECT (0xFD)
@@ -30,7 +29,6 @@ volatile uint8_t __xdata __at(0x103F) ECINDDR;
#define SPI_ERASE_SECTOR_COMMAND (0xD7)
#define SPI_STATUS_WIP (0x01)
// clang-format on
void flash_enter_follow_mode(void);
void flash_exit_follow_mode(void);
@@ -48,9 +46,8 @@ void flash_write_enable(void);
* NOTE: __critical to ensure interrupts are disabled. This does mean that interrupt
* such as the timer will be block until flash acccess is complete
*/
// clang-format off
void flash_entry(uint32_t addr, uint8_t *data, uint32_t length, uint8_t command) __reentrant __critical {
// clang-format on
void flash_entry(uint32_t addr, uint8_t *data, uint32_t length,
uint8_t command) __reentrant __critical {
// Only allow access from 64KB to 128KB.
if ((addr < 0x10000) || (length > 0x10000) || ((addr + length) > 0x20000))
return;
@@ -73,7 +70,8 @@ void flash_entry(uint32_t addr, uint8_t *data, uint32_t length, uint8_t command)
flash_enter_follow_mode();
while (length) {
// Note, this is the slow way to do it, but it's simple and all bytes are written properly.
// Note, this is the slow way to do it, but it's simple and all
// bytes are written properly.
flash_write_enable();
// Select the device

View File

@@ -3,17 +3,28 @@
#ifndef _BOARD_DGPU_H
#define _BOARD_DGPU_H
#include <stdbool.h>
#include <stdint.h>
#ifndef HAVE_DGPU
#define HAVE_DGPU 0
#endif
#if CONFIG_HAVE_DGPU
#if HAVE_DGPU
extern int16_t dgpu_temp;
#endif // HAVE_DGPU
void dgpu_init(void);
uint8_t dgpu_get_fan_duty(void);
bool dgpu_get_temp(int16_t *const data);
void dgpu_read_temp(void);
#else
static inline void dgpu_init(void) {}
static inline bool dgpu_get_temp(int16_t *const data) {
*data = 0;
return true;
}
static inline void dgpu_read_temp(void) {}
#endif // CONFIG_HAVE_DGPU
#endif // _BOARD_DGPU_H

View File

@@ -7,29 +7,6 @@
#include <stdint.h>
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
#define MAX_FAN_SPEED PWM_DUTY(100)
#define MIN_FAN_SPEED PWM_DUTY(0)
#ifndef SMOOTH_FANS
#define SMOOTH_FANS 1 // default to fan smoothing
#endif
#ifndef SYNC_FANS
#define SYNC_FANS 1 // default to syncing fan speeds
#endif
#if SMOOTH_FANS != 0
#ifndef SMOOTH_FANS_UP
#define SMOOTH_FANS_UP 45 // default to ~11 seconds for full ramp-up
#endif
#ifndef SMOOTH_FANS_DOWN
#define SMOOTH_FANS_DOWN 100 // default to ~25 seconds for full ramp-down
#endif
#endif
#ifndef SMOOTH_FANS_MIN
#define SMOOTH_FANS_MIN 0 // default to smoothing all fan speed changes
#endif
struct FanPoint {
int16_t temp;
@@ -43,17 +20,19 @@ struct Fan {
uint8_t heatup_size;
uint8_t *cooldown;
uint8_t cooldown_size;
bool interpolate;
uint8_t pwm_min;
};
extern bool fan_max;
void fan_reset(void);
extern uint8_t fan1_pwm_actual;
extern uint8_t fan1_pwm_target;
extern uint16_t fan1_rpm;
extern uint8_t fan2_pwm_actual;
extern uint8_t fan2_pwm_target;
extern uint16_t fan2_rpm;
uint8_t fan_duty(const struct Fan *const fan, int16_t temp) __reentrant;
void fan_duty_set(uint8_t peci_fan_duty, uint8_t dgpu_fan_duty) __reentrant;
uint8_t fan_heatup(const struct Fan *const fan, uint8_t duty) __reentrant;
uint8_t fan_cooldown(const struct Fan *const fan, uint8_t duty) __reentrant;
uint8_t fan_smooth(uint8_t last_duty, uint8_t duty) __reentrant;
void fan_reset(void);
void fan_event(void);
#endif // _BOARD_FAN_H

View File

@@ -12,11 +12,9 @@
/** \cond INTERNAL
* Internal defines
*/
// clang-format off
#define FLASH_COMMAND_READ (0x0)
#define FLASH_COMMAND_WRITE (0x1)
#define FLASH_COMMAND_ERASE_1K (0x2)
// clang-format on
/** \endcond */
/**

View File

@@ -3,16 +3,24 @@
#ifndef _BOARD_PECI_H
#define _BOARD_PECI_H
#include <stdbool.h>
#include <ec/peci.h>
#include <stdbool.h>
extern bool peci_on;
extern int16_t peci_temp;
enum PeciCmd {
PECI_CMD_PING = 0x00,
PECI_CMD_GET_TEMP = 0x01,
PECI_CMD_RD_PKG_CONFIG = 0xA1,
PECI_CMD_WR_PKG_CONFIG = 0xA5,
PECI_CMD_RD_IAMSR = 0xB1,
PECI_CMD_GET_DIB = 0xF7,
};
void peci_init(void);
bool peci_available(void);
int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data);
uint8_t peci_get_fan_duty(void);
void peci_read_temp(void);
#endif // _BOARD_PECI_H

View File

@@ -17,7 +17,6 @@ void power_init(void);
void power_on(void);
void power_off(void);
void power_cpu_reset(void);
void power_event(void);
#endif // _BOARD_POWER_H

View File

@@ -3,8 +3,6 @@
#ifndef _BOARD_PWM_H
#define _BOARD_PWM_H
#include <ec/pwm.h>
void pwm_init(void);
#endif // _BOARD_PWM_H

View File

@@ -3,9 +3,20 @@
#ifndef _BOARD_USBPD_H
#define _BOARD_USBPD_H
#if CONFIG_HAVE_USBPD
void usbpd_init(void);
void usbpd_event(void);
void usbpd_disable_charging(void);
void usbpd_enable_charging(void);
#else
static inline void usbpd_init(void) {}
static inline void usbpd_event(void) {}
static inline void usbpd_disable_charging(void) {}
static inline void usbpd_enable_charging(void) {}
#endif
#endif // _BOARD_USBPD_H

View File

@@ -41,7 +41,6 @@ static bool kbc_translate = true;
// LED state
uint8_t kbc_leds = 0;
// clang-format off
// Values from linux/drivers/input/keyboard/atkbd.c
static const uint16_t kbc_typematic_period[32] = {
33, // 30.0 cps = ~33.33ms
@@ -77,7 +76,6 @@ static const uint16_t kbc_typematic_period[32] = {
470, // 2.1 cps = ~478.19ms
500, // 2.0 cps = 500ms
};
// clang-format on
static uint8_t kbc_buffer[16] = { 0 };
static uint8_t kbc_buffer_head = 0;
@@ -400,15 +398,13 @@ static void kbc_on_input_data(struct Kbc *const kbc, uint8_t data) {
TRACE(" write second port input\n");
state = KBC_STATE_NORMAL;
// Begin write
*(PS2_TOUCHPAD.control) = 0x0D;
// Enable Transaction Done interrupt
*(PS2_TOUCHPAD.interrupt) |= BIT(2);
*(PS2_TOUCHPAD.control) = 0x1D;
// Write the data
*(PS2_TOUCHPAD.data) = data;
// Pull data line low
*(PS2_TOUCHPAD.control) = 0x0C;
*(PS2_TOUCHPAD.control) = 0x1C;
// Pull clock line high
*(PS2_TOUCHPAD.control) = 0x0E;
*(PS2_TOUCHPAD.control) = 0x1E;
// Set wait timeout of 100 cycles
kbc_second_wait = 100;
break;
@@ -468,6 +464,7 @@ void kbc_event(struct Kbc *const kbc) {
// Wait for touchpad write transaction to finish
kbc_second_wait -= 1;
uint8_t sts = *(PS2_TOUCHPAD.status);
*(PS2_TOUCHPAD.status) = sts;
// If transaction is done, stop waiting
if (sts & PSSTS_DONE) {
kbc_second_wait = 0;
@@ -488,9 +485,7 @@ void kbc_event(struct Kbc *const kbc) {
if (kbc_second_wait == 0) {
// Attempt to read from touchpad
*(PS2_TOUCHPAD.control) = 0x07;
// Enable Transaction Done interrupt
*(PS2_TOUCHPAD.interrupt) |= BIT(2);
*(PS2_TOUCHPAD.control) = 0x17;
if (state == KBC_STATE_NORMAL) {
uint8_t sts = *(PS2_TOUCHPAD.status);
*(PS2_TOUCHPAD.status) = sts;

View File

@@ -31,26 +31,26 @@ void kbled_reset(void) {
// Keep the following functions for compatibility - they are set via USB HID
uint8_t kbled_get(void) {
/* Always off */
// Always off
return 0;
}
uint8_t kbled_max(void) {
/* Always off */
// Always off
return 0;
}
void kbled_set(uint8_t level) {
/* Fix unused variable */
// Fix unused variable
level = level;
}
uint32_t kbled_get_color(void) {
/* Always black */
// Always black
return 0;
}
void kbled_set_color(uint32_t color) {
/* Fix unused variable */
// Fix unused variable
color = color;
}

View File

@@ -5,7 +5,6 @@
enum KbledKind kbled_kind = KBLED_NONE;
// clang-format off
static uint8_t LEVEL_I = 1;
#ifdef KBLED_DAC
// XXX: DAC uses separate levels due to brightness being different.
@@ -38,7 +37,6 @@ static const uint32_t __code COLORS[] = {
0x00FFFF,
0xFFFF00
};
// clang-format on
void kbled_hotkey_color(void) {
if (COLOR_I < (ARRAY_SIZE(COLORS) - 1)) {

View File

@@ -35,11 +35,11 @@ void kbled_set(uint8_t level) {
}
uint32_t kbled_get_color(void) {
/* Always white */
// Always white
return 0xFFFFFF;
}
void kbled_set_color(uint32_t color) {
/* Fix unused variable */
// Fix unused variable
color = color;
}

View File

@@ -45,10 +45,21 @@ static inline bool matrix_position_is_fn(uint8_t row, uint8_t col) {
// Assert the specified column for reading the row.
static void kbscan_set_column(uint8_t col) {
// Assert the specific bit corresponding to the column.
uint32_t colbit = ~BIT(col);
KSOL = colbit & 0xFF;
KSOH1 = (colbit >> 8) & 0xFF;
KSOH2 = (colbit >> 16) & 0x03;
// XXX: IT8587E will hang if the column is determined with:
// uint32_t colbit = ~BIT(col);
if (col < 8) {
KSOL = ~BIT(col);
KSOH1 = 0xFF;
KSOH2 = 0xFF;
} else if (col < 16) {
KSOL = 0xFF;
KSOH1 = ~BIT(col - 8);
KSOH2 = 0xFF;
} else {
KSOL = 0xFF;
KSOH1 = 0xFF;
KSOH2 = ~BIT(col - 16);
}
// Wait for matrix to stabilize
delay_ticks(20);
@@ -58,7 +69,7 @@ static void kbscan_set_column(uint8_t col) {
static void kbscan_disable_reading(void) {
KSOL = 0xFF;
KSOH1 = 0xFF;
KSOH2 = 0x3;
KSOH2 = 0xFF;
// No need to wait for matrix to stabilize as a read won't happen.
}
@@ -284,15 +295,15 @@ void kbscan_event(void) {
uint8_t matrix_curr[KM_OUT];
static bool debounce = false;
static uint32_t debounce_time = 0;
static systick_t debounce_time = 0;
static bool repeat = false;
static uint16_t repeat_key = 0;
static uint32_t repeat_key_time = 0;
static systick_t repeat_key_time = 0;
// If debounce complete
if (debounce) {
uint32_t time = time_get();
systick_t time = time_get();
if ((time - debounce_time) >= DEBOUNCE_DELAY) {
// Debounce time elapsed: Read new state
debounce = false;
@@ -330,10 +341,8 @@ void kbscan_event(void) {
// A key was pressed or released
for (uint8_t j = 0; j < KM_IN; j++) {
// clang-format off
bool new_b = new & BIT(j);
bool last_b = last & BIT(j);
// clang-format on
if (new_b != last_b) {
bool reset = false;
@@ -384,10 +393,10 @@ void kbscan_event(void) {
}
kbscan_matrix[i] = new;
} else if (new &&repeat_key != 0 && key_should_repeat(repeat_key)) {
} else if (new && repeat_key != 0 && key_should_repeat(repeat_key)) {
// A key is being pressed
uint32_t time = time_get();
static uint32_t repeat_start = 0;
systick_t time = time_get();
static systick_t repeat_start = 0;
if (!repeat) {
if (time < repeat_key_time) {

View File

@@ -18,7 +18,6 @@
#include <board/kbscan.h>
#include <board/keymap.h>
#include <board/lid.h>
#include <board/peci.h>
#include <board/pmc.h>
#include <board/power.h>
#include <board/ps2.h>
@@ -31,6 +30,10 @@
#include <common/version.h>
#include <ec/ec.h>
#if CONFIG_PLATFORM_INTEL
#include <board/peci.h>
#endif
#ifdef PARALLEL_DEBUG
#include <board/parallel.h>
#endif // PARALLEL_DEBUG
@@ -44,10 +47,10 @@ void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}
uint8_t main_cycle = 0;
const uint16_t battery_interval = 1000;
// update fan speed more frequently for smoother fans
// NOTE: event loop is longer than 100ms and maybe even longer than 250
const uint16_t fan_interval = SMOOTH_FANS != 0 ? 250 : 1000;
#define INTERVAL_100MS 100U
#define INTERVAL_250MS 250U
#define INTERVAL_1SEC 1000U
void init(void) {
// Must happen first
@@ -57,7 +60,7 @@ void init(void) {
gpio_init();
// Can happen in any order
#if HAVE_DGPU
#if CONFIG_HAVE_DGPU
dgpu_init();
#endif
ecpm_init();
@@ -73,7 +76,9 @@ void init(void) {
kbscan_init();
}
keymap_init();
#if CONFIG_PLATFORM_INTEL
peci_init();
#endif
pmc_init();
pwm_init();
smbus_init();
@@ -98,8 +103,9 @@ void main(void) {
INFO("System76 EC board '%s', version '%s'\n", board(), version());
uint32_t last_time_battery = 0;
uint32_t last_time_fan = 0;
systick_t last_time_100ms = 0;
systick_t last_time_250ms = 0;
systick_t last_time_1sec = 0;
for (main_cycle = 0;; main_cycle++) {
// NOTE: Do note use modulo to avoid expensive call to SDCC library
@@ -128,20 +134,26 @@ void main(void) {
}
if (main_cycle == 0) {
uint32_t time = time_get();
// Only run the following once per interval
if ((time - last_time_fan) >= fan_interval) {
last_time_fan = time;
systick_t time = time_get();
// Update fan speeds
fan_duty_set(peci_get_fan_duty(), dgpu_get_fan_duty());
if ((time - last_time_100ms) >= INTERVAL_100MS) {
last_time_100ms = time;
fan_event();
}
// Only run the following once per interval
if ((time - last_time_battery) >= battery_interval) {
last_time_battery = time;
if ((time - last_time_250ms) >= INTERVAL_250MS) {
last_time_250ms = time;
#if CONFIG_PLATFORM_INTEL
peci_read_temp();
#endif
dgpu_read_temp();
}
if ((time - last_time_1sec) >= INTERVAL_1SEC) {
last_time_1sec = time;
// Updates battery status
battery_event();
}
}

View File

@@ -19,14 +19,12 @@
* nWAIT = KSOH[1]
*/
// clang-format off
#define CTL_WRITE BIT(0)
#define CTL_DATA BIT(1)
#define CTL_RESET BIT(2)
#define CTL_ADDR BIT(3)
#define STS_WAIT BIT(1)
// clang-format on
// Maximum peripheral response time in ms
#define PARALLEL_TIMEOUT 10
@@ -34,7 +32,7 @@
bool parallel_debug = false;
static bool parallel_wait_peripheral(uint8_t mask, uint8_t value) {
uint32_t start = time_get();
systick_t start = time_get();
while ((time_get() - start) < PARALLEL_TIMEOUT) {
if ((KSOHGDMRR & mask) == value) {

View File

@@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
// PECI information can be found here:
// https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
#include <arch/time.h>
#include <board/espi.h>
#include <board/fan.h>
@@ -11,58 +14,15 @@
#include <ec/gpio.h>
#include <ec/pwm.h>
// Fan speed is the lowest requested over HEATUP seconds
#ifndef BOARD_HEATUP
#define BOARD_HEATUP 4
#endif
static uint8_t FAN_HEATUP[BOARD_HEATUP] = { 0 };
// Fan speed is the highest HEATUP speed over COOLDOWN seconds
#ifndef BOARD_COOLDOWN
#define BOARD_COOLDOWN 10
#endif
static uint8_t FAN_COOLDOWN[BOARD_COOLDOWN] = { 0 };
// Tjunction = 100C for i7-8565U (and probably the same for all WHL-U)
#define T_JUNCTION 100
bool peci_on = false;
int16_t peci_temp = 0;
#define PECI_TEMP(X) ((int16_t)(X))
// Tjunction = 100C for i7-8565U (and probably the same for all WHL-U)
#define T_JUNCTION ((int16_t)100)
// Maximum OOB channel response time in ms
#define PECI_ESPI_TIMEOUT 10
// clang-format off
#define FAN_POINT(T, D) { .temp = PECI_TEMP(T), .duty = PWM_DUTY(D) }
// clang-format on
// Fan curve with temperature in degrees C, duty cycle in percent
static struct FanPoint __code FAN_POINTS[] = {
#ifdef BOARD_FAN_POINTS
BOARD_FAN_POINTS
#else
FAN_POINT(70, 40),
FAN_POINT(75, 50),
FAN_POINT(80, 60),
FAN_POINT(85, 65),
FAN_POINT(90, 65)
#endif
};
static struct Fan __code FAN = {
.points = FAN_POINTS,
.points_size = ARRAY_SIZE(FAN_POINTS),
.heatup = FAN_HEATUP,
.heatup_size = ARRAY_SIZE(FAN_HEATUP),
.cooldown = FAN_COOLDOWN,
.cooldown_size = ARRAY_SIZE(FAN_COOLDOWN),
.interpolate = SMOOTH_FANS != 0,
};
// Returns true if peci is available
bool peci_available(void) {
// Ensure power state is up to date
@@ -84,7 +44,7 @@ bool peci_available(void) {
// If VW_HOST_C10 virtual wire is VWS_HIGH, PECI will wake the CPU
//TODO: wake CPU every 8 seconds following Intel recommendation?
return (vw_get(&VW_HOST_C10) != VWS_HIGH);
return vw_get(&VW_HOST_C10) != VWS_HIGH;
#else
// PECI is available if PLTRST# is high
return gpio_get(&BUF_PLT_RST_N);
@@ -124,8 +84,8 @@ bool peci_get_temp(int16_t *const data) {
UDB[5] = 1;
// PECI read length
UDB[6] = 2;
// PECI command (0x01 = GetTemp)
UDB[7] = 0x01;
// PECI command
UDB[7] = PECI_CMD_GET_TEMP;
// Set upstream enable
ESUCTRL0 |= ESUCTRL0_ENABLE;
@@ -133,7 +93,7 @@ bool peci_get_temp(int16_t *const data) {
ESUCTRL0 |= ESUCTRL0_GO;
// Wait until upstream done
uint32_t start = time_get();
systick_t start = time_get();
while (!(ESUCTRL0 & ESUCTRL0_DONE)) {
if ((time_get() - start) >= PECI_ESPI_TIMEOUT) {
DEBUG("peci_get_temp: upstream timeout\n");
@@ -161,9 +121,12 @@ bool peci_get_temp(int16_t *const data) {
// Received enough data for temperature
uint8_t low = PUTOOBDB[5];
uint8_t high = PUTOOBDB[6];
*data = (((int16_t)high << 8) | (int16_t)low);
int16_t offset = (((int16_t)high << 8) | (int16_t)low);
*data = T_JUNCTION + (offset >> 6);
// Clear PUT_OOB status
ESOCTRL0 = ESOCTRL0_STATUS;
return true;
} else {
// Did not receive enough data
@@ -204,8 +167,8 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
UDB[5] = 10;
// PECI read length
UDB[6] = 1;
// PECI command (0xA5 = WrPkgConfig)
UDB[7] = 0xA5;
// PECI command
UDB[7] = PECI_CMD_WR_PKG_CONFIG;
// Write host ID
UDB[8] = 0;
@@ -226,7 +189,7 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
ESUCTRL0 |= ESUCTRL0_GO;
// Wait until upstream done
uint32_t start = time_get();
systick_t start = time_get();
while (!(ESUCTRL0 & ESUCTRL0_DONE)) {
DEBUG("peci_wr_pkg_config: wait upstream\n");
if ((time_get() - start) >= PECI_ESPI_TIMEOUT) {
@@ -291,7 +254,7 @@ void peci_init(void) {
// Returns true on success, false on error
bool peci_get_temp(int16_t *const data) {
// Wait for any in-progress transaction to complete
uint32_t start = time_get();
systick_t start = time_get();
while (HOSTAR & BIT(0)) {
if ((time_get() - start) >= PECI_ESPI_TIMEOUT) {
DEBUG("%s: host timeout\n", __func__);
@@ -311,7 +274,7 @@ bool peci_get_temp(int16_t *const data) {
// Set read length
HORDLR = 2;
// Set command
HOCMDR = 1;
HOCMDR = PECI_CMD_GET_TEMP;
// Start transaction
HOCTLR |= 1;
@@ -330,23 +293,24 @@ bool peci_get_temp(int16_t *const data) {
// Clear status
HOSTAR = HOSTAR;
return false;
} else {
}
// Read two byte temperature data if finished successfully
uint8_t low = HORDDR;
uint8_t high = HORDDR;
*data = (((int16_t)high << 8) | (int16_t)low);
int16_t offset = (((int16_t)high << 8) | (int16_t)low);
*data = T_JUNCTION + (offset >> 6);
// Clear status
HOSTAR = HOSTAR;
return true;
}
}
// Returns positive completion code on success, negative completion code or
// negative (0x1000 | status register) on PECI hardware error
int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
// Wait for any in-progress transaction to complete
uint32_t start = time_get();
systick_t start = time_get();
while (HOSTAR & BIT(0)) {
if ((time_get() - start) >= PECI_ESPI_TIMEOUT) {
DEBUG("%s: host timeout\n", __func__);
@@ -366,7 +330,7 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
// Set read length
HORDLR = 1;
// Set command
HOCMDR = 0xA5;
HOCMDR = PECI_CMD_WR_PKG_CONFIG;
// Write host ID
HOWRDR = 0;
@@ -417,37 +381,13 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
#endif // CONFIG_PECI_OVER_ESPI
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
uint8_t peci_get_fan_duty(void) {
uint8_t duty;
void peci_read_temp(void) {
peci_on = peci_available();
if (peci_on) {
int16_t peci_offset = 0;
if (peci_get_temp(&peci_offset)) {
// Use result if finished successfully
peci_temp = PECI_TEMP(T_JUNCTION) + (peci_offset >> 6);
duty = fan_duty(&FAN, peci_temp);
} else {
// Default to 50% if there is an error
peci_temp = 0;
duty = PWM_DUTY(50);
if (peci_get_temp(&peci_temp)) {
return;
}
} else {
// Turn fan off if not in S0 state
peci_temp = 0;
duty = PWM_DUTY(0);
}
if (peci_on && fan_max) {
// Override duty if fans are manually set to maximum
duty = PWM_DUTY(100);
} else {
// Apply heatup and cooldown filters to duty
duty = fan_heatup(&FAN, duty);
duty = fan_cooldown(&FAN, duty);
}
TRACE("PECI temp=%d\n", peci_temp);
return duty;
peci_temp = 0;
}

View File

@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/power.h>
enum PowerState power_state = POWER_STATE_OFF;
void update_power_state(void) {}
void power_init(void) {}
void power_on(void) {}
void power_off(void) {}
void power_cpu_reset(void) {}
void power_event(void) {}

View File

@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/power.h>
#include <arch/delay.h>
#include <arch/time.h>
#include <board/acpi.h>
@@ -12,7 +14,6 @@
#include <board/kbled.h>
#include <board/lid.h>
#include <board/peci.h>
#include <board/power.h>
#include <board/pmc.h>
#include <board/pnp.h>
#include <board/wireless.h>
@@ -491,7 +492,6 @@ void power_event(void) {
}
pg_last = pg_new;
// clang-format off
static bool rst_last = false;
bool rst_new = gpio_get(&BUF_PLT_RST_N);
#if LEVEL >= LEVEL_DEBUG
@@ -508,7 +508,6 @@ void power_event(void) {
#endif // CONFIG_BUS_ESPI
}
rst_last = rst_new;
// clang-format on
#if HAVE_SLP_SUS_N
#if LEVEL >= LEVEL_DEBUG
@@ -574,8 +573,8 @@ void power_event(void) {
wake_last = wake_new;
#endif // HAVE_LAN_WAKEUP_N
static uint32_t last_time = 0;
uint32_t time = time_get();
static systick_t last_time = 0;
systick_t time = time_get();
if (power_state == POWER_STATE_S0) {
#if CONFIG_BUS_ESPI
// HOST_C10 virtual wire is high when CPU is in C10 sleep state

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/pwm.h>
#include <ec/pwm.h>
#include <common/macro.h>
void pwm_init(void) {
@@ -23,10 +24,10 @@ void pwm_init(void) {
// Set cycle time to 255 + 1
CTR0 = 255;
// Turn off CPU fan (temperature control in peci_get_fan_duty)
DCR2 = 0;
#if HAVE_CPU_FAN2
DCR3 = 0;
// Turn off fans
FAN1_PWM = 0;
#ifdef FAN2_PWM
FAN2_PWM = 0;
#endif
#if CONFIG_EC_ITE_IT5570E || CONFIG_EC_ITE_IT5571E

View File

@@ -1,14 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <8051.h>
#include <stdint.h>
#include <board/dgpu.h>
#include <board/fan.h>
#include <board/smfi.h>
#include <common/macro.h>
#include <ec/pwm.h>
#include <ec/scratch.h>
#include <8051.h>
#include <stdint.h>
// Include scratch ROM
uint8_t __code __at(SCRATCH_OFFSET) scratch_rom[] = {
#include <scratch.h>
@@ -17,12 +18,9 @@ uint8_t __code __at(SCRATCH_OFFSET) scratch_rom[] = {
// Enter or exit scratch ROM
void scratch_trampoline(void) {
// Set fans to 100%
DCR2 = 0xFF;
#if HAVE_CPU_FAN2
DCR3 = 0xFF;
#endif
#if HAVE_DGPU
DCR4 = 0xFF;
FAN1_PWM = CTR0;
#ifdef FAN2_PWM
FAN2_PWM = CTR0;
#endif
//TODO: Clear keyboard presses

View File

@@ -11,7 +11,7 @@ enum SecurityState security_get(void) {
bool security_set(enum SecurityState state) {
switch (state) {
// Allow perpare states to be set
// Allow prepare states to be set
case SECURITY_STATE_PREPARE_LOCK:
case SECURITY_STATE_PREPARE_UNLOCK:
security_state = state;

View File

@@ -13,27 +13,29 @@
// the command is complete and the result is available. The client should only
// read the SMFI_CMD_RES value when SMFI_CMD_CMD is set to CMD_NONE.
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <board/smfi.h>
#if !defined(__SCRATCH__)
#include <board/scratch.h>
#include <board/fan.h>
#include <board/kbled.h>
#include <board/kbscan.h>
#include <board/scratch.h>
#if CONFIG_SECURITY
#include <board/security.h>
#endif // CONFIG_SECURITY
#endif // !defined(__SCRATCH__)
#include <board/smfi.h>
#include <common/command.h>
#include <common/macro.h>
#include <common/version.h>
#include <ec/etwd.h>
#include <ec/pwm.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
// Shared memory host semaphore
volatile uint8_t __xdata __at(0x1022) SMHSR;
// Host RAM window control
@@ -123,15 +125,14 @@ static enum Result cmd_print(void) {
static enum Result cmd_fan_get(void) {
switch (smfi_cmd[SMFI_CMD_DATA]) {
case 0:
// Get duty of fan 0
smfi_cmd[SMFI_CMD_DATA + 1] = DCR2;
return RES_OK;
case 1:
// Get duty of fan 1
//TODO: only allow on platforms like addw2
smfi_cmd[SMFI_CMD_DATA + 1] = DCR4;
smfi_cmd[SMFI_CMD_DATA + 1] = fan1_pwm_actual;
return RES_OK;
#ifdef FAN2_PWM
case 2:
smfi_cmd[SMFI_CMD_DATA + 1] = fan2_pwm_actual;
return RES_OK;
#endif
}
// Failed if fan not found
@@ -140,15 +141,16 @@ static enum Result cmd_fan_get(void) {
static enum Result cmd_fan_set(void) {
switch (smfi_cmd[SMFI_CMD_DATA]) {
case 0:
// Set duty cycle of fan 0
DCR2 = smfi_cmd[SMFI_CMD_DATA + 1];
return RES_OK;
case 1:
// Set duty cycle of fan 1
//TODO: only allow on platforms like addw2
DCR4 = smfi_cmd[SMFI_CMD_DATA + 1];
// Set duty cycle of FAN1
fan1_pwm_target = smfi_cmd[SMFI_CMD_DATA + 1];
return RES_OK;
#ifdef FAN2_PWM
case 2:
// Set duty cycle of FAN2
fan2_pwm_target = smfi_cmd[SMFI_CMD_DATA + 1];
return RES_OK;
#endif
}
// Failed if fan not found

View File

@@ -1,11 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <board/usbpd.h>
void usbpd_init(void) {}
void usbpd_event(void) {}
void usbpd_disable_charging(void) {}
void usbpd_enable_charging(void) {}

View File

@@ -69,7 +69,7 @@ static int16_t usbpd_current_limit(void) {
}
static void usbpd_dump(void) {
/* Dump all registers for debugging */
// Dump all registers for debugging
for (uint8_t reg = 0x00; reg < 0x40; reg += 1) {
uint8_t value[65] = { 0 };
int16_t res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, reg, value, sizeof(value));

View File

@@ -7,7 +7,8 @@ EC = ite
CONFIG_EC_ITE_IT5570E = y
CONFIG_EC_FLASH_SIZE_256K = y
# Enable eSPI
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
@@ -41,7 +42,32 @@ CFLAGS += \
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
CFLAGS += -DHAVE_CPU_FAN2=1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DFAN1_PWM_MIN=27
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(48, 27), \
FAN_POINT(52, 27), \
FAN_POINT(56, 33), \
FAN_POINT(60, 37), \
FAN_POINT(75, 53), \
FAN_POINT(83, 65), \
FAN_POINT(87, 75), \
FAN_POINT(89, 77), \
"
CFLAGS += -DFAN2_PWM=DCR3
CFLAGS += -DFAN2_PWM_MIN=27
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(48, 27), \
FAN_POINT(52, 27), \
FAN_POINT(56, 33), \
FAN_POINT(60, 37), \
FAN_POINT(75, 53), \
FAN_POINT(83, 65), \
FAN_POINT(87, 75), \
FAN_POINT(89, 77), \
"
# Add common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(F, 7);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -31,7 +31,7 @@ struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_PWR_EN = GPIO(E, 1);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2

View File

@@ -7,7 +7,8 @@ EC = ite
CONFIG_EC_ITE_IT5570E = y
CONFIG_EC_FLASH_SIZE_256K = y
# Enable eSPI
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
@@ -39,7 +40,32 @@ CFLAGS += \
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
CFLAGS += -DHAVE_CPU_FAN2=1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DFAN1_PWM_MIN=27
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(48, 27), \
FAN_POINT(52, 27), \
FAN_POINT(56, 33), \
FAN_POINT(60, 37), \
FAN_POINT(75, 53), \
FAN_POINT(83, 65), \
FAN_POINT(87, 75), \
FAN_POINT(89, 77), \
"
CFLAGS += -DFAN2_PWM=DCR3
CFLAGS += -DFAN2_PWM_MIN=27
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(48, 27), \
FAN_POINT(52, 27), \
FAN_POINT(56, 33), \
FAN_POINT(60, 37), \
FAN_POINT(75, 53), \
FAN_POINT(83, 65), \
FAN_POINT(87, 75), \
FAN_POINT(89, 77), \
"
# Add common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(F, 7);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -31,7 +31,7 @@ struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_PWR_EN = GPIO(E, 1);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT8587E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102
@@ -34,5 +37,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 6);
struct Gpio __code AC_PRESENT = GPIO(E, 7);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -43,7 +43,7 @@ struct Gpio __code VA_EC_EN = GPIO(E, 3);
struct Gpio __code VR_ON = GPIO(H, 4);
struct Gpio __code WLAN_EN = GPIO(H, 5);
struct Gpio __code WLAN_PWR_EN = GPIO(J, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// Enable LPC reset on GPD2
@@ -192,8 +192,6 @@ void gpio_init(void) {
GPCRH5 = GPIO_OUT;
// SUSB#_PCH
GPCRH6 = GPIO_IN;
// Unknown
GPCRH7 = GPIO_IN;
// BAT_DET
GPCRI0 = GPIO_ALT;
// BAT_VOLT

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -48,6 +47,5 @@ extern struct Gpio __code VR_ON;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
#define HAVE_XLP_OUT 0
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -10,6 +10,9 @@ EC=ite
CONFIG_EC_ITE_IT8587E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102
@@ -37,5 +40,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Include keyboard
KEYBOARD=15in_102
@@ -36,5 +37,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -40,7 +40,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -109,8 +109,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EN
GPCRB6 = GPIO_OUT | GPIO_UP;
// Does not exist
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -50,6 +49,5 @@ extern struct Gpio __code VR_ON;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Include keyboard
KEYBOARD=15in_102
@@ -37,5 +38,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -37,7 +37,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(F, 3);
struct Gpio __code WLAN_PWR_EN = GPIO(G, 1);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -111,8 +111,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
// Does not exist
GPCRB7 = GPIO_IN | GPIO_DOWN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -46,6 +45,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
CONFIG_SECURITY=y
@@ -39,5 +40,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -37,7 +37,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(F, 3);
struct Gpio __code WLAN_PWR_EN = GPIO(G, 1);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -112,8 +112,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
// Missing
GPCRB7 = GPIO_IN | GPIO_DOWN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -47,6 +46,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT8587E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=14in_86
@@ -35,5 +38,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=40 \
-DPOWER_LIMIT_DC=28
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 6);
struct Gpio __code AC_PRESENT = GPIO(E, 7);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -42,7 +42,7 @@ struct Gpio __code VA_EC_EN = GPIO(E, 3);
struct Gpio __code VR_ON = GPIO(H, 4);
struct Gpio __code WLAN_EN = GPIO(H, 5);
struct Gpio __code WLAN_PWR_EN = GPIO(J, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// Enable LPC reset on GPD2
@@ -191,8 +191,6 @@ void gpio_init(void) {
GPCRH5 = GPIO_OUT;
// SUSB#_PCH
GPCRH6 = GPIO_IN;
// Unknown
GPCRH7 = GPIO_IN;
// BAT_DET
GPCRI0 = GPIO_ALT;
// BAT_VOLT

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -47,6 +46,5 @@ extern struct Gpio __code VR_ON;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
#define HAVE_XLP_OUT 0
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -10,6 +10,9 @@ EC=ite
CONFIG_EC_ITE_IT8587E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=14in_86
@@ -38,5 +41,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=40 \
-DPOWER_LIMIT_DC=28
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Include keyboard
KEYBOARD=14in_83
@@ -18,9 +19,6 @@ CONFIG_HAVE_KBLED = y
KBLED=white_dac
CFLAGS+=-DKBLED_DAC=2
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -42,23 +40,27 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 25), \
FAN_POINT(80, 25), \
FAN_POINT(80, 40), \
FAN_POINT(88, 40), \
FAN_POINT(88, 100) \
FAN_POINT(88, 100), \
"
# DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(70, 25), \
FAN_POINT(75, 40), \
FAN_POINT(80, 75), \
FAN_POINT(85, 90), \
FAN_POINT(90, 100) \
FAN_POINT(90, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -41,7 +41,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -110,8 +110,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EC
GPCRB6 = GPIO_OUT | GPIO_UP;
// N/A
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -50,6 +49,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
CONFIG_SECURITY=y
@@ -42,5 +43,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -39,7 +39,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -114,8 +114,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_IN;
// SUSBC_EC
GPCRB6 = GPIO_OUT;
// Does not exist
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -49,6 +48,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -10,8 +10,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Enable firmware security
CONFIG_SECURITY=y
@@ -45,5 +46,15 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=65 \
-DPOWER_LIMIT_DC=45
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(70, 40), \
FAN_POINT(75, 50), \
FAN_POINT(80, 60), \
FAN_POINT(85, 65), \
FAN_POINT(90, 65), \
"
# Add system76 common code
include src/board/system76/common/common.mk

View File

@@ -7,6 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
# Include keyboard
KEYBOARD=15in_102
@@ -14,9 +17,6 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -36,23 +36,27 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=180 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -38,7 +38,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4); // renamed to SLP_SUS#
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -100,8 +100,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// H_PROCHOT_EC
GPCRB6 = GPIO_OUT | GPIO_UP;
//
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

View File

@@ -7,7 +7,6 @@
void gpio_init(void);
// clang-format off
extern struct Gpio __code ACIN_N;
extern struct Gpio __code AC_PRESENT;
extern struct Gpio __code ALL_SYS_PWRGD;
@@ -46,6 +45,5 @@ extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN;
extern struct Gpio __code XLP_OUT;
// clang-format on
#endif // _BOARD_GPIO_H

View File

@@ -7,8 +7,9 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
CONFIG_EC_FLASH_SIZE_128K = y
# Enable eSPI
CONFIG_BUS_ESPI=y
# Intel-based host
CONFIG_PLATFORM_INTEL = y
CONFIG_BUS_ESPI = y
# Include keyboard
KEYBOARD=15in_102
@@ -17,9 +18,6 @@ KEYBOARD=15in_102
CONFIG_HAVE_KBLED = y
KBLED=rgb_pwm
# Set discrete GPU I2C bus
CFLAGS+=-DI2C_DGPU=I2C_1
# Set battery I2C bus
CFLAGS+=-DI2C_SMBUS=I2C_4
@@ -41,27 +39,31 @@ CFLAGS+=\
-DPOWER_LIMIT_AC=180 \
-DPOWER_LIMIT_DC=45
# Custom fan curve
CFLAGS+=-DBOARD_HEATUP=5
CFLAGS+=-DBOARD_COOLDOWN=20
CFLAGS+=-DBOARD_FAN_POINTS="\
# Enable dGPU support
CONFIG_HAVE_DGPU = y
CFLAGS += -DI2C_DGPU=I2C_1
# Fan configs
CFLAGS += -DFAN1_PWM=DCR2
CFLAGS += -DBOARD_FAN1_HEATUP=5
CFLAGS += -DBOARD_FAN1_COOLDOWN=20
CFLAGS += -DBOARD_FAN1_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Enable DGPU support
CFLAGS+=-DHAVE_DGPU=1
CFLAGS+=-DBOARD_DGPU_HEATUP=5
CFLAGS+=-DBOARD_DGPU_COOLDOWN=20
CFLAGS+=-DBOARD_DGPU_FAN_POINTS="\
CFLAGS += -DFAN2_PWM=DCR4
CFLAGS += -DBOARD_FAN2_HEATUP=5
CFLAGS += -DBOARD_FAN2_COOLDOWN=20
CFLAGS += -DBOARD_FAN2_POINTS="\
FAN_POINT(60, 40), \
FAN_POINT(65, 60), \
FAN_POINT(70, 75), \
FAN_POINT(75, 90), \
FAN_POINT(80, 100) \
FAN_POINT(80, 100), \
"
# Add system76 common code

View File

@@ -3,7 +3,7 @@
#include <board/gpio.h>
#include <common/macro.h>
// clang-format off
// uncrustify:off
struct Gpio __code ACIN_N = GPIO(B, 0);
struct Gpio __code AC_PRESENT = GPIO(E, 1);
struct Gpio __code ALL_SYS_PWRGD = GPIO(C, 0);
@@ -36,7 +36,7 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);
struct Gpio __code XLP_OUT = GPIO(B, 4);
// clang-format on
// uncrustify:on
void gpio_init(void) {
// PWRSW WDT 2 Enable 2
@@ -105,8 +105,6 @@ void gpio_init(void) {
GPCRB5 = GPIO_OUT | GPIO_UP;
// SUSBC_EC#
GPCRB6 = GPIO_OUT | GPIO_UP;
//
GPCRB7 = GPIO_IN;
// ALL_SYS_PWRGD
GPCRC0 = GPIO_IN;
// SMC_VGA_THERM

Some files were not shown because too many files have changed in this diff Show More