Linux Audio

Check our new training course

Loading...
v6.9.4
  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
 
 
 
 
 
 
 
 41	struct device *phy_dev;
 42	bool phy_enabled;
 43
 
 
 
 44	int id;
 45};
 46
 47/* dsi manager */
 48struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
 49					       struct drm_encoder *encoder);
 50int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge);
 
 51int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 52bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
 
 53int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
 54void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 55void msm_dsi_manager_tpg_enable(void);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 56
 57/* dsi host */
 58struct msm_dsi_host;
 59int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
 60					const struct mipi_dsi_msg *msg);
 61void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
 62					const struct mipi_dsi_msg *msg);
 63int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
 64					const struct mipi_dsi_msg *msg);
 65int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
 66					const struct mipi_dsi_msg *msg);
 67void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
 68					u32 dma_base, u32 len);
 69int msm_dsi_host_enable(struct mipi_dsi_host *host);
 70int msm_dsi_host_disable(struct mipi_dsi_host *host);
 71void msm_dsi_host_enable_irq(struct mipi_dsi_host *host);
 72void msm_dsi_host_disable_irq(struct mipi_dsi_host *host);
 73int msm_dsi_host_power_on(struct mipi_dsi_host *host,
 74			struct msm_dsi_phy_shared_timings *phy_shared_timings,
 75			bool is_bonded_dsi, struct msm_dsi_phy *phy);
 76int msm_dsi_host_power_off(struct mipi_dsi_host *host);
 77int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
 78				  const struct drm_display_mode *mode);
 79enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
 80					    const struct drm_display_mode *mode);
 81unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
 82int msm_dsi_host_register(struct mipi_dsi_host *host);
 
 83void msm_dsi_host_unregister(struct mipi_dsi_host *host);
 84void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
 85			struct msm_dsi_phy *src_phy);
 86int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
 87			struct msm_dsi_phy *src_phy);
 88void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
 89void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
 90	struct msm_dsi_phy_clk_request *clk_req,
 91	bool is_bonded_dsi);
 92void msm_dsi_host_destroy(struct mipi_dsi_host *host);
 93int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
 94					struct drm_device *dev);
 95int msm_dsi_host_init(struct msm_dsi *msm_dsi);
 96int msm_dsi_runtime_suspend(struct device *dev);
 97int msm_dsi_runtime_resume(struct device *dev);
 98int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
 99int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
100int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
101int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
102void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
103void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
104unsigned long dsi_byte_clk_get_rate(struct mipi_dsi_host *host, bool is_bonded_dsi,
105				    const struct drm_display_mode *mode);
106int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
107int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
108void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
109void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
110void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
111void msm_dsi_tx_buf_free(struct mipi_dsi_host *mipi_host);
112int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
113int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
114int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
115int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
116int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
117int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
118void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
119void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
120struct drm_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
121bool msm_dsi_host_is_wide_bus_enabled(struct mipi_dsi_host *host);
122
123/* dsi phy */
124struct msm_dsi_phy;
125struct msm_dsi_phy_shared_timings {
126	u32 clk_post;
127	u32 clk_pre;
128	bool clk_pre_inc_by_2;
129	bool byte_intf_clk_div_2;
130};
131
132struct msm_dsi_phy_clk_request {
133	unsigned long bitclk_rate;
134	unsigned long escclk_rate;
135};
136
137void msm_dsi_phy_driver_register(void);
138void msm_dsi_phy_driver_unregister(void);
139int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
140			struct msm_dsi_phy_clk_request *clk_req,
141			struct msm_dsi_phy_shared_timings *shared_timings);
142void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
 
 
 
