Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ properties:
coprocessor's driver writes around a firmware restart, such as an
apple,t8140-display-power or apple,t6041-display-power node.

apple,ext-idle-power:
$ref: /schemas/types.yaml#/definitions/phandle-array
items:
- items:
- description: External display power gate provider.
- description: Byte offset of this coprocessor's retention register.
description:
Register window and retention word for an idle-only external
display coprocessor session on T6030.

apple,bw-scratch:
$ref: /schemas/types.yaml#/definitions/phandle-array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$id: http://devicetree.org/schemas/display/apple,t8140-display-power.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Apple T8103, T6040, T6041, T8132, T8140 and T8142 display power words
title: Apple display power manager registers

maintainers:
- Diljit Singh <hey@djdev.me>
Expand All @@ -20,6 +20,8 @@ properties:
compatible:
oneOf:
- enum:
- apple,t6030-display-power
- apple,t6030-dispext-power
- apple,t8103-display-power
- apple,t6041-display-power
- apple,t8132-display-power
Expand All @@ -40,6 +42,14 @@ properties:
minItems: 1
maxItems: 5

apple,gate-words:
$ref: /schemas/types.yaml#/definitions/uint32-array
minItems: 12
maxItems: 12
description:
Byte offsets of the external display power gate words in the T6030
power-gate register window, in firmware stop order.

'#address-cells':
const: 1

Expand Down Expand Up @@ -116,6 +126,39 @@ required:
- reg-names

allOf:
- if:
properties:
compatible:
contains:
const: apple,t6030-display-power
then:
properties:
reg:
items:
- description: Power gate retention registers
- description: PMGR power state registers
reg-names:
items:
- const: pwrgate
- const: ps

- if:
properties:
compatible:
contains:
const: apple,t6030-dispext-power
then:
properties:
reg:
maxItems: 1
reg-names:
const: pwrgate
required:
- apple,gate-words
else:
properties:
apple,gate-words: false

- if:
properties:
compatible:
Expand Down
30 changes: 30 additions & 0 deletions arch/arm64/boot/dts/apple/t6030-dcp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
clocks = <&clk_disp0>;
/* PTD bandwidth request entry 305 in the disp-5 update window. */
apple,bw-scratch = <&pmgr_dcp 0 5 0x988>;
apple,display-power = <&dcp_power>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
Expand All @@ -105,6 +106,17 @@
#apple,bw-scratch-cells = <3>;
};

/*
* Internal display power gates and PMGR power states for DCP sleep
* (DISP_CPU, DISP_FE, DISP_SYS; HV recs 1394816..1394848).
*/
dcp_power: display-power@350724000 {
compatible = "apple,t6030-display-power";
reg = <0x3 0x50724000 0x0 0x1000>,
<0x3 0x50700000 0x0 0x14000>;
reg-names = "pwrgate", "ps";
};

dcpext_dart: iommu@2d130c000 {
compatible = "apple,t6030-dart", "apple,t8110-dart";
reg = <0x2 0xd130c000 0x0 0x4000>;
Expand Down Expand Up @@ -132,6 +144,18 @@
status = "disabled";
};

/*
* DCPext power gates and CPU retention registers referenced by
* apple,ext-idle-power.
*/
dispext_power: dispext-power@350725000 {
compatible = "apple,t6030-dispext-power";
reg = <0x3 0x50725000 0x0 0x1000>;
reg-names = "pwrgate";
apple,gate-words = <0x8d0 0x850 0x7d0 0x750 0x650 0x5d0
0x550 0x4d0 0x450 0x3d0 0x2d0 0x250>;
};

dcpext: dcp@2d2c00000 {
compatible = "apple,t6030-dcpext", "apple,dcpext";
reg = <0x2 0xd2c00000 0x0 0x4000>;
Expand All @@ -141,6 +165,7 @@
iommus = <&dcpext_dart 5>;
power-domains = <&ps_dispext0_cpu>;
resets = <&ps_dispext0_cpu>;
apple,ext-idle-power = <&dispext_power 0x36c>;
phys = <&atcphy0 PHY_TYPE_DP>, <&atcphy1 PHY_TYPE_DP>,
<&atcphy2 PHY_TYPE_DP>;
phy-names = "typec0", "typec1", "typec2";
Expand All @@ -157,6 +182,8 @@
apple,dcp-index = <1>;
apple,typec-dptx-phys = <0 1 2>;
apple,typec-mux-indices = <0 0 0>;
apple,sleep-power-args = /bits/ 8 <0x01 0x00 0x00 0x01 0x01 0xaa 0xaa 0xaa>;
apple,sleep-a500-args = /bits/ 8 <0x00 0x01 0xaa 0xaa 0x00 0x00 0xaa 0xaa>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
Expand Down Expand Up @@ -241,6 +268,7 @@
iommus = <&dcpext1_dart 5>;
power-domains = <&ps_dispext1_cpu>;
resets = <&ps_dispext1_cpu>;
apple,ext-idle-power = <&dispext_power 0x6ec>;
phys = <&atcphy0 PHY_TYPE_DP>, <&atcphy1 PHY_TYPE_DP>,
<&atcphy2 PHY_TYPE_DP>;
phy-names = "typec0", "typec1", "typec2";
Expand All @@ -257,6 +285,8 @@
apple,dcp-index = <2>;
apple,typec-dptx-phys = <0 1 2>;
apple,typec-mux-indices = <2 2 2>;
apple,sleep-power-args = /bits/ 8 <0x01 0x00 0x00 0x01 0x01 0xaa 0xaa 0xaa>;
apple,sleep-a500-args = /bits/ 8 <0x00 0x01 0xaa 0xaa 0x00 0x00 0xaa 0xaa>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
Expand Down
12 changes: 12 additions & 0 deletions arch/arm64/boot/dts/apple/t6030-j516s.dts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
};

