Skip to content
Draft
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
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t600x-die0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
<0x3 0x8b344000 0x0 0x4000>,
<0x3 0x8b800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x988>;
apple,iomfb-surfaces = <1 1 0 0>;
#ifdef APPLE_USE_PMP
power-domains = <&pmp_report_disp0>;
#else
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t600x-dieX.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<0x2 0x89344000 0x0 0x4000>,
<0x2 0x89800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x990>;
apple,iomfb-surfaces = <1 1 0 0>;
#ifdef APPLE_USE_PMP
power-domains = <&DIE_NODE(pmp_report_dispext0)>;
#else
Expand Down Expand Up @@ -184,6 +185,7 @@
<0x2 0x8c344000 0x0 0x4000>,
<0x2 0x8c800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x998>;
apple,iomfb-surfaces = <1 1 0 0>;
#ifdef APPLE_USE_PMP
power-domains = <&DIE_NODE(pmp_report_dispext1)>;
#else
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t602x-die0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@
<0x3 0x89344000 0x0 0x4000>,
<0x3 0x89800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x1208>;
apple,iomfb-surfaces = <1 1 0 1>;
#ifdef APPLE_USE_PMP
power-domains = <&pmp_report_disp0>;
#else
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t602x-dieX.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<0x2 0x89344000 0x0 0x4000>,
<0x2 0x89800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x1210>;
apple,iomfb-surfaces = <1 1 0 1>;
#ifdef APPLE_USE_PMP
power-domains = <&DIE_NODE(pmp_report_dispext0)>;
#else
Expand Down Expand Up @@ -254,6 +255,7 @@
<0x3 0x15344000 0x0 0x4000>,
<0x3 0x15800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x1218>;
apple,iomfb-surfaces = <1 1 0 1>;
#ifdef APPLE_USE_PMP
power-domains = <&DIE_NODE(pmp_report_dispext1)>;
#else
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t8103.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@
<0x2 0x3b3d0000 0x0 0x4000>;
apple,bw-scratch = <&pmgr_dcp 0 5 0x14>;
apple,bw-doorbell = <&pmgr_dcp 1 6>;
apple,iomfb-surfaces = <1 1 0 0>;
power-domains = <&ps_disp0_cpu0>;
resets = <&ps_disp0_cpu0>;
clocks = <&clk_disp0>;
Expand Down Expand Up @@ -1485,6 +1486,7 @@
<0x2 0x3b3d0000 0x0 0x4000>;
apple,bw-scratch = <&pmgr_dcp 0 5 0x18>;
apple,bw-doorbell = <&pmgr_dcp 1 6>;
apple,iomfb-surfaces = <1 1 0 0>;
power-domains = <&ps_dispext_cpu0>;
resets = <&ps_dispext_cpu0>;
clocks = <&clk_dispext0>;
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/apple/t8112.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@
<0x2 0x31344000 0x0 0x4000>,
<0x2 0x31800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x5d8>;
apple,iomfb-surfaces = <1 1 0 1>;
#ifdef APPLE_USE_PMP
power-domains = <&pmp_report_disp0>;
#else
Expand Down Expand Up @@ -1745,6 +1746,7 @@
<0x2 0x71344000 0x0 0x4000>,
<0x2 0x71800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 4 0x5e0>;
apple,iomfb-surfaces = <1 1 0 1>;
#ifdef APPLE_USE_PMP
power-domains = <&pmp_report_dispext>;
#else
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/apple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ appledrm-$(CONFIG_DRM_APPLE_AUDIO) += audio.o
appledrm-$(CONFIG_DRM_APPLE_AUDIO) += av.o
appledrm-y += connector.o
appledrm-y += ibootep.o
appledrm-y += iomfb_v12_3.o
appledrm-y += iomfb_v13_3.o
appledrm-y += iomfb_v14_8_3.o
appledrm-y += epic/dpavservep.o
appledrm-y += plane.o

