xref: /openbsd/sys/dev/pci/drm/apple/dptxep.h (revision 5dd0baa8)
1 #ifndef __APPLE_DCP_DPTXEP_H__
2 #define __APPLE_DCP_DPTXEP_H__
3 
4 #include <linux/phy/phy.h>
5 #include <linux/mux/consumer.h>
6 
7 enum dptx_apcall {
8 	DPTX_APCALL_ACTIVATE = 0,
9 	DPTX_APCALL_DEACTIVATE = 1,
10 	DPTX_APCALL_GET_MAX_DRIVE_SETTINGS = 2,
11 	DPTX_APCALL_SET_DRIVE_SETTINGS = 3,
12 	DPTX_APCALL_GET_DRIVE_SETTINGS = 4,
13 	DPTX_APCALL_WILL_CHANGE_LINKG_CONFIG = 5,
14 	DPTX_APCALL_DID_CHANGE_LINK_CONFIG = 6,
15 	DPTX_APCALL_GET_MAX_LINK_RATE = 7,
16 	DPTX_APCALL_GET_LINK_RATE = 8,
17 	DPTX_APCALL_SET_LINK_RATE = 9,
18 	DPTX_APCALL_GET_MAX_LANE_COUNT = 10,
19 	DPTX_APCALL_GET_ACTIVE_LANE_COUNT = 11,
20 	DPTX_APCALL_SET_ACTIVE_LANE_COUNT = 12,
21 	DPTX_APCALL_GET_SUPPORTS_DOWN_SPREAD = 13,
22 	DPTX_APCALL_GET_DOWN_SPREAD = 14,
23 	DPTX_APCALL_SET_DOWN_SPREAD = 15,
24 	DPTX_APCALL_GET_SUPPORTS_LANE_MAPPING = 16,
25 	DPTX_APCALL_SET_LANE_MAP = 17,
26 	DPTX_APCALL_GET_SUPPORTS_HPD = 18,
27 	DPTX_APCALL_FORCE_HOTPLUG_DETECT = 19,
28 	DPTX_APCALL_INACTIVE_SINK_DETECTED = 20,
29 	DPTX_APCALL_SET_TILED_DISPLAY_HINTS = 21,
30 	DPTX_APCALL_DEVICE_NOT_RESPONDING = 22,
31 	DPTX_APCALL_DEVICE_BUSY_TIMEOUT = 23,
32 	DPTX_APCALL_DEVICE_NOT_STARTED = 24,
33 };
34 
35 #define DCPDPTX_REMOTE_PORT_CORE GENMASK(3, 0)
36 #define DCPDPTX_REMOTE_PORT_ATC GENMASK(7, 4)
37 #define DCPDPTX_REMOTE_PORT_DIE GENMASK(11, 8)
38 #define DCPDPTX_REMOTE_PORT_CONNECTED BIT(15)
39 
40 enum dptx_link_rate {
41 	LINK_RATE_RBR = 0x06,
42 	LINK_RATE_HBR = 0x0a,
43 	LINK_RATE_HBR2 = 0x14,
44 	LINK_RATE_HBR3 = 0x1e,
45 };
46 
47 struct apple_epic_service;
48 
49 struct dptx_port {
50 	bool enabled, connected;
51 	struct completion enable_completion;
52 	struct completion linkcfg_completion;
53 	u32 unit;
54 	struct apple_epic_service *service;
55 	union phy_configure_opts phy_ops;
56 	struct phy *atcphy;
57 	struct mux_control *mux;
58 	u32 lane_count;
59 	u32 link_rate, pending_link_rate;
60 	u32 drive_settings[2];
61 };
62 
63 int dptxport_validate_connection(struct apple_epic_service *service, u8 core,
64 				 u8 atc, u8 die);
65 int dptxport_connect(struct apple_epic_service *service, u8 core, u8 atc,
66 		     u8 die);
67 int dptxport_request_display(struct apple_epic_service *service);
68 int dptxport_release_display(struct apple_epic_service *service);
69 int dptxport_set_hpd(struct apple_epic_service *service, bool hpd);
70 #endif
71