143void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
144			     enum msm_dsi_phy_usecase uc);
145void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy);
146int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy);
147void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct msm_dsi_phy *phy);
148bool msm_dsi_phy_set_continuous_clock(struct msm_dsi_phy *phy, bool enable);
149
150#endif /* __DSI_CONNECTOR_H__ */
151
v5.9
  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#include <drm/drm_panel.h>
 16
 17#include "msm_drv.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_type {
 27	MSM_DSI_PHY_28NM_HPM,
 28	MSM_DSI_PHY_28NM_LP,
 29	MSM_DSI_PHY_20NM,
 30	MSM_DSI_PHY_28NM_8960,
 31	MSM_DSI_PHY_14NM,
 32	MSM_DSI_PHY_10NM,
 33	MSM_DSI_PHY_MAX
 34};
 35
 36enum msm_dsi_phy_usecase {
 37	MSM_DSI_PHY_STANDALONE,
 38	MSM_DSI_PHY_MASTER,
 39	MSM_DSI_PHY_SLAVE,
 40};
 41
 42#define DSI_DEV_REGULATOR_MAX	8
 43#define DSI_BUS_CLK_MAX		4
 44
 45/* Regulators for DSI devices */
 46struct dsi_reg_entry {
 47	char name[32];
 48	int enable_load;
 49	int disable_load;
 50};
 51
 52struct dsi_reg_config {
 53	int num;
 54	struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
 55};
 56
 57struct msm_dsi {
 58	struct drm_device *dev;
 59	struct platform_device *pdev;
 60
 61	/* connector managed by us when we're connected to a drm_panel */
 62	struct drm_connector *connector;
 63	/* internal dsi bridge attached to MDP interface */
 64	struct drm_bridge *bridge;
 65
 66	struct mipi_dsi_host *host;
 67	struct msm_dsi_phy *phy;
 68
 69	/*
 70	 * panel/external_bridge connected to dsi bridge output, only one of the
 71	 * two can be valid at a time
 72	 */
 73	struct drm_panel *panel;
 74	struct drm_bridge *external_bridge;
 75
 76	struct device *phy_dev;
 77	bool phy_enabled;
 78
 79	/* the encoder we are hooked to (outside of dsi block) */
 80	struct drm_encoder *encoder;
 81
 82	int id;
 83};
 84
 85/* dsi manager */
 86struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
 87void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
 88struct drm_connector *msm_dsi_manager_connector_init(u8 id);
 89struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
 90int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 91bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
 92void msm_dsi_manager_setup_encoder(int id);
 93int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
 94void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 95bool msm_dsi_manager_validate_current_config(u8 id);
 96
 97/* msm dsi */
 98static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
 99{
100	return msm_dsi->panel || msm_dsi->external_bridge;
101}
102
103struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
104
105/* dsi pll */
106struct msm_dsi_pll;
107#ifdef CONFIG_DRM_MSM_DSI_PLL
108struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
109			enum msm_dsi_phy_type type, int dsi_id);
110void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
111int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
112	struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
113void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
114int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
115int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
116			    enum msm_dsi_phy_usecase uc);
117#else
118static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
119			 enum msm_dsi_phy_type type, int id) {
120	return ERR_PTR(-ENODEV);
121}
122static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
123{
124}
125static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
126	struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
127{
128	return -ENODEV;
129}
130static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
131{
132}
133static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
134{
135	return 0;
136}
137static inline int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
138					  enum msm_dsi_phy_usecase uc)
139{
140	return -ENODEV;
141}
142#endif
143
144/* dsi host */
145struct msm_dsi_host;
146int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
147					const struct mipi_dsi_msg *msg);
148void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
149					const struct mipi_dsi_msg *msg);
150int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
151					const struct mipi_dsi_msg *msg);
152int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
153					const struct mipi_dsi_msg *msg);
154void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
155					u32 dma_base, u32 len);
156int msm_dsi_host_enable(struct mipi_dsi_host *host);
157int msm_dsi_host_disable(struct mipi_dsi_host *host);
 
 
158int msm_dsi_host_power_on(struct mipi_dsi_host *host,
159			struct msm_dsi_phy_shared_timings *phy_shared_timings,
160			bool is_dual_dsi);
161int msm_dsi_host_power_off(struct mipi_dsi_host *host);
162int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
163				  const struct drm_display_mode *mode);
164struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
 
165unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
166struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
167int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
168void msm_dsi_host_unregister(struct mipi_dsi_host *host);
 
 
169int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
170			struct msm_dsi_pll *src_pll);
171void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
172void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
173	struct msm_dsi_phy_clk_request *clk_req,
174	bool is_dual_dsi);
175void msm_dsi_host_destroy(struct mipi_dsi_host *host);
176int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
177					struct drm_device *dev);
178int msm_dsi_host_init(struct msm_dsi *msm_dsi);
179int msm_dsi_runtime_suspend(struct device *dev);
180int msm_dsi_runtime_resume(struct device *dev);
181int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
182int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
183int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
184int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
185void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
186void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
 
 
187int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
188int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
189void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
190void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
191void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
 
192int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
193int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
194int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
195int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
196int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi);
197int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi);
 
 
 
 
198
199/* dsi phy */
200struct msm_dsi_phy;
201struct msm_dsi_phy_shared_timings {
202	u32 clk_post;
203	u32 clk_pre;
204	bool clk_pre_inc_by_2;
 
205};
206
207struct msm_dsi_phy_clk_request {
208	unsigned long bitclk_rate;
209	unsigned long escclk_rate;
210};
211
212void msm_dsi_phy_driver_register(void);
213void msm_dsi_phy_driver_unregister(void);
214int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
215			struct msm_dsi_phy_clk_request *clk_req);
 
216void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
217void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
218			struct msm_dsi_phy_shared_timings *shared_timing);
219struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
220void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
221			     enum msm_dsi_phy_usecase uc);
 
 
 
 
222
223#endif /* __DSI_CONNECTOR_H__ */
224