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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ description: |
mux cells 0, 1 and 2 describe the DP PHY, DP IN 0 and DP IN 1 outputs,
respectively. The per-port prefix distinguishes multiple ATCs on one DCP.
Dual-stream wiring requires these two named controls and two port@3
endpoints. It does not describe SoC handshake or retry policy.
endpoints. It does not describe SoC handshake or retry policy. T6050 host
routers have four DP IN adapters; their crossbars add typecN-dpin2 and
typecN-dpin3 (cells 3 and 4).

Legacy typecN-usb4 names describe cell 1 on old j414/j416 DTBs. With two
port@3 endpoints they retain the existing dual-stream wiring; cell 2 is
Expand Down Expand Up @@ -56,12 +58,12 @@ properties:

mux-controls:
minItems: 1
maxItems: 13
maxItems: 21
description: Fixed, DP Alt Mode and wired DP IN crossbar output controls.

mux-control-names:
minItems: 1
maxItems: 13
maxItems: 21
items:
anyOf:
- enum:
Expand All @@ -72,12 +74,20 @@ properties:
- typec3
- typec0-dpin0
- typec0-dpin1
- typec0-dpin2
- typec0-dpin3
- typec1-dpin0
- typec1-dpin1
- typec1-dpin2
- typec1-dpin3
- typec2-dpin0
- typec2-dpin1
- typec2-dpin2
- typec2-dpin3
- typec3-dpin0
- typec3-dpin1
- typec3-dpin2
- typec3-dpin3
- enum: [typec0-usb4, typec1-usb4, typec2-usb4, typec3-usb4]
deprecated: true

Expand Down Expand Up @@ -113,12 +123,26 @@ properties:
- maximum: 3
mode-switch:
type: boolean
apple,tunnel-only:
type: boolean
description: |
The route carries USB4 DP tunnels only and is never given a DP
Alt Mode display. It is not a Type-C mode-switch, so a port
whose connector already has as many mode-switch providers as
the Type-C class allows can still offer another tunnel
pipeline.
port:
$ref: /schemas/graph.yaml#/properties/port
required:
- reg
- mode-switch
- port
if:
not:
required:
- apple,tunnel-only
then:
required:
- mode-switch
required:
- '#address-cells'
- '#size-cells'
Expand Down
13 changes: 12 additions & 1 deletion Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,23 @@ properties:
maxItems: 1
mode-switch:
type: boolean
apple,tunnel-only:
type: boolean
description:
The route carries USB4 DP tunnels only, never a DP Alt Mode
display. It is not a Type-C mode-switch.
port:
$ref: /schemas/graph.yaml#/properties/port
required:
- reg
- mode-switch
- port
if:
not:
required:
- apple,tunnel-only
then:
required:
- mode-switch
additionalProperties: false
required:
- '#address-cells'
Expand Down
52 changes: 47 additions & 5 deletions arch/arm64/boot/dts/apple/t6050-j714s-display.dtsi
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
* J714s external displays: DisplayPort alt mode on the left-front and right ports and USB4
* DisplayPort tunnels on the right port. dcpext0 and dcpext2 drive the routes; dcpext1 and
* dcpext3 are their pairs for modes that need two pipelines. The left-back port (ATC0) is the
* debug port and is not described. Addresses and interrupts are from the J714sAP ADT. The boot
* loader hands each engine over: it enables the engine, its mailbox and DARTs, publishes its
* bandwidth scratch and adds its display DART to the display subsystem.
* DisplayPort tunnels on the right port. dcpext0 and dcpext2 drive the DP alt mode and tunnel
* routes, dcpext1 a third tunnel on the right port only; dcpext3 is the pair for modes that
* need two pipelines. The left-back port (ATC0) is the debug port and is not described.
* Addresses and interrupts are from the J714sAP ADT. The boot loader hands each engine over: it
* enables the engine, its mailbox and DARTs, publishes its bandwidth scratch and adds its
* display DART to the display subsystem.
*/

&dcpext1 {
apple,dcp-index = <2>;
apple,connector-type = "USB-C";
apple,dptx-die = <0>;
/*
* A third pipeline for USB4 DP tunnels on the right port, so a dock can
* drive three displays as on macOS. Routing dcpext1 stops it being a
* merged-mode peer; dcpext0, dcpext1 and dcpext2 then pair with dcpext3,
* so only one display wider than one pipeline runs at a time.
* Crossbar source 2 (dispext1 port 0) follows the 2 * dispext pattern of
* dcpext0 (0) and dcpext2 (4), and the T6040 dcpext1 (2).
* No mode-switch: hpm2 already has TYPEC_MUX_MAX_DEVS (3) mode-switch
* providers; tunnels find the port through the endpoint, not the mux.
* apple,tunnel-only keeps DP alt mode displays off it: only tunnels
* have been driven through it.
*/
apple,typec-dptx-phys = <2>;
apple,typec-mux-indices = <2>;
phys = <&atc2_phy 6>;
phy-names = "typec0";
mux-controls = <&atc2_xbar 0>, <&atc2_xbar 1>, <&atc2_xbar 2>, <&atc2_xbar 3>,
<&atc2_xbar 4>;
mux-control-names = "typec0", "typec0-dpin0", "typec0-dpin1", "typec0-dpin2",
"typec0-dpin3";

typec-routes {
#address-cells = <1>;
#size-cells = <0>;

route@0 {
reg = <0>;
apple,tunnel-only;

port {
dcpext1_right: endpoint {
remote-endpoint = <&hpm2_dp2>;
};
};
};
};
};