Expand Down
44 changes: 19 additions & 25 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,31 +272,25 @@ static int apple_probe_per_dcp(struct device *dev,
struct apple_crtc *crtc;
struct apple_connector *connector;
struct apple_encoder *enc;
struct drm_plane *planes[DCP_MAX_PLANES];
struct apple_plane *planes[DCP_MAX_PLANES];
struct apple_dcp *drv = platform_get_drvdata(dcp);
int ret, i;
int immutable_zpos = 0;
bool supports_l10r = !dcp_fw_compat_is_12_x(dcp);

planes[0] = apple_plane_init(drm, 1U << num, supports_l10r,
DRM_PLANE_TYPE_PRIMARY);
if (IS_ERR(planes[0]))
return PTR_ERR(planes[0]);
ret = drm_plane_create_zpos_immutable_property(planes[0], immutable_zpos);
if (ret) {
return ret;
}


/* Set up our other planes */
for (i = 1; i < DCP_MAX_PLANES; i++) {
planes[i] = apple_plane_init(drm, 1U << num, supports_l10r,
DRM_PLANE_TYPE_OVERLAY);
if (IS_ERR(planes[i]))
return PTR_ERR(planes[i]);
immutable_zpos++;
ret = drm_plane_create_zpos_immutable_property(planes[i], immutable_zpos);
if (ret) {
return ret;
int zpos = 0;
bool supports_l10r = true;

for (i = 0; i < DCP_MAX_PLANES; i++) {
if (drv->iomfb_surfaces[i]) {
planes[zpos] = apple_plane_init(drm, 1U << num, supports_l10r,
zpos ? DRM_PLANE_TYPE_OVERLAY : DRM_PLANE_TYPE_PRIMARY);
if (IS_ERR(planes[zpos]))
return PTR_ERR(planes[zpos]);

ret = drm_plane_create_zpos_immutable_property(&planes[zpos]->base, zpos);
if (ret)
return ret;

planes[zpos]->iomfb_surf = i;
zpos++;
}
}

Expand All @@ -307,7 +301,7 @@ static int apple_probe_per_dcp(struct device *dev,
* knows what to do with overlays.
*/
crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
ret = drm_crtc_init_with_planes(drm, &crtc->base, planes[0], NULL,
ret = drm_crtc_init_with_planes(drm, &crtc->base, &planes[0]->base, NULL,
&apple_crtc_funcs, NULL);
if (ret)
return ret;
Expand Down
15 changes: 1 addition & 14 deletions drivers/gpu/drm/apple/av.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ struct dcp_av_audio_cmds {
u32 get_product_attrs;
};

static const struct dcp_av_audio_cmds dcp_av_audio_cmds_v12_3 = {
.open = 6,
.close = 7,
.prepare = 8,
.start_link = 9,
.stop_link = 12,
.unprepare = 13,
.get_elements = 18,
.get_product_attrs = 20,
};

static const struct dcp_av_audio_cmds dcp_av_audio_cmds_v13_5 = {
.open = 4,
.close = 5,
Expand Down Expand Up @@ -389,10 +378,8 @@ int avep_init(struct apple_dcp *dcp)
mutex_init(&audiosrv_data->plug_lock);

switch (dcp->fw_compat) {
case DCP_FIRMWARE_V_12_3:
audiosrv_data->cmds = dcp_av_audio_cmds_v12_3;
break;
case DCP_FIRMWARE_V_13_5:
case DCP_FIRMWARE_V_14_7:
audiosrv_data->cmds = dcp_av_audio_cmds_v13_5;
break;
default:
Expand Down
15 changes: 6 additions & 9 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@

#include "dptxep.h"
#include "iomfb.h"
#include "iomfb_v12_3.h"
#include "iomfb_v13_3.h"
#include "iomfb_v14_8_3.h"
#include "epic/dpavservep.h"
#include "version_utils.h"

#define DCP_MAX_PLANES 2
#define DCP_MAX_PLANES 4

struct apple_dcp;
struct apple_dcp_afkep;

struct dcpav_service_epic;

enum dcp_firmware_version {
DCP_FIRMWARE_UNKNOWN,
DCP_FIRMWARE_V_12_3,
DCP_FIRMWARE_V_13_5,
};

enum {
SYSTEM_ENDPOINT = 0x20,
TEST_ENDPOINT = 0x21,
Expand Down Expand Up @@ -138,6 +133,8 @@ struct apple_dcp {
* sense to keep some of the members in apple_dcp. *
**********************************************************************/

u32 iomfb_surfaces[DCP_MAX_PLANES];

/* clock rate request by dcp in */
struct clk *clk;

Expand Down Expand Up @@ -174,8 +171,8 @@ struct apple_dcp {

/* Queued swap. Owned by the DCP to avoid per-swap memory allocation */
union {
struct dcp_swap_submit_req_v12_3 v12_3;
struct dcp_swap_submit_req_v13_3 v13_3;
struct dcp_swap_submit_req_v14_7_0 v14_7_0;
} swap;

/* swap id of the last completed swap */
Expand Down
52 changes: 17 additions & 35 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,7 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
{
struct platform_device *pdev = to_apple_crtc(crtc)->dcp;
struct apple_dcp *dcp = platform_get_drvdata(pdev);
struct drm_plane_state *new_state;
struct drm_plane *plane;
struct drm_crtc_state *crtc_state;
int plane_idx, plane_count = 0;
bool needs_modeset;

if (dcp->crashed)
Expand All @@ -348,19 +345,6 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
return -EINVAL;
}

for_each_new_plane_in_state(state, plane, new_state, plane_idx) {
/* skip planes not for this crtc */
if (new_state->crtc != crtc)
continue;

plane_count += 1;
}

if (plane_count > DCP_MAX_PLANES) {
dev_err(dcp->dev, "crtc_atomic_check: Blend supports only 2 layers!\n");
return -EINVAL;
}

return 0;
}

Expand Down Expand Up @@ -501,14 +485,6 @@ void dcp_link(struct platform_device *pdev, struct apple_crtc *crtc,
dcp->connector = connector;
}


bool dcp_fw_compat_is_12_x(struct platform_device *pdev)
{
struct apple_dcp *dcp = platform_get_drvdata(pdev);

return dcp->fw_compat == DCP_FIRMWARE_V_12_3;
}

int dcp_start(struct platform_device *pdev)
{
struct apple_dcp *dcp = platform_get_drvdata(pdev);
Expand Down Expand Up @@ -584,12 +560,12 @@ int dcp_start(struct platform_device *pdev)
static void _dcp_poweroff(struct apple_dcp *dcp)
{
switch (dcp->fw_compat) {
case DCP_FIRMWARE_V_12_3:
iomfb_poweroff_v12_3(dcp);
break;
case DCP_FIRMWARE_V_13_5:
iomfb_poweroff_v13_3(dcp);
break;
case DCP_FIRMWARE_V_14_7:
iomfb_poweroff_v14_7_0(dcp);
break;
default:
WARN_ONCE(true, "Unexpected firmware version: %u\n", dcp->fw_compat);
break;
Expand Down Expand Up @@ -643,12 +619,12 @@ int dcp_wait_ready(struct platform_device *pdev, u64 timeout)
static void __maybe_unused dcp_sleep(struct apple_dcp *dcp)
{
switch (dcp->fw_compat) {
case DCP_FIRMWARE_V_12_3:
iomfb_sleep_v12_3(dcp);
break;
case DCP_FIRMWARE_V_13_5:
iomfb_sleep_v13_3(dcp);
break;
case DCP_FIRMWARE_V_14_7:
iomfb_sleep_v14_7_0(dcp);
break;
default:
WARN_ONCE(true, "Unexpected firmware version: %u\n", dcp->fw_compat);
break;
Expand All @@ -668,12 +644,12 @@ void dcp_poweron(struct platform_device *pdev)
}

switch (dcp->fw_compat) {
case DCP_FIRMWARE_V_12_3:
iomfb_poweron_v12_3(dcp);
break;
case DCP_FIRMWARE_V_13_5:
iomfb_poweron_v13_3(dcp);
break;
case DCP_FIRMWARE_V_14_7:
iomfb_poweron_v14_7_0(dcp);
break;
default:
WARN_ONCE(true, "Unexpected firmware version: %u\n", dcp->fw_compat);
break;
Expand Down Expand Up @@ -959,8 +935,6 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)
return DCP_FIRMWARE_UNKNOWN;
}

if (strncmp(compat_str, "12.3.0", sizeof(compat_str)) == 0)
return DCP_FIRMWARE_V_12_3;
/*
* m1n1 reports firmware version 13.5 as compatible with 13.3. This is
* only true for the iomfb endpoint. The interface for the dptx-port
Expand All @@ -973,6 +947,9 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)
return DCP_FIRMWARE_V_13_5;
else if (strncmp(compat_str, "13.5.0", sizeof(compat_str)) == 0)
return DCP_FIRMWARE_V_13_5;
else if (strncmp(compat_str, "14.7.0", sizeof(compat_str)) == 0 &&
(strncmp(fw_str, "14.7.0", sizeof(compat_str)) == 0))
return DCP_FIRMWARE_V_14_7;

dev_err(dev, "DCP firmware-compat %s (FW: %s) is not supported\n",
compat_str, fw_str);
Expand Down Expand Up @@ -1194,6 +1171,11 @@ static int dcp_platform_probe(struct platform_device *pdev)
dev_err(dev, "Failed to get dp-phy: %ld\n", PTR_ERR(dcp->phy));
return PTR_ERR(dcp->phy);
}

if (of_property_read_u32_array(dev->of_node, "apple,iomfb-surfaces",
(u32 *)&dcp->iomfb_surfaces, DCP_MAX_PLANES))
dcp->iomfb_surfaces[0] = 1;

if (dcp->phy) {
int ret;
/*
Expand Down
Loading