Linux Audio

Check our new training course

Loading...
v5.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_crtc.h>
 13#include <drm/drm_mipi_dsi.h>
 14#include <drm/drm_panel.h>
 15
 16#include "msm_drv.h"
 17
 18#define DSI_0	0
 19#define DSI_1	1
 20#define DSI_MAX	2
 21
 22struct msm_dsi_phy_shared_timings;
 23struct msm_dsi_phy_clk_request;
 24
 25enum msm_dsi_phy_type {
 26	MSM_DSI_PHY_28NM_HPM,
 27	MSM_DSI_PHY_28NM_LP,
 28	MSM_DSI_PHY_20NM,
 29	MSM_DSI_PHY_28NM_8960,
 30	MSM_DSI_PHY_14NM,
 31	MSM_DSI_PHY_10NM,
 32	MSM_DSI_PHY_MAX
 33};
 34
 35enum msm_dsi_phy_usecase {
 36	MSM_DSI_PHY_STANDALONE,
 37	MSM_DSI_PHY_MASTER,
 38	MSM_DSI_PHY_SLAVE,
 39};
 40
 41#define DSI_DEV_REGULATOR_MAX	8
 42#define DSI_BUS_CLK_MAX		4
 43
 44/* Regulators for DSI devices */
 45struct dsi_reg_entry {
 46	char name[32];
 47	int enable_load;
 48	int disable_load;
 49};
 50
 51struct dsi_reg_config {
 52	int num;
 53	struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
 54};
 55
 56struct msm_dsi {
 57	struct drm_device *dev;
 58	struct platform_device *pdev;
 59
 60	/* connector managed by us when we're connected to a drm_panel */
 61	struct drm_connector *connector;
 62	/* internal dsi bridge attached to MDP interface */
 63	struct drm_bridge *bridge;
 64
 65	struct mipi_dsi_host *host;
 66	struct msm_dsi_phy *phy;
 67
 68	/*
 69	 * panel/external_bridge connected to dsi bridge output, only one of the
 70	 * two can be valid at a time
 71	 */
 72	struct drm_panel *panel;
 73	struct drm_bridge *external_bridge;
 
 74
 75	struct device *phy_dev;
 76	bool phy_enabled;
 77
 78	/* the encoder we are hooked to (outside of dsi block) */
 79	struct drm_encoder *encoder;
 80
 81	int id;
 82};
 83
 84/* dsi manager */
 85struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
 86void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
 87struct drm_connector *msm_dsi_manager_connector_init(u8 id);
 88struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
 89int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 90bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
 91void msm_dsi_manager_setup_encoder(int id);
 92int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
 93void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 94bool msm_dsi_manager_validate_current_config(u8 id);
 95
 96/* msm dsi */
 97static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
 98{
 99	return msm_dsi->panel || msm_dsi->external_bridge;
100}
101
102struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
103
104/* dsi pll */
105struct msm_dsi_pll;
106#ifdef CONFIG_DRM_MSM_DSI_PLL
107struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
108			enum msm_dsi_phy_type type, int dsi_id);
109void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
110int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
111	struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
112void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
113int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
114int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
115			    enum msm_dsi_phy_usecase uc);
116#else
117static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
118			 enum msm_dsi_phy_type type, int id) {
119	return ERR_PTR(-ENODEV);
120}
121static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
122{
123}
124static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
125	struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
126{
127	return -ENODEV;
128}
129static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
130{
131}
132static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
133{
134	return 0;
135}
136static inline int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
137					  enum msm_dsi_phy_usecase uc)
138{
139	return -ENODEV;
140}
141#endif
142
143/* dsi host */
144struct msm_dsi_host;
145int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
146					const struct mipi_dsi_msg *msg);
147void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
148					const struct mipi_dsi_msg *msg);
149int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
150					const struct mipi_dsi_msg *msg);
151int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
152					const struct mipi_dsi_msg *msg);
153void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
154					u32 dma_base, u32 len);
155int msm_dsi_host_enable(struct mipi_dsi_host *host);
156int msm_dsi_host_disable(struct mipi_dsi_host *host);
157int msm_dsi_host_power_on(struct mipi_dsi_host *host,
158			struct msm_dsi_phy_shared_timings *phy_shared_timings,
159			bool is_dual_dsi);
160int msm_dsi_host_power_off(struct mipi_dsi_host *host);
161int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
162				  const struct drm_display_mode *mode);
163struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
164unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
165struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
166int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
167void msm_dsi_host_unregister(struct mipi_dsi_host *host);
168int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
169			struct msm_dsi_pll *src_pll);
170void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
171void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
172	struct msm_dsi_phy_clk_request *clk_req,
173	bool is_dual_dsi);
174void msm_dsi_host_destroy(struct mipi_dsi_host *host);
175int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
176					struct drm_device *dev);
177int msm_dsi_host_init(struct msm_dsi *msm_dsi);
178int msm_dsi_runtime_suspend(struct device *dev);
179int msm_dsi_runtime_resume(struct device *dev);
180int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
181int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
182void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
183void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
184int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
185int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
186void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
187void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
188void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
189int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
190int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
191int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
192int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
193int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi);
194int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi);
195
196/* dsi phy */
197struct msm_dsi_phy;
198struct msm_dsi_phy_shared_timings {
199	u32 clk_post;
200	u32 clk_pre;
201	bool clk_pre_inc_by_2;
202};
203
204struct msm_dsi_phy_clk_request {
205	unsigned long bitclk_rate;
206	unsigned long escclk_rate;
207};
208
209void msm_dsi_phy_driver_register(void);
210void msm_dsi_phy_driver_unregister(void);
211int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
212			struct msm_dsi_phy_clk_request *clk_req);
213void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
214void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
215			struct msm_dsi_phy_shared_timings *shared_timing);
216struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
217void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
218			     enum msm_dsi_phy_usecase uc);
219
220#endif /* __DSI_CONNECTOR_H__ */
221
v4.17
 
  1/*
  2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3 *
  4 * This program is free software; you can redistribute it and/or modify
  5 * it under the terms of the GNU General Public License version 2 and
  6 * only version 2 as published by the Free Software Foundation.
  7 *
  8 * This program is distributed in the hope that it will be useful,
  9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11 * GNU General Public License for more details.
 12 */
 13
 14#ifndef __DSI_CONNECTOR_H__
 15#define __DSI_CONNECTOR_H__
 16
 17#include <linux/of_platform.h>
 18#include <linux/platform_device.h>
 19
 20#include <drm/drm_crtc.h>
 21#include <drm/drm_mipi_dsi.h>
 22#include <drm/drm_panel.h>
 23
 24#include "msm_drv.h"
 25
 26#define DSI_0	0
 27#define DSI_1	1
 28#define DSI_MAX	2
 29
 30struct msm_dsi_phy_shared_timings;
 31struct msm_dsi_phy_clk_request;
 32
 33enum msm_dsi_phy_type {
 34	MSM_DSI_PHY_28NM_HPM,
 35	MSM_DSI_PHY_28NM_LP,
 36	MSM_DSI_PHY_20NM,
 37	MSM_DSI_PHY_28NM_8960,
 38	MSM_DSI_PHY_14NM,
 39	MSM_DSI_PHY_10NM,
 40	MSM_DSI_PHY_MAX
 41};
 42
 43enum msm_dsi_phy_usecase {
 44	MSM_DSI_PHY_STANDALONE,
 45	MSM_DSI_PHY_MASTER,
 46	MSM_DSI_PHY_SLAVE,
 47};
 48
 49#define DSI_DEV_REGULATOR_MAX	8
 50#define DSI_BUS_CLK_MAX		4
 51
 52/* Regulators for DSI devices */
 53struct dsi_reg_entry {
 54	char name[32];
 55	int enable_load;
 56	int disable_load;
 57};
 58
 59struct dsi_reg_config {
 60	int num;
 61	struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
 62};
 63
 64struct msm_dsi {
 65	struct drm_device *dev;
 66	struct platform_device *pdev;
 67
 68	/* connector managed by us when we're connected to a drm_panel */
 69	struct drm_connector *connector;
 70	/* internal dsi bridge attached to MDP interface */
 71	struct drm_bridge *bridge;
 72
 73	struct mipi_dsi_host *host;
 74	struct msm_dsi_phy *phy;
 75
 76	/*
 77	 * panel/external_bridge connected to dsi bridge output, only one of the
 78	 * two can be valid at a time
 79	 */
 80	struct drm_panel *panel;
 81	struct drm_bridge *external_bridge;
 82	unsigned long device_flags;
 83
 84	struct device *phy_dev;
 85	bool phy_enabled;
 86
 87	/* the encoder we are hooked to (outside of dsi block) */
 88	struct drm_encoder *encoder;
 89
 90	int id;
 91};
 92
 93/* dsi manager */
 94struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
 95void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
 96struct drm_connector *msm_dsi_manager_connector_init(u8 id);
 97struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
 98int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 99bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
