2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
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.
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.
14 #ifndef __DSI_CONNECTOR_H__
15 #define __DSI_CONNECTOR_H__
17 #include <linux/of_platform.h>
18 #include <linux/platform_device.h>
21 #include "drm_mipi_dsi.h"
22 #include "drm_panel.h"
30 enum msm_dsi_phy_type
{
34 MSM_DSI_PHY_28NM_8960
,
38 #define DSI_DEV_REGULATOR_MAX 8
39 #define DSI_BUS_CLK_MAX 4
41 /* Regulators for DSI devices */
42 struct dsi_reg_entry
{
48 struct dsi_reg_config
{
50 struct dsi_reg_entry regs
[DSI_DEV_REGULATOR_MAX
];
54 struct drm_device
*dev
;
55 struct platform_device
*pdev
;
57 /* connector managed by us when we're connected to a drm_panel */
58 struct drm_connector
*connector
;
59 /* internal dsi bridge attached to MDP interface */
60 struct drm_bridge
*bridge
;
62 struct mipi_dsi_host
*host
;
63 struct msm_dsi_phy
*phy
;
66 * panel/external_bridge connected to dsi bridge output, only one of the
67 * two can be valid at a time
69 struct drm_panel
*panel
;
70 struct drm_bridge
*external_bridge
;
71 unsigned long device_flags
;
73 struct device
*phy_dev
;
76 /* the encoders we are hooked to (outside of dsi block) */
77 struct drm_encoder
*encoders
[MSM_DSI_ENCODER_NUM
];
83 struct drm_bridge
*msm_dsi_manager_bridge_init(u8 id
);
84 void msm_dsi_manager_bridge_destroy(struct drm_bridge
*bridge
);
85 struct drm_connector
*msm_dsi_manager_connector_init(u8 id
);
86 struct drm_connector
*msm_dsi_manager_ext_bridge_init(u8 id
);
87 int msm_dsi_manager_phy_enable(int id
,
88 const unsigned long bit_rate
, const unsigned long esc_rate
,
89 u32
*clk_pre
, u32
*clk_post
);
90 void msm_dsi_manager_phy_disable(int id
);
91 int msm_dsi_manager_cmd_xfer(int id
, const struct mipi_dsi_msg
*msg
);
92 bool msm_dsi_manager_cmd_xfer_trigger(int id
, u32 dma_base
, u32 len
);
93 int msm_dsi_manager_register(struct msm_dsi
*msm_dsi
);
94 void msm_dsi_manager_unregister(struct msm_dsi
*msm_dsi
);
97 static inline bool msm_dsi_device_connected(struct msm_dsi
*msm_dsi
)
99 return msm_dsi
->panel
|| msm_dsi
->external_bridge
;
102 struct drm_encoder
*msm_dsi_get_encoder(struct msm_dsi
*msm_dsi
);
106 #ifdef CONFIG_DRM_MSM_DSI_PLL
107 struct msm_dsi_pll
*msm_dsi_pll_init(struct platform_device
*pdev
,
108 enum msm_dsi_phy_type type
, int dsi_id
);
109 void msm_dsi_pll_destroy(struct msm_dsi_pll
*pll
);
110 int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll
*pll
,
111 struct clk
**byte_clk_provider
, struct clk
**pixel_clk_provider
);
112 void msm_dsi_pll_save_state(struct msm_dsi_pll
*pll
);
113 int msm_dsi_pll_restore_state(struct msm_dsi_pll
*pll
);
115 static inline struct msm_dsi_pll
*msm_dsi_pll_init(struct platform_device
*pdev
,
116 enum msm_dsi_phy_type type
, int id
) {
117 return ERR_PTR(-ENODEV
);
119 static inline void msm_dsi_pll_destroy(struct msm_dsi_pll
*pll
)
122 static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll
*pll
,
123 struct clk
**byte_clk_provider
, struct clk
**pixel_clk_provider
)
127 static inline void msm_dsi_pll_save_state(struct msm_dsi_pll
*pll
)
130 static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll
*pll
)
137 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host
*host
,
138 const struct mipi_dsi_msg
*msg
);
139 void msm_dsi_host_xfer_restore(struct mipi_dsi_host
*host
,
140 const struct mipi_dsi_msg
*msg
);
141 int msm_dsi_host_cmd_tx(struct mipi_dsi_host
*host
,
142 const struct mipi_dsi_msg
*msg
);
143 int msm_dsi_host_cmd_rx(struct mipi_dsi_host
*host
,
144 const struct mipi_dsi_msg
*msg
);
145 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host
*host
,
146 u32 dma_base
, u32 len
);
147 int msm_dsi_host_enable(struct mipi_dsi_host
*host
);
148 int msm_dsi_host_disable(struct mipi_dsi_host
*host
);
149 int msm_dsi_host_power_on(struct mipi_dsi_host
*host
);
150 int msm_dsi_host_power_off(struct mipi_dsi_host
*host
);
151 int msm_dsi_host_set_display_mode(struct mipi_dsi_host
*host
,
152 struct drm_display_mode
*mode
);
153 struct drm_panel
*msm_dsi_host_get_panel(struct mipi_dsi_host
*host
,
154 unsigned long *panel_flags
);
155 struct drm_bridge
*msm_dsi_host_get_bridge(struct mipi_dsi_host
*host
);
156 int msm_dsi_host_register(struct mipi_dsi_host
*host
, bool check_defer
);
157 void msm_dsi_host_unregister(struct mipi_dsi_host
*host
);
158 int msm_dsi_host_set_src_pll(struct mipi_dsi_host
*host
,
159 struct msm_dsi_pll
*src_pll
);
160 void msm_dsi_host_destroy(struct mipi_dsi_host
*host
);
161 int msm_dsi_host_modeset_init(struct mipi_dsi_host
*host
,
162 struct drm_device
*dev
);
163 int msm_dsi_host_init(struct msm_dsi
*msm_dsi
);
167 void msm_dsi_phy_driver_register(void);
168 void msm_dsi_phy_driver_unregister(void);
169 int msm_dsi_phy_enable(struct msm_dsi_phy
*phy
, int src_pll_id
,
170 const unsigned long bit_rate
, const unsigned long esc_rate
);
171 void msm_dsi_phy_disable(struct msm_dsi_phy
*phy
);
172 void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy
*phy
,
173 u32
*clk_pre
, u32
*clk_post
);
174 struct msm_dsi_pll
*msm_dsi_phy_get_pll(struct msm_dsi_phy
*phy
);
176 #endif /* __DSI_CONNECTOR_H__ */