Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2015, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #ifndef __DSI_CONNECTOR_H__
0007 #define __DSI_CONNECTOR_H__
0008 
0009 #include <linux/of_platform.h>
0010 #include <linux/platform_device.h>
0011 
0012 #include <drm/drm_bridge.h>
0013 #include <drm/drm_crtc.h>
0014 #include <drm/drm_mipi_dsi.h>
0015 #include <drm/drm_panel.h>
0016 
0017 #include "msm_drv.h"
0018 #include "disp/msm_disp_snapshot.h"
0019 
0020 #define DSI_0   0
0021 #define DSI_1   1
0022 #define DSI_MAX 2
0023 
0024 struct msm_dsi_phy_shared_timings;
0025 struct msm_dsi_phy_clk_request;
0026 
0027 enum msm_dsi_phy_usecase {
0028     MSM_DSI_PHY_STANDALONE,
0029     MSM_DSI_PHY_MASTER,
0030     MSM_DSI_PHY_SLAVE,
0031 };
0032 
0033 #define DSI_DEV_REGULATOR_MAX   8
0034 #define DSI_BUS_CLK_MAX     4
0035 
0036 /* Regulators for DSI devices */
0037 struct dsi_reg_entry {
0038     char name[32];
0039     int enable_load;
0040     int disable_load;
0041 };
0042 
0043 struct dsi_reg_config {
0044     int num;
0045     struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
0046 };
0047 
0048 struct msm_dsi {
0049     struct drm_device *dev;
0050     struct platform_device *pdev;
0051 
0052     /* connector managed by us when we're connected to a drm_panel */
0053     struct drm_connector *connector;
0054     /* internal dsi bridge attached to MDP interface */
0055     struct drm_bridge *bridge;
0056 
0057     struct mipi_dsi_host *host;
0058     struct msm_dsi_phy *phy;
0059 
0060     /*
0061      * panel/external_bridge connected to dsi bridge output, only one of the
0062      * two can be valid at a time
0063      */
0064     struct drm_panel *panel;
0065     struct drm_bridge *external_bridge;
0066 
0067     struct device *phy_dev;
0068     bool phy_enabled;
0069 
0070     /* the encoder we are hooked to (outside of dsi block) */
0071     struct drm_encoder *encoder;
0072 
0073     int id;
0074 };
0075 
0076 /* dsi manager */
0077 struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
0078 void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
0079 struct drm_connector *msm_dsi_manager_connector_init(u8 id);
0080 struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
0081 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
0082 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
0083 int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
0084 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
0085 void msm_dsi_manager_tpg_enable(void);
0086 
0087 /* msm dsi */
0088 static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
0089 {
0090     return msm_dsi->panel || msm_dsi->external_bridge;
0091 }
0092 
0093 struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
0094 
0095 /* dsi host */
0096 struct msm_dsi_host;
0097 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
0098                     const struct mipi_dsi_msg *msg);
0099 void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
0100                     const struct mipi_dsi_msg *msg);
0101 int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
0102                     const struct mipi_dsi_msg *msg);
0103 int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
0104                     const struct mipi_dsi_msg *msg);
0105 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
0106                     u32 dma_base, u32 len);
0107 int msm_dsi_host_enable(struct mipi_dsi_host *host);
0108 int msm_dsi_host_disable(struct mipi_dsi_host *host);
0109 void msm_dsi_host_enable_irq(struct mipi_dsi_host *host);
0110 void msm_dsi_host_disable_irq(struct mipi_dsi_host *host);
0111 int msm_dsi_host_power_on(struct mipi_dsi_host *host,
0112             struct msm_dsi_phy_shared_timings *phy_shared_timings,
0113             bool is_bonded_dsi, struct msm_dsi_phy *phy);
0114 int msm_dsi_host_power_off(struct mipi_dsi_host *host);
0115 int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
0116                   const struct drm_display_mode *mode);
0117 enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
0118                         const struct drm_display_mode *mode);
0119 struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
0120 unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
0121 struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
0122 int msm_dsi_host_register(struct mipi_dsi_host *host);
0123 void msm_dsi_host_unregister(struct mipi_dsi_host *host);
0124 void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
0125             struct msm_dsi_phy *src_phy);
0126 int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
0127             struct msm_dsi_phy *src_phy);
0128 void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
0129 void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
0130     struct msm_dsi_phy_clk_request *clk_req,
0131     bool is_bonded_dsi);
0132 void msm_dsi_host_destroy(struct mipi_dsi_host *host);
0133 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
0134                     struct drm_device *dev);
0135 int msm_dsi_host_init(struct msm_dsi *msm_dsi);
0136 int msm_dsi_runtime_suspend(struct device *dev);
0137 int msm_dsi_runtime_resume(struct device *dev);
0138 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
0139 int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
0140 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
0141 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
0142 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
0143 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
0144 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
0145 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
0146 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
0147 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
0148 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
0149 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
0150 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
0151 int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
0152 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
0153 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
0154 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
0155 void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
0156 void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
0157 struct msm_display_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
0158 
0159 /* dsi phy */
0160 struct msm_dsi_phy;
0161 struct msm_dsi_phy_shared_timings {
0162     u32 clk_post;
0163     u32 clk_pre;
0164     bool clk_pre_inc_by_2;
0165 };
0166 
0167 struct msm_dsi_phy_clk_request {
0168     unsigned long bitclk_rate;
0169     unsigned long escclk_rate;
0170 };
0171 
0172 void msm_dsi_phy_driver_register(void);
0173 void msm_dsi_phy_driver_unregister(void);
0174 int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
0175             struct msm_dsi_phy_clk_request *clk_req,
0176             struct msm_dsi_phy_shared_timings *shared_timings);
0177 void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
0178 void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
0179                  enum msm_dsi_phy_usecase uc);
0180 void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy);
0181 int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy);
0182 void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct msm_dsi_phy *phy);
0183 bool msm_dsi_phy_set_continuous_clock(struct msm_dsi_phy *phy, bool enable);
0184 
0185 #endif /* __DSI_CONNECTOR_H__ */
0186