100void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags);
101int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
102void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 
103
104/* msm dsi */
105static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
106{
107	return msm_dsi->panel || msm_dsi->external_bridge;
108}
109
110struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
111
112/* dsi pll */
113struct msm_dsi_pll;
114#ifdef CONFIG_DRM_MSM_DSI_PLL
115struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
116			enum msm_dsi_phy_type type, int dsi_id);
117void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
118int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
119	struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
120void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
121int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
122int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
123			    enum msm_dsi_phy_usecase uc);
124#else
125static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
126			 enum msm_dsi_phy_type type, int id) {
127	return ERR_PTR(-ENODEV);
128}
129static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
130{
131}
132static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
133	struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
134{
135	return -ENODEV;
136}
137static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
138{
139}
140static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
141{
142	return 0;
143}
144static inline int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
145					  enum msm_dsi_phy_usecase uc)
146{
147	return -ENODEV;
148}
149#endif
150
151/* dsi host */
 
152int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
153					const struct mipi_dsi_msg *msg);
154void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
155					const struct mipi_dsi_msg *msg);
156int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
157					const struct mipi_dsi_msg *msg);
158int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
159					const struct mipi_dsi_msg *msg);
160void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
161					u32 dma_base, u32 len);
162int msm_dsi_host_enable(struct mipi_dsi_host *host);
163int msm_dsi_host_disable(struct mipi_dsi_host *host);
164int msm_dsi_host_power_on(struct mipi_dsi_host *host,
165			struct msm_dsi_phy_shared_timings *phy_shared_timings);
 
