Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 */
5
6#ifndef __DSI_CONNECTOR_H__
7#define __DSI_CONNECTOR_H__
8
9#include <linux/of_platform.h>
10#include <linux/platform_device.h>
11
12#include <drm/drm_bridge.h>
13#include <drm/drm_crtc.h>
14#include <drm/drm_mipi_dsi.h>
15
16#include "msm_drv.h"
17#include "disp/msm_disp_snapshot.h"
18
19#define DSI_0 0
20#define DSI_1 1
21#define DSI_MAX 2
22
23struct msm_dsi_phy_shared_timings;
24struct msm_dsi_phy_clk_request;
25
26enum msm_dsi_phy_usecase {
27 MSM_DSI_PHY_STANDALONE,
28 MSM_DSI_PHY_MASTER,
29 MSM_DSI_PHY_SLAVE,
30};
31
32#define DSI_BUS_CLK_MAX 4
33
34struct msm_dsi {
35 struct drm_device *dev;
36 struct platform_device *pdev;
37
38 struct mipi_dsi_host *host;
39 struct msm_dsi_phy *phy;
40 const char *te_source;
41
42 struct drm_bridge *next_bridge;
43
44 struct device *phy_dev;
45 bool phy_enabled;
46
47 int id;
48};
49
50/* dsi manager */
51int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
52 struct drm_encoder *encoder);
53int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
54bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
55int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
56void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
57void msm_dsi_manager_tpg_enable(void);
58
59/* dsi host */
60struct msm_dsi_host;
61int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
62 const struct mipi_dsi_msg *msg);
63void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
64 const struct mipi_dsi_msg *msg);
65int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
66 const struct mipi_dsi_msg *msg);
67int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
68 const struct mipi_dsi_msg *msg);
69void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
70 u32 dma_base, u32 len);
71int msm_dsi_host_enable(struct mipi_dsi_host *host);
72int msm_dsi_host_disable(struct mipi_dsi_host *host);
73void msm_dsi_host_enable_irq(struct mipi_dsi_host *host);
74void msm_dsi_host_disable_irq(struct mipi_dsi_host *host);
75int msm_dsi_host_power_on(struct mipi_dsi_host *host,
76 struct msm_dsi_phy_shared_timings *phy_shared_timings,
77 bool is_bonded_dsi, struct msm_dsi_phy *phy);
78int msm_dsi_host_power_off(struct mipi_dsi_host *host);
79int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
80 const struct drm_display_mode *mode);
81enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
82 const struct drm_display_mode *mode);
83unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
84int msm_dsi_host_register(struct mipi_dsi_host *host);
85void msm_dsi_host_unregister(struct mipi_dsi_host *host);
86void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
87 struct msm_dsi_phy *src_phy);
88int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
89 struct msm_dsi_phy *src_phy);
90void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
91void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
92 struct msm_dsi_phy_clk_request *clk_req,
93 bool is_bonded_dsi);
94void msm_dsi_host_destroy(struct mipi_dsi_host *host);
95int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
96 struct drm_device *dev);
97int msm_dsi_host_init(struct msm_dsi *msm_dsi);
98int msm_dsi_runtime_suspend(struct device *dev);
99int msm_dsi_runtime_resume(struct device *dev);
100int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
101int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
102int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
103int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
104void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
105void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
106unsigned long dsi_byte_clk_get_rate(struct mipi_dsi_host *host, bool is_bonded_dsi,
107 const struct drm_display_mode *mode);
108int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
109int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
110void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
111void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
112void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
113void msm_dsi_tx_buf_free(struct mipi_dsi_host *mipi_host);
114int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
115int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
116int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
117int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
118int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
119int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
120void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
121void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
122struct drm_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
123bool msm_dsi_host_is_wide_bus_enabled(struct mipi_dsi_host *host);
124
125/* dsi phy */
126struct msm_dsi_phy;
127struct msm_dsi_phy_shared_timings {
128 u32 clk_post;
129 u32 clk_pre;
130 bool clk_pre_inc_by_2;
131 bool byte_intf_clk_div_2;
132};
133
134struct msm_dsi_phy_clk_request {
135 unsigned long bitclk_rate;
136 unsigned long escclk_rate;
137};
138
139void msm_dsi_phy_driver_register(void);
140void msm_dsi_phy_driver_unregister(void);
141int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
142 struct msm_dsi_phy_clk_request *clk_req,
143 struct msm_dsi_phy_shared_timings *shared_timings);
144void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
145void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
146 enum msm_dsi_phy_usecase uc);
147void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy);
148int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy);
149void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct msm_dsi_phy *phy);
150bool msm_dsi_phy_set_continuous_clock(struct msm_dsi_phy *phy, bool enable);
151
152#endif /* __DSI_CONNECTOR_H__ */
153
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 */
5
6#ifndef __DSI_CONNECTOR_H__
7#define __DSI_CONNECTOR_H__
8
9#include <linux/of_platform.h>
10#include <linux/platform_device.h>
11
12#include <drm/drm_bridge.h>
13#include <drm/drm_crtc.h>
14#include <drm/drm_mipi_dsi.h>
15
16#include "msm_drv.h"
17#include "disp/msm_disp_snapshot.h"
18
19#define DSI_0 0
20#define DSI_1 1
21#define DSI_MAX 2
22
23struct msm_dsi_phy_shared_timings;
24struct msm_dsi_phy_clk_request;
25
26enum msm_dsi_phy_usecase {
27 MSM_DSI_PHY_STANDALONE,
28 MSM_DSI_PHY_MASTER,
29 MSM_DSI_PHY_SLAVE,
30};
31
32#define DSI_BUS_CLK_MAX 4
33
34struct msm_dsi {
35 struct drm_device *dev;
36 struct platform_device *pdev;
37
38 /* internal dsi bridge attached to MDP interface */
39 struct drm_bridge *bridge;
40
41 struct mipi_dsi_host *host;
42 struct msm_dsi_phy *phy;
43
44 /*
45 * external_bridge connected to dsi bridge output
46 */
47 struct drm_bridge *external_bridge;
48
49 struct device *phy_dev;
50 bool phy_enabled;
51
52 /* the encoder we are hooked to (outside of dsi block) */
53 struct drm_encoder *encoder;
54
55 int id;
56};
57
58/* dsi manager */
59struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
60void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
61int msm_dsi_manager_ext_bridge_init(u8 id);
62int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
63bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
64int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
65void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
66void msm_dsi_manager_tpg_enable(void);
67
68/* msm dsi */
69static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
70{
71 return msm_dsi->external_bridge;
72}
73
74/* dsi host */
75struct msm_dsi_host;
76int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
77 const struct mipi_dsi_msg *msg);
78void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
79 const struct mipi_dsi_msg *msg);
80int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
81 const struct mipi_dsi_msg *msg);
82int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
83 const struct mipi_dsi_msg *msg);
84void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
85 u32 dma_base, u32 len);
86int msm_dsi_host_enable(struct mipi_dsi_host *host);
87int msm_dsi_host_disable(struct mipi_dsi_host *host);
88void msm_dsi_host_enable_irq(struct mipi_dsi_host *host);
89void msm_dsi_host_disable_irq(struct mipi_dsi_host *host);
90int msm_dsi_host_power_on(struct mipi_dsi_host *host,
91 struct msm_dsi_phy_shared_timings *phy_shared_timings,
92 bool is_bonded_dsi, struct msm_dsi_phy *phy);
93int msm_dsi_host_power_off(struct mipi_dsi_host *host);
94int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
95 const struct drm_display_mode *mode);
96enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
97 const struct drm_display_mode *mode);
98unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
99int msm_dsi_host_register(struct mipi_dsi_host *host);
100void msm_dsi_host_unregister(struct mipi_dsi_host *host);
101void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
102 struct msm_dsi_phy *src_phy);
103int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
104 struct msm_dsi_phy *src_phy);
105void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
106void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
107 struct msm_dsi_phy_clk_request *clk_req,
108 bool is_bonded_dsi);
109void msm_dsi_host_destroy(struct mipi_dsi_host *host);
110int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
111 struct drm_device *dev);
112int msm_dsi_host_init(struct msm_dsi *msm_dsi);
113int msm_dsi_runtime_suspend(struct device *dev);
114int msm_dsi_runtime_resume(struct device *dev);
115int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
116int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
117int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
118int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
119void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
120void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
121int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
122int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
123void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
124void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
125void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
126int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
127int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
128int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
129int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
130int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
131int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
132void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
133void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
134struct drm_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
135
136/* dsi phy */
137struct msm_dsi_phy;
138struct msm_dsi_phy_shared_timings {
139 u32 clk_post;
140 u32 clk_pre;
141 bool clk_pre_inc_by_2;
142};
143
144struct msm_dsi_phy_clk_request {
145 unsigned long bitclk_rate;
146 unsigned long escclk_rate;
147};
148
149void msm_dsi_phy_driver_register(void);
150void msm_dsi_phy_driver_unregister(void);
151int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
152 struct msm_dsi_phy_clk_request *clk_req,
153 struct msm_dsi_phy_shared_timings *shared_timings);
154void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
155void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
156 enum msm_dsi_phy_usecase uc);
157void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy);
158int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy);
159void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct msm_dsi_phy *phy);
160bool msm_dsi_phy_set_continuous_clock(struct msm_dsi_phy *phy, bool enable);
161
162#endif /* __DSI_CONNECTOR_H__ */
163