Commit graph

928 commits

Author SHA1 Message Date
Janne Grunau
e4ea2d5319 kboot: dcp: Use OS firmware 13.5 as compat version
The dptxport endpoint changed API between 13.3 and 13.5. Nobody is
supposed to run 13.3 OS firmware at this point so do not claim to be
compatible. The DCP linux driver is fixed since a couple of weeks to
accept 13.5 as compat version.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
4ce65e1c08 kboot: dcpext: Enable dcpext* on t600x only with firmware 13.5
Only the HDMI port on 14 and 16 inch Macbook Pros needs dcpext and the
dptxport endpoint implemention in the DCP driver supports only the 13.5
firmware. Postpone this for after the fedora release.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
c9ae791b79 kboot: dcpext: t8112/t602x: Use dt_reserve_asc_firmware() for dcpext*
Avoids manually matching pre-mapped memory against "carveout-memory-map"
and maintaining a list of hopefully static carveoout regions.
Leave t8103 and t600x alone for now. Porting dcp over to this a littles
harder since that needs additional handling for regions mapped to
"dart-disp0?".

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
9a3a1271a5 kboot: Align segment sizes to 16k in dt_reserve_asc_firmware()
The segment for the dcp firmware text is inexplicably only aligned to 4k.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
69e3610737 display: Optionally use dcpext0/1 on t6020 and t6021
Allows emulating a t6022 system with fused off dcp0/dcp1 display
controllers.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
8c99a189e0 dptx: Add the number of dptxport services
Avoids waiting 500 ms for the second dptxport service on t6020 and
possibly t6021.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Hector Martin
787eb8c220 display: More Sonoma workarounds
Power up display early (fixes HPD sometimes) and delay at least one
frame after swapping before quiescing DCP, otherwise the swap somehow
doesn't complete.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 19:19:10 +09:00
Hector Martin
5cecf53144 everything: Use calloc instead of malloc almost everywhere
This fixes at least one and likely more than one bug where we forgot to
zero-init.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
321a80c928 afk: Increase timeout from 500 loops to 500ms (time-based)
This should hopefully solve the reliability issues here.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
40a9444484 display,fb: Clear framebuffer early in the Sonoma stage2 fixup path
stage1 ends up with an ugly Asahi 100% logo on top of a 200% Apple logo.
Let's just clear it so it looks nicer.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
6af39a9b40 display: Try to modeset twice
This works around issues switching to 120Hz mode on systems affected by
the Sonoma situation, and in general it's probably a good idea anyway.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:27 +09:00
Hector Martin
c887c3cb54 display: Work around macOS Sonoma firmware bugs
It appears that when macOS is set to non-ProMotion mode, DCP firmware
<14.0 booted from DCP firmware 14.0+ needs a delay before modesetting to
complete the modeset properly.

The cases here are:
- Older m1n1 stage1 will, as far as it's concerned, initialize the
  display properly, but it won't work. It also misses the retina flag,
  since this codepath was intended for external displays. Use the
  missing retina flag as a signal to trigger reconfig.
- If installed as stage1, we reconfigure the display as usual, now with
  the extra delay. We also set the Retina flag now.

The persistence mechanism for the ProMotion flag is unknown. It doesn't
seem to be nvram. It also doesn't matter if we successfully modeset to
120Hz mode and then reboot, it breaks again, so it's not about the
"current" mode sticking.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:26 +09:00
Janne Grunau
9a277fadc9 dcp/afk: Retry harder to init afk endpoints/services
Extend start_interface() with the number of expected services so it can
stop when all services are initialized.

Fixes failed display init on some devices in stage 1 due to a too slow
IOP which does not manage to send service announce messages in 20
mailbox / ringbuffer query operations.