166int msm_dsi_host_power_off(struct mipi_dsi_host *host);
167int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
168					struct drm_display_mode *mode);
169struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
170					unsigned long *panel_flags);
171struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
172int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
173void msm_dsi_host_unregister(struct mipi_dsi_host *host);
174int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
175			struct msm_dsi_pll *src_pll);
176void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
177void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
178	struct msm_dsi_phy_clk_request *clk_req);
 
179void msm_dsi_host_destroy(struct mipi_dsi_host *host);
180int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
181					struct drm_device *dev);
182int msm_dsi_host_init(struct msm_dsi *msm_dsi);
183int msm_dsi_runtime_suspend(struct device *dev);
184int msm_dsi_runtime_resume(struct device *dev);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
186/* dsi phy */
187struct msm_dsi_phy;
188struct msm_dsi_phy_shared_timings {
189	u32 clk_post;
190	u32 clk_pre;
191	bool clk_pre_inc_by_2;
192};
193
194struct msm_dsi_phy_clk_request {
195	unsigned long bitclk_rate;
196	unsigned long escclk_rate;
197};
198
199void msm_dsi_phy_driver_register(void);
200void msm_dsi_phy_driver_unregister(void);
201int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
202			struct msm_dsi_phy_clk_request *clk_req);
203void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
204void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
205			struct msm_dsi_phy_shared_timings *shared_timing);
206struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
207void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
208			     enum msm_dsi_phy_usecase uc);
209
210#endif /* __DSI_CONNECTOR_H__ */
211