drm/msm/dsi: Move PHY operations out of host
[linux-2.6-block.git] / drivers / gpu / drm / msm / dsi / dsi.h
CommitLineData
a689554b
HL
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
ec31abf6 17#include <linux/of_platform.h>
a689554b
HL
18#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
dceac340 30struct msm_dsi_phy_shared_timings;
b62aa70a 31struct msm_dsi_phy_clk_request;
dceac340 32
9d32c498 33enum msm_dsi_phy_type {
9d32c498
HL
34 MSM_DSI_PHY_28NM_HPM,
35 MSM_DSI_PHY_28NM_LP,
dcefc117 36 MSM_DSI_PHY_20NM,
225380b3 37 MSM_DSI_PHY_28NM_8960,
9d32c498
HL
38 MSM_DSI_PHY_MAX
39};
40
57bf4338
HL
41enum msm_dsi_phy_usecase {
42 MSM_DSI_PHY_STANDALONE,
43 MSM_DSI_PHY_MASTER,
44 MSM_DSI_PHY_SLAVE,
45};
46
ec31abf6 47#define DSI_DEV_REGULATOR_MAX 8
6e0eb52e 48#define DSI_BUS_CLK_MAX 4
ec31abf6
HL
49
50/* Regulators for DSI devices */
51struct dsi_reg_entry {
52 char name[32];
ec31abf6
HL
53 int enable_load;
54 int disable_load;
55};
56
57struct dsi_reg_config {
58 int num;
59 struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
60};
61
a689554b
HL
62struct msm_dsi {
63 struct drm_device *dev;
64 struct platform_device *pdev;
65
c118e290 66 /* connector managed by us when we're connected to a drm_panel */
a689554b 67 struct drm_connector *connector;
c118e290 68 /* internal dsi bridge attached to MDP interface */
a689554b
HL
69 struct drm_bridge *bridge;
70
71 struct mipi_dsi_host *host;
72 struct msm_dsi_phy *phy;
c118e290
AT
73
74 /*
75 * panel/external_bridge connected to dsi bridge output, only one of the
76 * two can be valid at a time
77 */
a689554b 78 struct drm_panel *panel;
c118e290 79 struct drm_bridge *external_bridge;
a9ddac9c 80 unsigned long device_flags;
9d32c498 81
ec31abf6 82 struct device *phy_dev;
a689554b
HL
83 bool phy_enabled;
84
97e00119
AT
85 /* the encoder we are hooked to (outside of dsi block) */
86 struct drm_encoder *encoder;
a689554b
HL
87
88 int id;
89};
90
91/* dsi manager */
92struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
93void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
94struct drm_connector *msm_dsi_manager_connector_init(u8 id);
c118e290 95struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
a689554b 96int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
4ff9d4cb 97bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
9c9f6f8d 98void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags);
a689554b
HL
99int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
100void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
101
102/* msm dsi */
6f054ec5
AT
103static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
104{
c118e290 105 return msm_dsi->panel || msm_dsi->external_bridge;
6f054ec5
AT
106}
107
a689554b
HL
108struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
109
9d32c498
HL
110/* dsi pll */
111struct msm_dsi_pll;
112#ifdef CONFIG_DRM_MSM_DSI_PLL
113struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
114 enum msm_dsi_phy_type type, int dsi_id);
115void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
116int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
117 struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
328e1a63
HL
118void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
119int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
9d32c498
HL
120#else
121static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
122 enum msm_dsi_phy_type type, int id) {
123 return ERR_PTR(-ENODEV);
124}
125static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
126{
127}
128static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
129 struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
130{
131 return -ENODEV;
132}
328e1a63
HL
133static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
134{
135}
136static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
137{
138 return 0;
139}
9d32c498
HL
140#endif
141
a689554b
HL
142/* dsi host */
143int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
144 const struct mipi_dsi_msg *msg);
145void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
146 const struct mipi_dsi_msg *msg);
147int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
148 const struct mipi_dsi_msg *msg);
149int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
150 const struct mipi_dsi_msg *msg);
151void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
4ff9d4cb 152 u32 dma_base, u32 len);
a689554b
HL
153int msm_dsi_host_enable(struct mipi_dsi_host *host);
154int msm_dsi_host_disable(struct mipi_dsi_host *host);
b62aa70a
HL
155int msm_dsi_host_power_on(struct mipi_dsi_host *host,
156 struct msm_dsi_phy_shared_timings *phy_shared_timings);
a689554b
HL
157int msm_dsi_host_power_off(struct mipi_dsi_host *host);
158int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
159 struct drm_display_mode *mode);
160struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
161 unsigned long *panel_flags);
c118e290 162struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
a689554b
HL
163int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
164void msm_dsi_host_unregister(struct mipi_dsi_host *host);
9d32c498
HL
165int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
166 struct msm_dsi_pll *src_pll);
34d9545b 167void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
b62aa70a
HL
168void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
169 struct msm_dsi_phy_clk_request *clk_req);
a689554b
HL
170void msm_dsi_host_destroy(struct mipi_dsi_host *host);
171int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
172 struct drm_device *dev);
173int msm_dsi_host_init(struct msm_dsi *msm_dsi);
174
175/* dsi phy */
176struct msm_dsi_phy;
dceac340
HL
177struct msm_dsi_phy_shared_timings {
178 u32 clk_post;
179 u32 clk_pre;
180 bool clk_pre_inc_by_2;
181};
b62aa70a
HL
182
183struct msm_dsi_phy_clk_request {
184 unsigned long bitclk_rate;
185 unsigned long escclk_rate;
186};
187
ec31abf6
HL
188void msm_dsi_phy_driver_register(void);
189void msm_dsi_phy_driver_unregister(void);
13351cd1 190int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
b62aa70a 191 struct msm_dsi_phy_clk_request *clk_req);
29e61690 192void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
dceac340
HL
193void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
194 struct msm_dsi_phy_shared_timings *shared_timing);
9d32c498 195struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
57bf4338
HL
196void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
197 enum msm_dsi_phy_usecase uc);
9d32c498 198
a689554b
HL
199#endif /* __DSI_CONNECTOR_H__ */
200