Proper fix for this is to let the endpoint implementations drive the
initialization via afk_epic_work() until the expected services are
found.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-13 16:33:09 +09:00
Janne Grunau
1ea734296a dcp: Fix shutdown sequence on dptx errors
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-13 16:33:09 +09:00
Hector Martin
6de69564bd cpufreq: Fix t6022 clusters
We were only initializing the first die...

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-08 19:14:33 +09:00
Asahi Lina
250f96bb15 hv_vm: Implement scalar LDNP instructions
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-08 16:12:59 +09:00
James Calligeros
c3820a5016 smc: fix smc_init() definition
clang 17 now enforces strict prototyping. add void to the parameters
to fix building with clang going forward.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-10-08 16:09:18 +09:00
Janne Grunau
50ac69eaa5 dcp: Wait 25ms after enabling dcp/dptx-phy power-domains
Fixes display initialization from stage 1 m1n1. 20ms looked reliable on
j473 but let's add 25% safety margin. Someone with more motivation (and
HW serial) to do repeated `kmutil configure-boot ...` can try to
minimize this and test on t602x.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-07 21:56:19 +09:00
Janne Grunau
0097d51149 afk/dptx: Convert noisy/misleading printf to dprintf
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-07 21:56:19 +09:00
Asahi Lina
7e3e9ac301 isp, kboot: Misc changes for t8112
Probably doesn't do anything...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
d07ea82821 kboot: Add firmware versions to ISP node
Might be useful...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
182fddd31e kboot: Fix ISP remap on t8103/t8112
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
6aca0608d8 isp: Handle high mapped VAs for t602x
This is similar to some of the other hardware we've seen on this SoC...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Hector Martin
0b7708f98e kboot: Try isp/isp0 for reserving firmware
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00
Hector Martin
5a632bad87 kboot: Make dt_get_or_add_reserved_mem mutate existing nodes
This means we can use it with pre-created nodes in the DT.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00
Hector Martin
4ae23577cc kboot: Handle ISP heap carveout
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00
Hector Martin
c03f94c86a kboot: Handle ISP/SIO reserved firmware differences
The iova field is different, handle it with a flag.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00
Hector Martin
dd2d4e5441 kboot: Use adt_segment_ranges struct instead of open-coding
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00
Eileen Yoon
f4d6d2069a isp: ISP init module
Co-authored-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-10-05 14:21:13 +09:00
Eileen Yoon
f89e33c5ee kboot: Reserve ISP firmware
Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-10-05 14:19:31 +09:00
Hector Martin
ee536f7414 pmgr: Expose pmgr_set_mode
For ISP stuff which is not declared in the ADT

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:19:31 +09:00
Hector Martin
e1421f6fef dapf: Also (try to) init dart-isp0
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:19:31 +09:00
Eileen Yoon
6072b8facf dapf: Support reg indexing + add ISP
Also enable power if domain exists.

Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-10-05 14:13:45 +09:00
Janne Grunau
187e7f8893 kboot/gpu: Add "no-map" property for reserved memory nodes
Without this property u-boot will add reserved memory regions to the
EFI memory map with the wrong type. This results in Linux mapping it
and thus breaking the intended use in the asahi driver.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 14:02:07 +09:00
Daniel Berlin
da1f50be74 Issue error message if firmware_set_fdt fails
Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
2023-10-05 14:01:17 +09:00
Janne Grunau
31ee1499f8 display: Support the HDMI output on M2* desktop systems
On M2* desktop systems the HDMI output is not managed by dcp/dcp0. This
allows more flexibility, for example dcp on the M2 Mac mini can be
routed to the USB-C/ThunderBolt ports.
For m1n1 this adds quite ab bit of complexity. In addition to the DCP
iboot endpoint/protocol two additional endpoints have to be started.
Only the dptx-port endpoint has a meaningful AP <=> DCP communication.
In addition we start the system endpoint to optionally enable more
verbose syslog messages (if RTKIT_SYSLOG is defined).
In addition the dptx-phy or lpdptx-phy has to be programmed. Those two
phy look mostly identical. MacOS seems to use a static DP configuration
(4 lanes, HBR3*) regardless of the connected display.
The added SMC gpio support is used to power the MCDP29xx DP to HDMI
converter on.
Config  is unfortunately a mess since Apple can't name the device tree
nodes consistently. On M2 Ultra devices only the four dcpext*/dispext*
on each die are used. M2 Ultra support is untested.

* link rate might differ on t602x based devices for 8k60 support

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
517c8e5f5b smc: Add minimal smc client
Only supported operation is smc_write_u32() for turning the dp2hdmi
converter on M2 desktop systems on.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
b65c7d1edc rtkit: Support usage with SRAM
Will be used by SMC.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
41e4e25eed dcp/system: Add system endpoint
This on is boring but allows turning additional logging on.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
f46da8bbbb dcp/dpav: Add DPAV endpoint
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
b44a862756 dcp/dptx: Add dptx-port endpoint
Based on the linux kernel implementation with updates for the macOS 13.5
based DCP firmware.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
2b58bfd24b dcp: Do not use an anonymous struct for dcp_dev_t typedef
This allows forward declarations in other headers.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
73b78abe3b afk: epic channel/interface numbers do not reset
They exceed 256 with repeated chainloading of m1n1.bin on j473. Do not
hold a service for every possible channel but keep a fixed array of 8
services identified by the channel number.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
14826241a9 afk: Add EPIC std services IOp -> AP calls
Used on dptx-port endpoint.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
7473a0779e afk: use increasing EPIC sequence numbers
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
29b6e668f9 afk: Introduce EPIC services
To be used on the dptx-port endpoint.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
a4c4b8cd99 afk: Fix a NULL pointer dereference in adfk_epic_send()
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
76fbc77ad2 afk: Prepare afk/epic for handling of multiple endpoints
This needs to ensure that the data processing does not block on
message retrieval from the mailbox. Command processing must not block
and have to ensure that afk_epic_command() receives the reply to its
command.
DCP's dptx-port endpoint (endpoint 0x2a) can send notifies at any time
which needs to be processed in the right context.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
84c0aa10bb afk: Sync structs/names with proxyclient's python definitions
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
64ab7258a8 dcp: dptx-phy: make dptx_phy_set_link_rate() SoC independent
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00