&dcpext2 {
Expand Down Expand Up @@ -111,6 +148,11 @@
reg = <1>;
remote-endpoint = <&dcpext2_right>;
};

hpm2_dp2: endpoint@2 {
reg = <2>;
remote-endpoint = <&dcpext1_right>;
};
};
};
};
Expand Down
20 changes: 15 additions & 5 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,22 +1234,28 @@ static int apple_probe_per_dcp(struct device *dev,
* connector per port for a dock's second DP tunnel, preserving primary
* connector names. T6050 instead exposes one connector per port/pipeline
* pair: tunnel allocation chooses which connector is connected, without
* changing any encoder's advertised CRTC mask after registration.
* changing any encoder's advertised CRTC mask after registration. Pairs
* whose route carries DP tunnels only come last, so adding such a route
* does not renumber the connectors that existed before it.
*/
static int apple_probe_typec_ports(struct drm_device *drm,
struct platform_device **dcp,
u32 *crtc_mask, int num_dcp)
{
unsigned int idx, nr_ports = dcp_typec_nr_ports();
unsigned int n, nr_ports = dcp_typec_nr_ports();
bool fixed = dcp_typec_fixed_crtcs();
unsigned int slots = fixed ? num_dcp : (dcp_typec_dual_stream() ? 2 : 1);
/* T6050 creates its tunnel-only port/pipeline pairs in a second pass. */
unsigned int passes = fixed ? 2 : 1;
int i, ret;

/* Keep the existing physical-port connector numbers stable. On the
* M2 Pro/Max laptops, append one more connector per port for a second
* USB4 DP tunnel.
*/
for (idx = 0; idx < nr_ports * slots; idx++) {
for (n = 0; n < passes * nr_ports * slots; n++) {
unsigned int pass = n / (nr_ports * slots);
unsigned int idx = n % (nr_ports * slots);
struct apple_connector *connector;
struct apple_encoder *enc;
struct platform_device *pipeline = fixed ? dcp[idx / nr_ports] : NULL;
Expand All @@ -1259,14 +1265,18 @@ static int apple_probe_typec_ports(struct drm_device *drm,

/* Only a failed T8122 dcpext could drive it: no connector. */
if (dcp_typec_port_unusable(port_idx)) {
drm_warn(drm, "Type-C port %u: its display pipeline is unusable\n",
port_idx);
if (!pass)
drm_warn(drm, "Type-C port %u: its display pipeline is unusable\n",
port_idx);
continue;
}

if (fixed) {
if (!dcp_typec_port_has_candidate(port_idx, pipeline))
continue;
/* T6050: tunnel-only pairs in the second pass */
if (dcp_typec_port_tunnel_only(port_idx, pipeline) != pass)
continue;
mask = crtc_mask[idx / nr_ports];
if (!mask)
continue;
Expand Down
39 changes: 32 additions & 7 deletions drivers/gpu/drm/apple/dcp-fabric-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ dcp_fabric_free_route(const struct dcp_fabric_port *port,
for (route = port->routes; route; route = route->next) {
unsigned int score;

if (!dcp_fabric_available(route->pipeline, policy))
if (route->tunnel_only ||
!dcp_fabric_available(route->pipeline, policy))
continue;
score = dcp_fabric_score(route->pipeline, policy);
if (score < best_score) {
best = route;
best_score = score;
}
}
if (!last || !dcp_fabric_available(last->pipeline, policy))
if (!last || last->tunnel_only ||
!dcp_fabric_available(last->pipeline, policy))
return best;
if (!policy->dual_stream && best &&
best_score < dcp_fabric_score(last->pipeline, policy))
Expand All @@ -215,6 +217,17 @@ dcp_fabric_port_route(const struct dcp_fabric_port *port,
return NULL;
}

/* Does a DP tunnel hold any of @port's owner slots? */
static bool dcp_fabric_port_tunneled(const struct dcp_fabric_port *port)
{
unsigned int i;

for (i = 0; i < DCP_FABRIC_DPIN_MAX; i++)
if (port->owner[i] && port->owner[i]->tunnel)
return true;
return false;
}

static void dcp_fabric_plan_pipeline(struct dcp_fabric_pipeline *pipeline,
const struct dcp_fabric_port *ports,
const struct dcp_fabric_port *arriving,
Expand Down Expand Up @@ -242,10 +255,11 @@ static void dcp_fabric_plan_pipeline(struct dcp_fabric_pipeline *pipeline,
BIT(pipeline->crtc_index)))
continue;
route = dcp_fabric_port_route(port, pipeline);
tunnel = stream || (port->owner[0] && port->owner[0]->tunnel) ||
tunnel = stream || dcp_fabric_port_tunneled(port) ||
(port == arriving && dpin == 0);
if (!route || (tunnel &&
(route->tunnel_clock_blocked & BIT(stream))))
(route->tunnel_clock_blocked & BIT(stream))) ||
(!tunnel && route->tunnel_only))
continue;
port->plan->target[stream] = route;
return;
Expand Down Expand Up @@ -288,11 +302,18 @@ void dcp_fabric_plan(struct dcp_fabric_pipeline *pipelines,
}
EXPORT_SYMBOL_GPL(dcp_fabric_plan);

/* 1 means an already handed, matching stream; zero admits allocation. */
/*
* 1 means an already handed, matching stream; zero admits allocation.
* @per_dpin: DP IN 2 and 3 have owner slots of their own.
*/
int dcp_fabric_tunnel_slot(const struct dcp_fabric_port *port,
unsigned int dpin)
unsigned int dpin, bool per_dpin)
{
const struct dcp_fabric_route *slot = port->owner[dcp_fabric_dpin_slot(dpin)];
const struct dcp_fabric_route *slot;

if (dpin >= DCP_FABRIC_DPIN_MAX)
return -EINVAL;
slot = port->owner[dcp_fabric_tunnel_owner(dpin, per_dpin)];

if (slot)
return slot->tunnel && slot->dpin == dpin ? 1 : -EADDRINUSE;
Expand Down Expand Up @@ -391,6 +412,10 @@ dcp_fabric_follow(const struct dcp_fabric_route *from,
(holder->dpin >= DCP_FABRIC_DPIN_MAX ||
(holder_back->tunnel_clock_blocked & BIT(holder->dpin)))))
return DCP_FABRIC_FOLLOW_REFUSE;
/* A direct stream never moves onto a tunnel-only route. */
if ((!from->tunnel && to->tunnel_only) ||
(holder && !holder->tunnel && holder_back && holder_back->tunnel_only))
return DCP_FABRIC_FOLLOW_REFUSE;
pipeline = to->pipeline;
if (!pipeline->bound || pipeline->fixed_busy || pipeline->terminal ||
!pipeline->services_ready)
Expand Down
28 changes: 24 additions & 4 deletions drivers/gpu/drm/apple/dcp-fabric-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
/*
* A Thunderbolt DP tunnel enters through one of up to four DP IN adapters of
* the port's host router, each behind a crossbar output of its own. A port
* carries at most two streams, primary and secondary: DP IN n and n + 2 share
* a stream slot.
* carries two streams, primary and secondary: DP IN n and n + 2 share a
* stream slot. Where every pipeline drives one DP IN of its own (T6050, fixed
* CRTCs), DP IN 2 and 3 have owner slots of their own as well; see
* dcp_fabric_tunnel_owner().
*/
#define DCP_FABRIC_DPIN_MAX 4

Expand All @@ -18,6 +20,16 @@ static inline unsigned int dcp_fabric_dpin_slot(unsigned int dpin)
return dpin & 1;
}

/*
* The owner slot (dcp_fabric_port.owner[]) of DP IN @dpin: its stream slot,
* or the DP IN itself when @per_dpin, each pipeline taking one DP IN.
*/
static inline unsigned int dcp_fabric_tunnel_owner(unsigned int dpin,
bool per_dpin)
{
return per_dpin ? dpin : dcp_fabric_dpin_slot(dpin);
}

enum dcp_fabric_presence_state {
DCP_FABRIC_ABSENT,
DCP_FABRIC_SETTLING,
Expand Down Expand Up @@ -53,6 +65,8 @@ struct dcp_fabric_route {
unsigned int dpin;
/* DP IN adapters this source cannot clock; direct DP is unaffected. */
u8 tunnel_clock_blocked;
/* Carries DP tunnels only, never a direct DP-alt stream. */
bool tunnel_only;
};

struct dcp_fabric_plan {
Expand All @@ -65,7 +79,13 @@ struct dcp_fabric_port {
unsigned long key;
struct dcp_fabric_port *next;
struct dcp_fabric_route *routes;
struct dcp_fabric_route *owner[2];
/*
* Indexed by dcp_fabric_tunnel_owner(): [0] the primary stream (direct
* DP, DP IN 0, and DP IN 2 unless per-DP IN), [1] the secondary (DP
* IN 1, and 3 unless per-DP IN), [2] and [3] DP IN 2 and 3 with per-DP
* IN slots.
*/
struct dcp_fabric_route *owner[DCP_FABRIC_DPIN_MAX];
struct dcp_fabric_route *preferred;
u32 candidate_crtcs[2];
bool wanted;
Expand Down Expand Up @@ -196,7 +216,7 @@ void dcp_fabric_plan(struct dcp_fabric_pipeline *pipelines,
const struct dcp_fabric_port *ports,
const struct dcp_fabric_port *arriving, unsigned int dpin);
int dcp_fabric_tunnel_slot(const struct dcp_fabric_port *port,
unsigned int dpin);
unsigned int dpin, bool per_dpin);
struct dcp_fabric_route *
dcp_fabric_tunnel_candidate(const struct dcp_fabric_port *port,
const struct dcp_fabric_policy *policy,
Expand Down
Loading
Loading