Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ allOf:
properties:
compatible:
contains:
enum: ['apple,t6050-dcp', 'apple,t6050-dcpext']
enum: ['apple,t6050-dcp', 'apple,t6050-dcpext', 'apple,t8122-dcp']
then:
properties:
apple,sleep-power-args: false
Expand All @@ -820,7 +820,7 @@ allOf:
properties:
compatible:
contains:
const: apple,t6050-dcp
enum: ['apple,t6050-dcp', 'apple,t8122-dcp']
then:
properties:
apple,sleep-display-power-args: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ properties:
- apple,t6030-display-power
- apple,t6030-dispext-power
- apple,t8103-display-power
- apple,t8122-display-power
- apple,t6041-display-power
- apple,t8132-display-power
- apple,t8140-display-power
Expand Down Expand Up @@ -130,7 +131,9 @@ allOf:
properties:
compatible:
contains:
const: apple,t6030-display-power
enum:
- apple,t6030-display-power
- apple,t8122-display-power
then:
properties:
reg:
Expand Down
13 changes: 13 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-dcp.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
apple,bw-scratch = <&pmgr_dcp 0 5 0x908>;
/* The 14.x firmware runs once the PMP acknowledges this request. */
apple,pmp-report = <&pmp_report_disp>;
apple,display-power = <&dcp_power>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
Expand All @@ -118,6 +119,17 @@
#apple,bw-scratch-cells = <3>;
};

/*
* Display power gates and PMGR power states for DCP and DCPext sleep
* (DISP_CPU/FE/SYS and DISPEXT_CPU/FE/SYS).
*/
dcp_power: display-power@2d0724000 {
compatible = "apple,t8122-display-power";
reg = <0x2 0xd0724000 0x0 0x1000>,
<0x2 0xd0700000 0x0 0x14000>;
reg-names = "pwrgate", "ps";
};

/*
* External display processor: the boot loader only reserves its
* firmware, the driver starts it. DMA windows as on T8112.
Expand Down Expand Up @@ -181,6 +193,7 @@
clocks = <&clk_dispext0>;
/* Its first mode set completes only with this PMP request. */
apple,pmp-report = <&pmp_report_dispext>;
apple,display-power = <&dcp_power>;
apple,dcp-index = <1>;
status = "disabled";

Expand Down
14 changes: 14 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-j613-j615.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,20 @@
status = "okay";
};

