Repository navigation
kboot: T8132 USB3 calibration, AOP handoff and absent-ISP rule by ADT property #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
techmore
wants to merge
3
commits into
aurora-silicon:main
Choose a base branch
from
techmore:m4/j773g-dt-adt-gates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+842
−29
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* SPDX-License-Identifier: MIT */ | ||
| /* | ||
| * T8132 (M4) rules. They live here, not in kboot.c: kboot.c's code is linked into Stage 1's | ||
| * .init slot (aura-raw.ld), which has almost no room left. | ||
| */ | ||
|
|
||
| #include "kboot.h" | ||
| #include "adt.h" | ||
| #include "utils.h" | ||
|
|
||
| #include "libfdt/libfdt.h" | ||
|
|
||
| #define bail(...) \ | ||
| do { \ | ||
| printf(__VA_ARGS__); \ | ||
| return -1; \ | ||
| } while (0) | ||
|
|
||
| /* Whether a node other than skip names the IOMMU phandle in its iommus list. */ | ||
| static bool dt_iommu_shared(const void *dt, u32 phandle, int skip) | ||
| { | ||
| int node; | ||
|
|
||
| for (node = fdt_next_node(dt, -1, NULL); node >= 0; node = fdt_next_node(dt, node, NULL)) { | ||
| int len; | ||
| const fdt32_t *iommus = node == skip ? NULL : fdt_getprop(dt, node, "iommus", &len); | ||
|
|
||
| for (int i = 0; iommus && i + 1 < len / (int)sizeof(*iommus); i += 2) | ||
| if (fdt32_ld(&iommus[i]) == phandle) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /* | ||
| * A T8132 Mac without a camera (the J773g) has no isp or isp0 in its ADT. A tree that enables | ||
| * the ISP there would have the OS probe a camera and power domains that do not exist: disable | ||
| * the ISP and the DARTs that only it uses. A tree that leaves it disabled is not changed. | ||
| */ | ||
| int dt_disable_t8132_absent_isp(void *dt) | ||
| { | ||
| if (adt_path_offset(adt, "/arm-io/isp") >= 0 || adt_path_offset(adt, "/arm-io/isp0") >= 0) | ||
| return 0; | ||
|
|
||
| int isp = -1; | ||
| while ((isp = fdt_node_offset_by_compatible(dt, isp, "apple,t8132-isp")) >= 0) { | ||
| const char *status = fdt_getprop(dt, isp, "status", NULL); | ||
| if (status && !strcmp(status, "disabled")) | ||
| continue; | ||
|
|
||
| /* One cell of stream ID per DART, as in t8132.dtsi. Decide before any write. */ | ||
| u32 darts[8]; | ||
| bool own[8]; | ||
| int len, count = 0; | ||
| const fdt32_t *iommus = fdt_getprop(dt, isp, "iommus", &len); | ||
| int cells = iommus && len > 0 && !(len % sizeof(*iommus)) ? len / sizeof(*iommus) : 0; | ||
| if (!(cells % 2) && cells / 2 <= (int)ARRAY_SIZE(darts)) | ||
| for (; count < cells / 2; count++) { | ||
| darts[count] = fdt32_ld(&iommus[2 * count]); | ||
| own[count] = !dt_iommu_shared(dt, darts[count], isp); | ||
| } | ||
|
|
||
| if (fdt_setprop_string(dt, isp, "status", "disabled")) | ||
| bail("FDT: cannot disable the T8132 ISP\n"); | ||
| for (int i = 0; i < count; i++) { | ||
| int dart = own[i] ? fdt_node_offset_by_phandle(dt, darts[i]) : -1; | ||
| if (dart >= 0 && fdt_setprop_string(dt, dart, "status", "disabled")) | ||
| bail("FDT: cannot disable a T8132 ISP DART\n"); | ||
| } | ||
| printf("FDT: no ISP in the ADT; T8132 ISP disabled with the DARTs only it uses\n"); | ||
| isp = -1; /* Offsets moved; start over. Disabled nodes are skipped. */ | ||
| } | ||
| return 0; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a camera-less T8132 with an
ispalias and enabled ISP/DART nodes,kboot_prepare_dt()executesdt_set_isp()before this helper (src/kboot.c:11457–11460). The generic step fails to find either ADT ISP node and sets the ISP todisabled, so this early skip bypasses all DART cleanup and leaves the unused ISP DARTs enabled in the handed-off tree. Running both production steps in order reproduces an exclusively owned DART remainingokay; move the absence gate before generic ISP setup, or allow it to clean up DARTs when the preceding step disabled the ISP.Useful? React with 👍 / 👎.