1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef _DP_CATALOG_H_
7 #define _DP_CATALOG_H_
8 
9 #include <drm/drm_modes.h>
10 
11 #include "dp_utils.h"
12 #include "disp/msm_disp_snapshot.h"
13 
14 /* interrupts */
15 #define DP_INTR_HPD		BIT(0)
16 #define DP_INTR_AUX_XFER_DONE	BIT(3)
17 #define DP_INTR_WRONG_ADDR	BIT(6)
18 #define DP_INTR_TIMEOUT		BIT(9)
19 #define DP_INTR_NACK_DEFER	BIT(12)
20 #define DP_INTR_WRONG_DATA_CNT	BIT(15)
21 #define DP_INTR_I2C_NACK	BIT(18)
22 #define DP_INTR_I2C_DEFER	BIT(21)
23 #define DP_INTR_PLL_UNLOCKED	BIT(24)
24 #define DP_INTR_AUX_ERROR	BIT(27)
25 
26 #define DP_INTR_READY_FOR_VIDEO		BIT(0)
27 #define DP_INTR_IDLE_PATTERN_SENT	BIT(3)
28 #define DP_INTR_FRAME_END		BIT(6)
29 #define DP_INTR_CRC_UPDATED		BIT(9)
30 
31 #define DP_HW_VERSION_1_0	0x10000000
32 #define DP_HW_VERSION_1_2	0x10020000
33 
34 enum dp_catalog_audio_sdp_type {
35 	DP_AUDIO_SDP_STREAM,
36 	DP_AUDIO_SDP_TIMESTAMP,
37 	DP_AUDIO_SDP_INFOFRAME,
38 	DP_AUDIO_SDP_COPYMANAGEMENT,
39 	DP_AUDIO_SDP_ISRC,
40 	DP_AUDIO_SDP_MAX,
41 };
42 
43 enum dp_catalog_audio_header_type {
44 	DP_AUDIO_SDP_HEADER_1,
45 	DP_AUDIO_SDP_HEADER_2,
46 	DP_AUDIO_SDP_HEADER_3,
47 	DP_AUDIO_SDP_HEADER_MAX,
48 };
49 
50 struct dp_catalog {
51 	bool wide_bus_en;
52 };
53 
54 /* Debug module */
55 void dp_catalog_snapshot(struct dp_catalog *dp_catalog, struct msm_disp_state *disp_state);
56 
57 /* AUX APIs */
58 u32 dp_catalog_aux_read_data(struct dp_catalog *dp_catalog);
59 int dp_catalog_aux_write_data(struct dp_catalog *dp_catalog, u32 data);
60 int dp_catalog_aux_write_trans(struct dp_catalog *dp_catalog, u32 data);
61 int dp_catalog_aux_clear_trans(struct dp_catalog *dp_catalog, bool read);
62 int dp_catalog_aux_clear_hw_interrupts(struct dp_catalog *dp_catalog);
63 void dp_catalog_aux_reset(struct dp_catalog *dp_catalog);
64 void dp_catalog_aux_enable(struct dp_catalog *dp_catalog, bool enable);
65 int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog,
66 					      unsigned long wait_us);
67 u32 dp_catalog_aux_get_irq(struct dp_catalog *dp_catalog);
68 
69 /* DP Controller APIs */
70 void dp_catalog_ctrl_state_ctrl(struct dp_catalog *dp_catalog, u32 state);
71 void dp_catalog_ctrl_config_ctrl(struct dp_catalog *dp_catalog, u32 config);
72 void dp_catalog_ctrl_lane_mapping(struct dp_catalog *dp_catalog);
73 void dp_catalog_ctrl_mainlink_ctrl(struct dp_catalog *dp_catalog, bool enable);
74 void dp_catalog_ctrl_psr_mainlink_enable(struct dp_catalog *dp_catalog, bool enable);
75 void dp_catalog_setup_peripheral_flush(struct dp_catalog *dp_catalog);
76 void dp_catalog_ctrl_config_misc(struct dp_catalog *dp_catalog, u32 cc, u32 tb);
77 void dp_catalog_ctrl_config_msa(struct dp_catalog *dp_catalog, u32 rate,
78 				u32 stream_rate_khz, bool is_ycbcr_420);
79 int dp_catalog_ctrl_set_pattern_state_bit(struct dp_catalog *dp_catalog, u32 pattern);
80 u32 dp_catalog_hw_revision(const struct dp_catalog *dp_catalog);
81 void dp_catalog_ctrl_reset(struct dp_catalog *dp_catalog);
82 bool dp_catalog_ctrl_mainlink_ready(struct dp_catalog *dp_catalog);
83 void dp_catalog_ctrl_enable_irq(struct dp_catalog *dp_catalog, bool enable);
84 void dp_catalog_hpd_config_intr(struct dp_catalog *dp_catalog,
85 			u32 intr_mask, bool en);
86 void dp_catalog_ctrl_hpd_enable(struct dp_catalog *dp_catalog);
87 void dp_catalog_ctrl_hpd_disable(struct dp_catalog *dp_catalog);
88 void dp_catalog_ctrl_config_psr(struct dp_catalog *dp_catalog);
89 void dp_catalog_ctrl_set_psr(struct dp_catalog *dp_catalog, bool enter);
90 u32 dp_catalog_link_is_connected(struct dp_catalog *dp_catalog);
91 u32 dp_catalog_hpd_get_intr_status(struct dp_catalog *dp_catalog);
92 void dp_catalog_ctrl_phy_reset(struct dp_catalog *dp_catalog);
93 int dp_catalog_ctrl_get_interrupt(struct dp_catalog *dp_catalog);
94 u32 dp_catalog_ctrl_read_psr_interrupt_status(struct dp_catalog *dp_catalog);
95 void dp_catalog_ctrl_update_transfer_unit(struct dp_catalog *dp_catalog,
96 				u32 dp_tu, u32 valid_boundary,
97 				u32 valid_boundary2);
98 void dp_catalog_ctrl_send_phy_pattern(struct dp_catalog *dp_catalog,
99 				u32 pattern);
100 u32 dp_catalog_ctrl_read_phy_pattern(struct dp_catalog *dp_catalog);
101 
102 /* DP Panel APIs */
103 int dp_catalog_panel_timing_cfg(struct dp_catalog *dp_catalog, u32 total,
104 				u32 sync_start, u32 width_blanking, u32 dp_active);
105 void dp_catalog_panel_enable_vsc_sdp(struct dp_catalog *dp_catalog, struct dp_sdp *vsc_sdp);
106 void dp_catalog_panel_disable_vsc_sdp(struct dp_catalog *dp_catalog);
107 void dp_catalog_dump_regs(struct dp_catalog *dp_catalog);
108 void dp_catalog_panel_tpg_enable(struct dp_catalog *dp_catalog,
109 				struct drm_display_mode *drm_mode);
110 void dp_catalog_panel_tpg_disable(struct dp_catalog *dp_catalog);
111 
112 struct dp_catalog *dp_catalog_get(struct device *dev);
113 
114 /* DP Audio APIs */
115 u32 dp_catalog_audio_get_header(struct dp_catalog *dp_catalog,
116 				enum dp_catalog_audio_sdp_type sdp,
117 				enum dp_catalog_audio_header_type header);
118 void dp_catalog_audio_set_header(struct dp_catalog *dp_catalog,
119 				 enum dp_catalog_audio_sdp_type sdp,
120 				 enum dp_catalog_audio_header_type header,
121 				 u32 data);
122 void dp_catalog_audio_config_acr(struct dp_catalog *catalog, u32 select);
123 void dp_catalog_audio_enable(struct dp_catalog *catalog, bool enable);
124 void dp_catalog_audio_config_sdp(struct dp_catalog *catalog);
125 void dp_catalog_audio_init(struct dp_catalog *catalog);
126 void dp_catalog_audio_sfe_level(struct dp_catalog *catalog, u32 safe_to_exit_level);
127 
128 #endif /* _DP_CATALOG_H_ */
129