&dcp {
/*
* Firmware 27.2's display sleep calls on J613/J615, matching the 27.2.0
* internal DCP ABI (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>;
};

&sleep {
apple,debug-port = <&hpm0>;
status = "okay";
Expand Down
39 changes: 39 additions & 0 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9119,6 +9119,12 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
return ret;
dcp->hw = *(struct apple_dcp_hw_data *)of_device_get_match_data(dev);
dcp_apply_dt_profile(dcp);
/*
* v27_early_stop's layout has no DART streams: firmware 26.6's sleep takes
* them from its own (dcp_v26_find_darts()).
*/
if (dcp->hw.v27_early_stop && fw_compat != DCP_FIRMWARE_V_27_0)
dcp->hw.s2r_layout = NULL;
/* The link report: on the board it has run on (dcp_j714s_ext()). */
if (!dcp_j714s_ext(dev))
dcp->hw.link_report = false;
Expand All @@ -9144,6 +9150,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
dcp->hw.num_dptx_ports = 2;
dcp->hw.fw_14_7_endpoints = false;
dcp->hw.adopt_live_session = false;
/* Its stop and start are this firmware's, not 14.7's or 26.6's. */
dcp->hw.s2r_ext = true;
}
if (fw_compat == DCP_FIRMWARE_V_27_0 &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcpext")) {
Expand Down Expand Up @@ -10347,6 +10355,29 @@ static const struct dcp_s2r_layout dcp_s2r_t6030 = {
.pmc_dcp = false,
};

/*
* T8122's internal and external display power words from the ADT/PMGR
* (DISP_CPU/FE/SYS with its flip-flop and SRAM retention words, and
* DISPEXT_CPU/FE/SYS with its DART streams). No pmc-dcp word.
*/
static const struct dcp_s2r_layout dcp_s2r_t8122 = {
.disp_cpu = 0x10000,
.disp_fe = 0x208,
.disp_sys = 0x1d8,
.ret_ff = 0xcac,
.ret_mem = 0xcd0,
.pmc_dcp = false,
};

static const struct dcp_s2r_layout dcp_s2r_t8122_ext = {
.disp_cpu = 0x488,
.disp_fe = 0x480,
.disp_sys = 0x410,
.dcp_streams = BIT(5),
.disp_streams = BIT(0) | BIT(4),
.pmc_dcp = false,
};

/* TEST: J813 external processors, ADT DISPEXT0/1 power words. */
static const struct dcp_s2r_layout dcp_s2r_t8142_ext[] = {
{ .disp_cpu = 0x428, .disp_fe = 0x418, .disp_sys = 0x308,
Expand Down Expand Up @@ -12998,6 +13029,10 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t6030 = {
static const struct apple_dcp_hw_data apple_dcp_hw_t8122 = {
.iboot_handoff = "apple,t8122-handoff",
.num_dptx_ports = 2,
.afk_name_fallback = true,
/* Firmware 27.2's sleep: only with the DT's sleep arguments and display power words */
.v27_early_stop = true,
.s2r_layout = &dcp_s2r_t8122,
};

/* The internal panel only, through the 14.x IOMFB, as on T6030. */
Expand All @@ -13015,6 +13050,10 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t8122_dcpext = {
.external_processor = true,
.num_dptx_ports = 2,
.fw_14_7_endpoints = true,
/* For firmware 27's s2r_ext, see dcp_platform_probe_pipe(). */
.s2r_no_secure_port = true,
.s2r_disp_dart_with_dcp = true,
.s2r_layout = &dcp_s2r_t8122_ext,
};

static const struct apple_dcp_hw_data apple_dcp_hw_dcpext = {
Expand Down
11 changes: 6 additions & 5 deletions drivers/iommu/apple-dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -9327,14 +9327,14 @@ static int apple_dart_t8112_display_streams(struct apple_dart *dart, u32 streams

if (READ_ONCE(dart->host_off))
return 0;
if (!READ_ONCE(dart->display_dark)) {
ret = apple_dart_display_dark_enter(dart);
if (ret)
return ret;
if (!dart->display_saved) {
apple_dart_save_state(dart);
dart->display_enable = readl(dart->regs + DART_T8110_ENABLE_STREAMS);
dart->display_saved = true;
}
ret = apple_dart_display_dark_enter(dart);
if (ret)
return ret;
for_each_set_bit(sid, &bits, dart->num_streams)
writel(BIT(sid), dart->regs + DART_T8110_DISABLE_STREAMS);
if (flush) {
Expand Down Expand Up @@ -9362,7 +9362,8 @@ int apple_dart_display_streams(struct device *dev, u32 streams, bool on, bool fl

if (dart->hw->type == DART_T8020)
return apple_dart_t8020_display_streams(dart, streams, on, flush);
if (of_device_is_compatible(dev->of_node, "apple,t8112-dart"))
if (of_device_is_compatible(dev->of_node, "apple,t8112-dart") ||
of_device_is_compatible(dev->of_node, "apple,t8122-dart"))
return apple_dart_t8112_display_streams(dart, streams, on, flush);

if (on) {
Expand Down
76 changes: 44 additions & 32 deletions drivers/pmdomain/apple/pmp-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ struct apple_pmp_report {
* to the sleep's commit, so a sleep doesn't wait for their acknowledgment to go.
*/
u64 always_on;
/* Bits the PMP never acknowledges (apple,no-ack): wake does not poll them. */
u64 no_ack;
/*
* Requests are held in memory until the PMP runs (@defer_requests), and
* while it's stopped for a system sleep.
Expand Down Expand Up @@ -653,7 +655,7 @@ void apple_pmp_report_wake(struct device *pmp, bool lost_power)
if (rep->dvfs_shadow[i])
writeq(rep->dvfs_shadow[i],
rep->base + offs->update + 8 * (offs->dvfs_first + i));
want = rep->shadow;
want = rep->shadow & ~rep->no_ack;
WRITE_ONCE(rep->defer, false);
spin_unlock_irqrestore(&rep->lock, flags);

Expand Down Expand Up @@ -986,7 +988,7 @@ static const struct {
* holds that ID. Only a report that starts its PMP has that table.
*/
static int apple_pmp_report_record(struct device_node *pmp,
struct device_node *entry, u32 *bit, bool *record)
const struct device_node *entry, u32 *bit, bool *record)
{
const u8 *table;
int len = 0, index;
Expand Down Expand Up @@ -3270,6 +3272,32 @@ static int apple_pmp_report_entry_set_state(struct generic_pm_domain *genpd, boo
return ret;
}

static struct apple_pmp_report *apple_pmp_report_of_entry(const struct device_node *entry,
u32 *id)
{
struct device_node *report, *pmp;
struct apple_pmp_report *rep, *found = NULL;
bool record;

report = of_get_parent(entry);
if (!report)
return NULL;
list_for_each_entry_rcu(rep, &apple_pmp_reports, list) {
if (rep->dev->of_node == report) {
found = rep;
break;
}
}
of_node_put(report);
if (!found)
return NULL;
pmp = found->native_pmp ?: (found->start ? found->start->pmp : NULL);
if (apple_pmp_report_record(pmp, entry, id, &record) || *id >= 64)
return NULL;

return found;
}

/**
* apple_pmp_report_entry_request() - set or withdraw one entry's request
* @entry: the report entry's node
Expand All @@ -3285,51 +3313,25 @@ static int apple_pmp_report_entry_set_state(struct generic_pm_domain *genpd, boo
*/
int apple_pmp_report_entry_request(const struct device_node *entry, bool enable)
{
struct device_node *report;
struct apple_pmp_report *rep;
u32 id;
int ret = 0;

if (of_property_read_u32(entry, "reg", &id))
return -EINVAL;

report = of_get_parent(entry);
rcu_read_lock();
list_for_each_entry_rcu(rep, &apple_pmp_reports, list) {
if (rep->dev->of_node != report)
continue;
rep = apple_pmp_report_of_entry(entry, &id);
if (rep)
ret = apple_pmp_report_set_state(rep, id, enable, false);
break;
}
rcu_read_unlock();
of_node_put(report);

return ret;
}
EXPORT_SYMBOL_GPL(apple_pmp_report_entry_request);

static struct apple_pmp_report *apple_pmp_report_of_entry(const struct device_node *entry,
u32 *id)
{
struct device_node *report;
struct apple_pmp_report *rep, *found = NULL;

if (of_property_read_u32(entry, "reg", id) || *id >= 64)
return NULL;
report = of_get_parent(entry);
list_for_each_entry_rcu(rep, &apple_pmp_reports, list) {
if (rep->dev->of_node == report) {
found = rep;
break;
}
}
of_node_put(report);

return found;
}

/*
* After a T6030 wake vote, require live READY, target and acknowledge
* After a T6030 or T8122 wake vote, require live READY, target and acknowledge
* before starting its firmware. The cold-start supplier wait needs only
* READY and acknowledge.
*/
Expand All @@ -3344,7 +3346,9 @@ int apple_pmp_report_check_t6030_ack(const struct device_node *entry)
return -EIO;
rcu_read_lock();
rep = apple_pmp_report_of_entry(entry, &id);
if (rep && id < 64 && rep->offsets == &apple_pmp_offsets_t6030) {
if (rep && id < 64 &&
(rep->offsets == &apple_pmp_offsets_t6030 ||
rep->offsets == &apple_pmp_offsets_t8122)) {
u64 bit = BIT_ULL(id);

offs = rep->offsets;
Expand Down Expand Up @@ -3678,6 +3682,14 @@ static int apple_pmp_report_entry_probe(struct platform_device *pdev)
goto err_free;
}

if (ent->no_ack && rep) {
unsigned long flags;

spin_lock_irqsave(&rep->lock, flags);
rep->no_ack |= BIT_ULL(ent->id);
spin_unlock_irqrestore(&rep->lock, flags);
}

if (of_property_read_bool(node, "apple,always-on")) {
ent->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP;
if (rep) {
Expand Down
1 change: 0 additions & 1 deletion drivers/soc/apple/sleep-t8122.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,6 @@ static const struct apple_sleep_soc t8122_sleep_soc = {
.no_pmu_notes = true,
.display_no_restart = true,
.early_context = true,
.coproc_slp_ddr = true,
.stray = t8122_stray,
.nstray = ARRAY_SIZE(t8122_stray),
.wake_mask = 0x08,
Expand Down
Loading
Loading