&dcp {
/*
* Firmware 27.2's display sleep calls on J516s, as macOS sends them to the internal
* DCP (A534, A550, A534, A464, A537).
*/
apple,sleep-power-args = /bits/ 8 <0x01 0x00 0x00 0x01 0x01 0xaa 0xaa 0xaa>;
apple,sleep-a500-args = /bits/ 8 <0x00 0x01 0xaa 0xaa 0x00 0x00 0xaa 0xaa>;
apple,sleep-display-power-args = /bits/ 8 <0x00 0x00 0x00 0x00 0x00 0xaa 0xaa 0xaa>;
apple,sleep-display-stage-args = /bits/ 8 <0x00 0x00 0x00 0x00 0x00 0xaa 0xaa 0xaa
0x01 0x00 0x00 0x00>;
apple,panel-video-open-delay-us = <10000>;
apple,panel-hdcp-open-arg = <3>;

panel: panel {
compatible = "apple,panel-j516", "apple,panel-mini-led", "apple,panel";
width-mm = <346>;
Expand Down
28 changes: 24 additions & 4 deletions drivers/gpu/drm/apple/afk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1911,12 +1911,14 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel,
ep->dcp->hw.firmware_compat == DCP_FIRMWARE_H17P) ||
ep->dcp->v27_j714s ||
(ep->dcp->fw_compat == DCP_FIRMWARE_V_27_0 &&
dcp_has_external_output(ep->dcp)) ||
(dcp_has_external_output(ep->dcp) ||
ep->dcp->hw.afk_name_fallback)) ||
(ep->dcp->v27_sleep_transport && !strcmp(name, "md-manager")))) {
/*
* H17G and firmware-27 T8142 can omit EPIC identity
* for powerlog-service. J716c's sleep transport
* admits only md-manager by name here.
* hw.afk_name_fallback covers firmware-27 T6030 internal DCP.
*/
epic_name = NULL;
epic_class = NULL;
Expand Down Expand Up @@ -2557,6 +2559,11 @@ static void afk_v2_callback(struct apple_dcp_afkep *ep,
kfree(owned_request);
afk_service_put(service);
reject:
if (ep->j516s_panel_service)
dev_info_ratelimited(ep->dcp->dev,
"AFKV2[ep:%02x]: panel callback rejected iface=%u type=%#x oob=%u tx=%u rx=%u status=%#x\n",
ep->endpoint, frame->interface, frame->type,
command->oob, command->tx_size, command->rx_size, status);
afk_v2_status(ep, frame, command, status);
}

Expand All @@ -2582,12 +2589,19 @@ static void afk_v2_receive(struct apple_dcp_afkep *ep, u32 channel, u32 type,
!frame.interface)
return;
if (frame.category == AFKV2_REPORT) {
if (ep->j516s_panel_service &&
READ_ONCE(ep->dcp->sleep_v27_closed) != DCP_V27_TX_LIVE)
dev_info_ratelimited(ep->dcp->dev,
"AFKV2[ep:%02x]: sleep/wake report iface=%u type=%#x flags=%#x len=%zu gate=%d\n",
ep->endpoint, frame.interface, frame.type,
frame.interface_flags, frame.payload_size,
READ_ONCE(ep->dcp->sleep_v27_closed));
if (frame.type == EPIC_SUBTYPE_ANNOUNCE_H17P)
afk_recv_handle_init(ep, frame.interface, (void *)frame.payload,
frame.payload_size);
else if ((frame.type == AFKV2_CLOSE && frame.interface_flags == 1) ||
((ep == ep->dcp->dcpavservep || afk_is_panelav(ep) ||
ep->v27_closed_teardown) &&
ep->v27_closed_teardown || ep->j516s_panel_service) &&
afkv2_closed_report(&frame)))
afk_recv_handle_teardown(ep, frame.interface);
return;
Expand Down Expand Up @@ -3042,7 +3056,7 @@ static int afk_send_epic_token(struct apple_dcp_afkep *ep, u32 channel, u16 tag,
u8 v2_command[AFKV2_COMMAND_SIZE + AFKV2_OOB_SIZE];
u8 v2_category = 0;
u16 v2_flags = 0;
int ret;
int gate, ret;

/* External H17P services use AFKV2; the internal profile has no EPIC sender. */
if (ep->dcp->fw_compat == DCP_FIRMWARE_H17P && !ep->wire_v2) {
Expand Down Expand Up @@ -3093,7 +3107,13 @@ static int afk_send_epic_token(struct apple_dcp_afkep *ep, u32 channel, u16 tag,

mutex_lock(&ep->tx_lock);
spin_lock_irqsave(&ep->lock, flags);
if (READ_ONCE(ep->dcp->sleep_v27_closed) && ecat != EPIC_CAT_REPLY) {
gate = READ_ONCE(ep->dcp->sleep_v27_closed);
if (gate != DCP_V27_TX_LIVE && ecat != EPIC_CAT_REPLY &&
!(gate == DCP_V27_TX_PANEL_OPEN && ep->j516s_panel_service && ep->wire_v2 &&
((etype == EPIC_TYPE_NOTIFY && ecat == EPIC_CAT_REPORT &&
stype == AFKV2_OPEN && !payload_len) ||
(ep->inline_v2 && etype == EPIC_TYPE_COMMAND &&
ecat == EPIC_CAT_COMMAND)))) {
ret = -EBUSY;
goto out;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/afk.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ struct apple_dcp_afkep {
bool match_epic_name;
/* Firmware 27: this endpoint's services end with the firmware's closed report. */
bool v27_closed_teardown;
bool j516s_panel_service;
};

/*
Expand Down
23 changes: 21 additions & 2 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ struct apple_dcp_hw_data {
/* A firmware 27 sleep in progress, and how it ended */
bool v27_sleep_protocol;
bool v27_sleep_recovery;
/*
* Firmware 27 sleep with the DCP stopped at its own suspend (T6030), see
* dcp_v27_early_suspend(). Needs @s2r_layout.
*/
bool v27_early_stop;
/* Required with @s2r */
const struct dcp_s2r_layout *s2r_layout;
/* @s2r with derived power words: firmware 27.0 only, off with appledrm.s2r_untested=0 */
Expand All @@ -429,6 +434,8 @@ struct apple_dcp_hw_data {
* properties after it are not parsed (afk_recv_handle_init()).
*/
bool afk_announced_names;
/* Match firmware-27 AFK services by announced name if identity is missing. */
bool afk_name_fallback;
/*
* How long AFK waits for the firmware to start or stop an endpoint
* and to answer a command or service call (afk_timeout_ms()); zero
Expand Down Expand Up @@ -984,12 +991,22 @@ struct apple_dcp {

/* A firmware-driven suspend stops the firmware, see dcp_s2r_suspend(). */
struct apple_dcp_afkep *sleep_v27_ep[0x20];
/* T6030 internal DCP: the service endpoints macOS runs (dcp_v27_early_services_start()) */
struct apple_dcp_afkep *v27_early_svc_ep[0x20];
/* The J714s normal method table, panel services and swap profile. */
bool v27_j714s;
/* Sleep endpoint inventory and control replies; not a normal RPC profile. */
bool v27_sleep_transport;
struct dcp_v27_sleep *sleep_v27;
bool sleep_v27_closed;
/* Stopped at its own suspend for a firmware 27 sleep, see dcp_v27_early_suspend(). */
struct dcp_v27_early *v27_early;
/* TEST: a T6030 dcpext on the 27.2 image, idle-only (dcp-t6030-ext272.inc) */
struct dcp_ext272 *ext272;
enum {
DCP_V27_TX_LIVE,
DCP_V27_TX_REPLIES,
DCP_V27_TX_PANEL_OPEN,
} sleep_v27_closed;
/*
* Its display on a USB-C port was released for a firmware sleep and the DRM device
* has not resumed since: the CRTC's saved mode is not restored (it resumes disabled,
Expand Down Expand Up @@ -1200,7 +1217,7 @@ struct apple_dcp {
/* Since the V27 wake: the panel's video interface opened, firmware reported the panel */
struct completion v27_wake_video, v27_wake_hotplug;
#define V27_WAKE_VIDEO_MS 1500
#define V27_WAKE_HOTPLUG_MS 250
#define V27_WAKE_HOTPLUG_MS 1000
/* V27 sleep: the output area of the call being pushed holds this (an in/out word) */
const void *push_out_prefill;

Expand Down Expand Up @@ -1732,4 +1749,6 @@ static inline void dcp_note_swap_complete(struct apple_dcp *dcp, u32 swap_id, bo
atomic_inc(&dcp->shown_swaps);
}

int dcpext_verify_memory(struct apple_dcp *dcp);

#endif /* __APPLE_DCP_INTERNAL_H__ */
Loading
Loading