Skip to content
Closed
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
21 changes: 17 additions & 4 deletions drivers/gpu/drm/apple/dcp-fabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ bool dcp_is_t8132_ext(const struct apple_dcp *dcp)
return of_device_is_compatible(dcp->dev->of_node, "apple,t8132-dcpext");
}

/*
* A T6030 display processor, from its compatible's match data. Its outputs go
* through the T6030 display crossbars (apple,t6030-display-crossbar): there a
* selected output is only routed until its link is brought up, which starts
* its clocks, and only external sources 0 and 2 feed the ATC tunnel pixel
* clocks (dcp_fabric_t6030_pclk()). The T6031 and T6034 processors have
* their own compatibles and keep the default flow.
*/
bool dcp_is_t6030_fabric(const struct apple_dcp *dcp)
{
return dcp->hw.t6030_fabric;
}

/*
* DP IN outputs (bits 0/1) whose tunnel pixel clock source @route cannot be:
* T6030 even sources only, T8132 its dcpexts (2 and 4), others any.
Expand All @@ -254,7 +267,7 @@ static u8 dcp_route_tunnel_clock_blocked(const struct apple_dcp_typec_route *rou
if (dcp_is_t8132_ext(route->dcp))
return (apple_dp_tunnel_t8132_pclk(route->mux_index, 0) < 0 ? BIT(0) : 0) |
(apple_dp_tunnel_t8132_pclk(route->mux_index, 1) < 0 ? BIT(1) : 0);
return dcp_fabric_tunnel_clock_blocked(of_machine_is_compatible("apple,t6030"),
return dcp_fabric_tunnel_clock_blocked(dcp_is_t6030_fabric(route->dcp),
route->mux_index);
}

Expand Down Expand Up @@ -482,7 +495,7 @@ static int dcp_route_clock_rate(struct apple_dcp_typec_route *route,
}

/* A T8132 dcpext names its source (2 or 4), as T6030 does. */
if (of_machine_is_compatible("apple,t6030") || t8132) {
if (dcp_is_t6030_fabric(route->dcp) || t8132) {
typeof(apple_atc_dp_tunnel_rate_source) *fn;

if (t8132 ? apple_dp_tunnel_t8132_pclk(route->mux_index, dpin) < 0 :
Expand Down Expand Up @@ -2631,7 +2644,7 @@ int dcp_direct_crossbar_link(struct apple_dcp *dcp, bool up)
* native26 pipeline, selecting a crossbar output only routes it;
* link-up enables clocks.
*/
if (!of_machine_is_compatible("apple,t6030") &&
if (!dcp_is_t6030_fabric(dcp) &&
!dcp_t6041_ext_v27(dcp) &&
!dcp_is_t8132_ext(dcp) && !dcp_is_ext26(dcp))
return 0;
Expand Down Expand Up @@ -2710,7 +2723,7 @@ int dcp_tunnel_set_rate(struct apple_dcp *dcp, struct phy *phy, u32 unit,
}
return ret;
}
if (of_machine_is_compatible("apple,t6030") &&
if (dcp_is_t6030_fabric(dcp) &&
(unit || dcp->dptx_dfp_port != 1 + route->tunnel_dpin ||
apple_dp_tunnel_t6030_pclk(route->mux_index,
route->tunnel_dpin) < 0))
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/dcp-fabric.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ int dcp_tunnel_dpin_activate(struct apple_dcp *dcp, u32 unit, bool active);

/* An adopted T8132 dcpext. */
bool dcp_is_t8132_ext(const struct apple_dcp *dcp);
bool dcp_is_t6030_fabric(const struct apple_dcp *dcp);

/* DCP probe, resume and endpoint teardown hooks. */
int dcp_register_typec_routes(struct apple_dcp *dcp);
Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ struct apple_dcp_hw_data {
u32 firmware_request;
/* M2 Pro/Max laptop T6020 Thunderbolt flow, from the match data */
bool t6020_tunnel_flow;
/*
* A T6030 display processor (apple,t6030-dcp, apple,t6030-dcpext),
* behind the T6030 display crossbars: selecting an output only routes
* it and linking it up starts its clocks, and only the even external
* sources reach the ATC tunnel pixel clocks, see dcp_is_t6030_fabric().
*/
bool t6030_fabric;
/*
* A processor Linux starts itself on 14.7 firmware through the IOMFB
* template whose AFK, DPTX and DPAV endpoints speak the 14.7 protocol
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10016,6 +10016,7 @@ static const struct apple_dcp_hw_data apple_dcp_hw_dcp = {

static const struct apple_dcp_hw_data apple_dcp_hw_t6030 = {
.num_dptx_ports = 1,
.t6030_fabric = true,
};

static const struct apple_dcp_hw_data apple_dcp_hw_t8122 = {
Expand All @@ -10029,6 +10030,7 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t6031 = {

static const struct apple_dcp_hw_data apple_dcp_hw_t6030_dcpext = {
.num_dptx_ports = 1,
.t6030_fabric = true,
};

static const struct apple_dcp_hw_data apple_dcp_hw_t8122_dcpext = {
Expand Down
124 changes: 93 additions & 31 deletions drivers/phy/apple/atc.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,15 @@ struct apple_atcphy;
* @aciophy_lane_mode: Lane mode register offset
* @aciophy_crossbar: Crossbar register offset
* @has_usb4: A USB4/Thunderbolt controller sits behind the PHY
* @tunnel_t8103_clock: DP tunnels are clocked by the T8103 sequence: one
* AUSPLL pixel clock (PCLK1) feeds both DP IN adapters,
* see atc_tunnel_start_t8103(); the T8103, T8112 and T600x
* PHYs. Without it, and without @t8122_tunnel_clock, each
* DP IN has its own clock (atc_tunnel_set_t602x())
* @tunnel_dprx_clock: With @tunnel_t8103_clock, the tunnel also runs PCLK2 and
* the DP IN (DPRX) clock at the same rate, and the clock
* path is woken before the first rate request
* (apple_atc_dp_tunnel_open()): the T600x PHY
* @usb2_only: Uses the USB2 subset unless its banked SuperSpeed resources exist
* @usb2phy_sig_host: Host role field mask, or zero for the original layout
* @pipe_mux_clk: PIPE clock selection field mask
Expand All @@ -704,13 +713,18 @@ struct apple_atcphy;
* can also drop while the system runs, see atcphy_rpm_get().
* Only for PHYs without DisplayPort, whose phy ops and tunnel
* calls take no runtime PM reference
* @t8122_tunnel_clock: The DP IN outputs are clocked from the PHY's AUSPLL
* tunnel clock, see apple_atc_tunnel_t8122_clock(): the
* T6030 and T8132 PHYs
*/
struct atcphy_hw {
void (*configure_post_tunable)(struct apple_atcphy *, enum atcphy_mode);
enum atcphy_generation gen;
int aciophy_lane_mode;
int aciophy_crossbar;
bool has_usb4;
bool tunnel_t8103_clock;
bool tunnel_dprx_clock;
bool usb2_only;
u32 usb2phy_sig_host;
u32 pipe_mux_clk;
Expand All @@ -725,6 +739,7 @@ struct atcphy_hw {
bool clear_boot_hold;
bool restore_after_pd_off;
bool idle_power_off;
bool t8122_tunnel_clock;
};

enum atcphy_t8132_bank {
Expand Down Expand Up @@ -2897,13 +2912,6 @@ static void atcphy_configure_post_tunable_all_modes(struct apple_atcphy *atcphy,
* without touching the lane mux. Based on Oliver Lukschander's t6020 tunnel
* clock patch (asahi-j416s-display).
*/
/* t600x (M1 Pro/Max) has the t8103 generation ATC. */
static bool apple_atc_tunnel_is_t600x(void)
{
return of_machine_is_compatible("apple,t6000") ||
of_machine_is_compatible("apple,t6001");
}

/*
* Stop the tunnel pixel clock: switch the AUSPLL output drivers off and send
* APB command 3. TX_DP_CTRL0, the sleep overrides and the
Expand Down Expand Up @@ -3135,7 +3143,7 @@ static void atc_tunnel_pclk_t8103(struct apple_atcphy *atcphy, u32 selector)
{
core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N);
core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N_OV);
if (apple_atc_tunnel_is_t600x()) {
if (atcphy->hw->tunnel_dprx_clock) {
core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_ENABLE);
core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK2_ENABLE);
core_mask32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_SELECT,
Expand Down Expand Up @@ -3576,15 +3584,17 @@ static int atc_tunnel_set_t602x(struct apple_atcphy *atcphy, unsigned int dpin,
}

/*
* T6030 (M3 Pro) uses T8122-generation PHYs for both DP IN clock outputs.
* The T8132 (M4) PHY has the same tunnel clock: AUSPLL descriptor, APB
* handshake, lock bit and TX_DP_CTRL0 selects are at the same offsets.
* The T6030 (M3 Pro) PHY (apple,t6030-atcphy, a T8122-generation PHY) clocks
* both DP IN outputs from its own AUSPLL tunnel clock. The T8132 (M4) PHY has
* the same tunnel clock: AUSPLL descriptor, APB handshake, lock bit and
* TX_DP_CTRL0 selects are at the same offsets. The match data of the PHY's
* compatible says which it is. The T8122 and T6031 PHYs share the T6030 one's
* generation but have their own compatibles and keep the T8103/T602X tunnel
* clock sequence.
*/
static bool apple_atc_tunnel_t8122_clock(struct apple_atcphy *atcphy)
{
return (of_machine_is_compatible("apple,t6030") &&
atcphy->hw->gen == ATCPHY_GENERATION_T8122) ||
atcphy->hw->gen == ATCPHY_GENERATION_T8132;
return atcphy->hw->t8122_tunnel_clock;
}

/* Which pixel clock (0: PCLK1, 1: PCLK2) source @source uses for DP IN @dpin. */
Expand Down Expand Up @@ -4203,9 +4213,12 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode)
}
/* Keep failed transitions retryable even when the requested mode is unchanged. */
atcphy->mode_dirty = true;
/* the mode change below may power the PHY down: stop the tunnel clock first */
if (of_machine_is_compatible("apple,t6030") &&
atcphy->hw->gen == ATCPHY_GENERATION_T8122) {
/*
* The mode change below may power the PHY down: stop the tunnel clock
* first, by the sequence that started it. A T8132 PHY never gets here
* (atcphy_configure_t8132()).
*/
if (atcphy->hw->t8122_tunnel_clock) {
ret = atc_t8122_tunnel_stop(atcphy);
if (ret)
return ret;
Expand Down Expand Up @@ -4993,13 +5006,13 @@ static const struct phy_ops apple_atc_dp_phy_ops = {
* Thunderbolt DP IN adapter @dpin (rate is the DP link rate code, 0 = stop).
*/
/*
* t600x (M1 Pro/Max) and t8112 (M2, whose ATC PHY is t8103-compatible) run
* the t8103 tunnel clock sequence unchanged.
* The T8103-generation PHYs of T8103, T8112 (M2) and T600x (M1 Pro/Max/Ultra)
* run the T8103 tunnel clock sequence; the T6020 PHY, of the same generation,
* has a clock per DP IN. The PHY's match data says which (tunnel_t8103_clock).
*/
static bool apple_atc_tunnel_is_t8103_style(void)
static bool apple_atc_tunnel_is_t8103_style(const struct apple_atcphy *atcphy)
{
return of_machine_is_compatible("apple,t8103") ||
of_machine_is_compatible("apple,t8112") || apple_atc_tunnel_is_t600x();
return atcphy->hw->tunnel_t8103_clock;
}

int apple_atc_dp_tunnel_rate_source(struct phy *phy, unsigned int source,
Expand Down Expand Up @@ -5116,7 +5129,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate)
*/
if (apple_atc_tunnel_t8122_clock(atcphy))
return apple_atc_dp_tunnel_rate_source(phy, 0, dpin, rate);
if (!apple_atc_tunnel_is_t8103_style()) {
if (!apple_atc_tunnel_is_t8103_style(atcphy)) {
bool valid_core = apple_atc_t602x_core_valid(atcphy->np, atcphy->res.core->start,
resource_size(atcphy->res.core));

Expand All @@ -5127,7 +5140,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate)
}
guard(mutex)(&atcphy->lock);
if (!rate) {
if (apple_atc_tunnel_is_t8103_style()) {
if (apple_atc_tunnel_is_t8103_style(atcphy)) {
/*
* One pixel clock feeds both DP IN adapters: a stream
* that ends must not stop the other one's clock.
Expand All @@ -5142,7 +5155,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate)
}
if (atcphy->mode != APPLE_ATCPHY_MODE_USB4 && atcphy->mode != APPLE_ATCPHY_MODE_TBT)
return -EBUSY;
if (apple_atc_tunnel_is_t8103_style()) {
if (apple_atc_tunnel_is_t8103_style(atcphy)) {
ret = atc_tunnel_start_t8103(atcphy, rate);
if (!ret)
atcphy->tunnel_users |= BIT(dpin);
Expand All @@ -5164,15 +5177,16 @@ int apple_atc_dp_tunnel_open(struct phy *phy)
if (!phy)
return -EINVAL;
/*
* Everything but t600x has nothing to open, whichever driver provides
* the PHY: T6050's tunnel clocks belong to atc-t6050-dp.c, whose PHY
* this driver does not know, and start from the link rate alone.
* Only a PHY with the DPRX tunnel clock (T600x) has something to open.
* Others, whichever driver provides them, start from the link rate
* alone: T6050's tunnel clocks belong to atc-t6050-dp.c, whose PHY this
* driver does not know.
*/
if (!apple_atc_tunnel_is_t600x())
return -EOPNOTSUPP;
if (phy->ops != &apple_atc_dp_phy_ops)
return -EINVAL;
return -EOPNOTSUPP;
atcphy = phy_get_drvdata(phy);
if (!atcphy->hw->tunnel_dprx_clock)
return -EOPNOTSUPP;
guard(mutex)(&atcphy->lock);
if (atcphy->mode != APPLE_ATCPHY_MODE_USB4 && atcphy->mode != APPLE_ATCPHY_MODE_TBT)
return -EBUSY;
Expand Down Expand Up @@ -7919,7 +7933,35 @@ static const struct dev_pm_ops atcphy_pm_ops = {
NOIRQ_SYSTEM_SLEEP_PM_OPS(atcphy_suspend_noirq, atcphy_resume_noirq)
};

/* T8103, and T8112 through its fallback compatible. */
static const struct atcphy_hw atcphy_hw_t8103 = {
.gen = ATCPHY_GENERATION_T8103,
.aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103,
.aciophy_crossbar = ACIOPHY_CROSSBAR_T8103,
.configure_post_tunable = atcphy_configure_post_tunable_t8103,
.pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103,
.pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103,
.has_usb4 = true,
.tunnel_t8103_clock = true,
.park_pipe_unlocked = true,
};

/* T600x: the T8103 PHY, whose tunnels also run PCLK2 and the DPRX clock. */
static const struct atcphy_hw atcphy_hw_t6000 = {
.gen = ATCPHY_GENERATION_T8103,
.aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103,
.aciophy_crossbar = ACIOPHY_CROSSBAR_T8103,
.configure_post_tunable = atcphy_configure_post_tunable_t8103,
.pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103,
.pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103,
.has_usb4 = true,
.tunnel_t8103_clock = true,
.tunnel_dprx_clock = true,
.park_pipe_unlocked = true,
};

/* T602x: the T8103 PHY, with a tunnel clock per DP IN. */
static const struct atcphy_hw atcphy_hw_t6020 = {
.gen = ATCPHY_GENERATION_T8103,
.aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103,
.aciophy_crossbar = ACIOPHY_CROSSBAR_T8103,
Expand All @@ -7944,6 +7986,22 @@ static const struct atcphy_hw atcphy_hw_t8122 = {
.restore_after_pd_off = true,
};

/* The T6030 PHY: the T8122 PHY, with the DP IN clocks on its tunnel clock. */
static const struct atcphy_hw atcphy_hw_t6030 = {
.gen = ATCPHY_GENERATION_T8122,
.aciophy_lane_mode = ACIOPHY_LANE_MODE_T8122,
.aciophy_crossbar = ACIOPHY_CROSSBAR_T8122,
.configure_post_tunable = atcphy_configure_post_tunable_t8122,
.pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103,
.pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103,
.has_usb4 = true,
.dp_t8122 = true,
.park_pipe_unlocked = true,
.park_dummy_phy = true,
.restore_after_pd_off = true,
.t8122_tunnel_clock = true,
};

static const struct atcphy_hw atcphy_hw_t8132 = {
.gen = ATCPHY_GENERATION_T8132,
.usb2_only = true,
Expand All @@ -7952,6 +8010,7 @@ static const struct atcphy_hw atcphy_hw_t8132 = {
.pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103,
.restore_after_pd_off = true,
.idle_power_off = true,
.t8122_tunnel_clock = true,
};

static const struct atcphy_hw atcphy_hw_t8140 = {
Expand Down Expand Up @@ -7985,6 +8044,9 @@ static const struct atcphy_hw atcphy_hw_t8142 = {

static const struct of_device_id atcphy_match[] = {
{ .compatible = "apple,t8103-atcphy", .data = &atcphy_hw_t8103 },
{ .compatible = "apple,t6000-atcphy", .data = &atcphy_hw_t6000 },
{ .compatible = "apple,t6020-atcphy", .data = &atcphy_hw_t6020 },
{ .compatible = "apple,t6030-atcphy", .data = &atcphy_hw_t6030 },
{ .compatible = "apple,t8122-atcphy", .data = &atcphy_hw_t8122 },
{ .compatible = "apple,t8132-atcphy", .data = &atcphy_hw_t8132 },
{ .compatible = "apple,t8142-atcphy", .data = &atcphy_hw_t8142 },
Expand Down
2 changes: 1 addition & 1 deletion tools/asahi/atc-usb3-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def block(source, marker):
def generation_scope(source, root):
"""Resolve real DT fallback compatibles through the driver's actual match table."""
tables = {}
for name in ("t8103", "t8122", "t8140", "t8142"):
for name in ("t8103", "t6000", "t6020", "t8122", "t6030", "t8140", "t8142"):
text = block(source, "static const struct atcphy_hw atcphy_hw_" + name + " =")
tables["atcphy_hw_" + name] = re.search(r"\.gen\s*=\s*(ATCPHY_GENERATION_\w+)", text).group(1)
matches = dict(re.findall(r'\.compatible\s*=\s*"([^"]+)"\s*,\s*\.data\s*=\s*&([a-zA-Z0-9_]+)', source))
Expand Down
9 changes: 6 additions & 3 deletions tools/asahi/dcpext26-crossbar-union-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def function(text, name):
bool tunnel, selected;
};
struct apple_dcp {
struct { int iomfb_method_profile; } hw;
struct { int iomfb_method_profile; bool t6030_fabric; } hw;
int fw_compat, tb_lock;
struct device *dev;
struct apple_dcp_typec_route *active_typec_route;
Expand All @@ -64,7 +64,7 @@ def function(text, name):
static struct mux_control *last;
static bool last_up;
static int fault;
static bool of_machine_is_compatible(const char *name) { return !strcmp(machine, name); }
/* The gate reads the processor's match data, not the machine. */
static bool of_device_is_compatible(const struct device_node *n, const char *name) {
return !strcmp(n->compatible, name);
}
Expand All @@ -90,6 +90,8 @@ def function(text, name):
node.compatible = profile == 1 ? "apple,t8132-dcpext" : "apple,other-dcp";
struct apple_dcp d = { .dev = &dev, .active_typec_route = &route };
d.hw.iomfb_method_profile = profile == 2 ? DCP_IOMFB_METHODS_J613_EXT26 : 0;
/* A T6030 processor's match data, on the T6030 machine only. */
d.hw.t6030_fabric = !strcmp(machine, "apple,t6030");
reset();
assert(dcp_direct_crossbar_link(&d, true) == 0);
assert(links == 1 && locks == 1 && last == &a && last_up && d.direct_xbar_up == &a);
Expand Down Expand Up @@ -138,7 +140,8 @@ def function(text, name):
'''
unit = pre + function(header, 'dcp_is_ext26') + '\n'
unit += function(source, 'dcp_t6041_ext_v27') + '\n'
unit += function(source, 'dcp_is_t8132_ext') + '\n' + link + '\n' + cases
unit += function(source, 'dcp_is_t8132_ext') + '\n'
unit += function(source, 'dcp_is_t6030_fabric') + '\n' + link + '\n' + cases
with tempfile.TemporaryDirectory() as tmp:
c = Path(tmp) / 'crossbar.c'
binary = Path(tmp) / 'crossbar'
Expand Down
Loading
Loading