blob: 1636513347e0e5419a287313afac1a769977d5fb [file] [log] [blame]
Hai Lia6895542015-03-31 14:36:33 -04001/*
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
Hai Liec31abf2015-05-15 13:04:06 -040017#include <linux/of_platform.h>
Hai Lia6895542015-03-31 14:36:33 -040018#include <linux/platform_device.h>
19
20#include "drm_crtc.h"
21#include "drm_mipi_dsi.h"
22#include "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
Hai Li9d32c4982015-05-15 13:04:05 -040030enum msm_dsi_phy_type {
Hai Li9d32c4982015-05-15 13:04:05 -040031 MSM_DSI_PHY_28NM_HPM,
32 MSM_DSI_PHY_28NM_LP,
Hai Lidcefc112015-06-18 10:14:21 -040033 MSM_DSI_PHY_20NM,
Hai Li9d32c4982015-05-15 13:04:05 -040034 MSM_DSI_PHY_MAX
35};
36
Hai Liec31abf2015-05-15 13:04:06 -040037#define DSI_DEV_REGULATOR_MAX 8
38
39/* Regulators for DSI devices */
40struct dsi_reg_entry {
41 char name[32];
42 int min_voltage;
43 int max_voltage;
44 int enable_load;
45 int disable_load;
46};
47
48struct dsi_reg_config {
49 int num;
50 struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
51};
52
Hai Lia6895542015-03-31 14:36:33 -040053struct msm_dsi {
54 struct drm_device *dev;
55 struct platform_device *pdev;
56
57 struct drm_connector *connector;
58 struct drm_bridge *bridge;
59
60 struct mipi_dsi_host *host;
61 struct msm_dsi_phy *phy;
62 struct drm_panel *panel;
Archit Tanejaa9ddac92015-08-03 14:05:45 +053063 unsigned long device_flags;
Hai Li9d32c4982015-05-15 13:04:05 -040064
Hai Liec31abf2015-05-15 13:04:06 -040065 struct device *phy_dev;
Hai Lia6895542015-03-31 14:36:33 -040066 bool phy_enabled;
67
68 /* the encoders we are hooked to (outside of dsi block) */
69 struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
70
71 int id;
72};
73
74/* dsi manager */
75struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
76void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
77struct drm_connector *msm_dsi_manager_connector_init(u8 id);
78int msm_dsi_manager_phy_enable(int id,
79 const unsigned long bit_rate, const unsigned long esc_rate,
80 u32 *clk_pre, u32 *clk_post);
81void msm_dsi_manager_phy_disable(int id);
82int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
83bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len);
84int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
85void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
86
87/* msm dsi */
Archit Taneja6f054ec2015-08-03 14:08:33 +053088static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
89{
90 return msm_dsi->panel;
91}
92
Hai Lia6895542015-03-31 14:36:33 -040093struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
94
Hai Li9d32c4982015-05-15 13:04:05 -040095/* dsi pll */
96struct msm_dsi_pll;
97#ifdef CONFIG_DRM_MSM_DSI_PLL
98struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
99 enum msm_dsi_phy_type type, int dsi_id);
100void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
101int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
102 struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
Hai Li328e1a62015-07-03 10:09:46 -0400103void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
104int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
Hai Li9d32c4982015-05-15 13:04:05 -0400105#else
106static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
107 enum msm_dsi_phy_type type, int id) {
108 return ERR_PTR(-ENODEV);
109}
110static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
111{
112}
113static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
114 struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
115{
116 return -ENODEV;
117}
Hai Li328e1a62015-07-03 10:09:46 -0400118static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
119{
120}
121static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
122{
123 return 0;
124}
Hai Li9d32c4982015-05-15 13:04:05 -0400125#endif
126
Hai Lia6895542015-03-31 14:36:33 -0400127/* dsi host */
128int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
129 const struct mipi_dsi_msg *msg);
130void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
131 const struct mipi_dsi_msg *msg);
132int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
133 const struct mipi_dsi_msg *msg);
134int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
135 const struct mipi_dsi_msg *msg);
136void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
137 u32 iova, u32 len);
138int msm_dsi_host_enable(struct mipi_dsi_host *host);
139int msm_dsi_host_disable(struct mipi_dsi_host *host);
140int msm_dsi_host_power_on(struct mipi_dsi_host *host);
141int msm_dsi_host_power_off(struct mipi_dsi_host *host);
142int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
143 struct drm_display_mode *mode);
144struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
145 unsigned long *panel_flags);
146int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
147void msm_dsi_host_unregister(struct mipi_dsi_host *host);
Hai Li9d32c4982015-05-15 13:04:05 -0400148int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
149 struct msm_dsi_pll *src_pll);
Hai Lia6895542015-03-31 14:36:33 -0400150void msm_dsi_host_destroy(struct mipi_dsi_host *host);
151int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
152 struct drm_device *dev);
153int msm_dsi_host_init(struct msm_dsi *msm_dsi);
154
155/* dsi phy */
156struct msm_dsi_phy;
Hai Liec31abf2015-05-15 13:04:06 -0400157void msm_dsi_phy_driver_register(void);
158void msm_dsi_phy_driver_unregister(void);
Hai Li13351cd2015-06-10 13:18:17 -0400159int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
Hai Lia6895542015-03-31 14:36:33 -0400160 const unsigned long bit_rate, const unsigned long esc_rate);
161int msm_dsi_phy_disable(struct msm_dsi_phy *phy);
162void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
163 u32 *clk_pre, u32 *clk_post);
Hai Li9d32c4982015-05-15 13:04:05 -0400164struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
165
Hai Lia6895542015-03-31 14:36:33 -0400166#endif /* __DSI_CONNECTOR_H__ */
167