2019-05-29 07:17:58 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-03-31 14:36:33 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DSI_CONNECTOR_H__
|
|
|
|
#define __DSI_CONNECTOR_H__
|
|
|
|
|
2015-05-15 13:04:06 -04:00
|
|
|
#include <linux/of_platform.h>
|
2015-03-31 14:36:33 -04:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
2019-08-26 17:26:29 +02:00
|
|
|
#include <drm/drm_bridge.h>
|
2017-04-24 13:50:28 +09:00
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <drm/drm_mipi_dsi.h>
|
2015-03-31 14:36:33 -04:00
|
|
|
|
|
|
|
#include "msm_drv.h"
|
2021-04-16 13:57:21 -07:00
|
|
|
#include "disp/msm_disp_snapshot.h"
|
2015-03-31 14:36:33 -04:00
|
|
|
|
|
|
|
#define DSI_0 0
|
|
|
|
#define DSI_1 1
|
|
|
|
#define DSI_MAX 2
|
|
|
|
|
2016-09-15 14:34:49 +05:30
|
|
|
struct msm_dsi_phy_shared_timings;
|
2017-01-07 14:24:38 +05:30
|
|
|
struct msm_dsi_phy_clk_request;
|
2016-09-15 14:34:49 +05:30
|
|
|
|
2016-09-15 14:44:22 +05:30
|
|
|
enum msm_dsi_phy_usecase {
|
|
|
|
MSM_DSI_PHY_STANDALONE,
|
|
|
|
MSM_DSI_PHY_MASTER,
|
|
|
|
MSM_DSI_PHY_SLAVE,
|
|
|
|
};
|
|
|
|
|
2015-10-09 15:21:12 +05:30
|
|
|
#define DSI_BUS_CLK_MAX 4
|
2015-05-15 13:04:06 -04:00
|
|
|
|
2015-03-31 14:36:33 -04:00
|
|
|
struct msm_dsi {
|
|
|
|
struct drm_device *dev;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
|
|
|
|
struct mipi_dsi_host *host;
|
|
|
|
struct msm_dsi_phy *phy;
|
2024-06-13 20:05:09 +03:00
|
|
|
const char *te_source;
|
2015-07-31 14:06:10 +05:30
|
|
|
|
2024-03-09 17:09:06 +02:00
|
|
|
struct drm_bridge *next_bridge;
|
|
|
|
|
2015-05-15 13:04:06 -04:00
|
|
|
struct device *phy_dev;
|
2015-03-31 14:36:33 -04:00
|
|
|
bool phy_enabled;
|
|
|
|
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* dsi manager */
|
2024-03-09 17:09:07 +02:00
|
|
|
int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
|
|
|
|
struct drm_encoder *encoder);
|
2015-03-31 14:36:33 -04:00
|
|
|
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
|
2015-10-13 12:20:47 +05:30
|
|
|
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
|
2015-03-31 14:36:33 -04:00
|
|
|
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
|
|
|
|
void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
|
2021-07-21 19:50:32 -07:00
|
|
|
void msm_dsi_manager_tpg_enable(void);
|
2015-03-31 14:36:33 -04:00
|
|
|
|
|
|
|
/* dsi host */
|
2018-05-29 19:50:31 +05:30
|
|
|
struct msm_dsi_host;
|
2015-03-31 14:36:33 -04:00
|
|
|
int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
|
|
|
|
const struct mipi_dsi_msg *msg);
|
|
|
|
void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
|
|
|
|
const struct mipi_dsi_msg *msg);
|
|
|
|
int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
|
|
|
|
const struct mipi_dsi_msg *msg);
|
|
|
|
int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
|
|
|
|
const struct mipi_dsi_msg *msg);
|
|
|
|
void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
|
2015-10-13 12:20:47 +05:30
|
|
|
u32 dma_base, u32 len);
|
2015-03-31 14:36:33 -04:00
|
|
|
int msm_dsi_host_enable(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_disable(struct mipi_dsi_host *host);
|
2021-10-02 04:08:30 +03:00
|
|
|
void msm_dsi_host_enable_irq(struct mipi_dsi_host *host);
|
|
|
|
void msm_dsi_host_disable_irq(struct mipi_dsi_host *host);
|
2017-01-07 14:24:38 +05:30
|
|
|
int msm_dsi_host_power_on(struct mipi_dsi_host *host,
|
2018-04-18 12:45:14 -07:00
|
|
|
struct msm_dsi_phy_shared_timings *phy_shared_timings,
|
2021-08-05 20:08:17 +03:00
|
|
|
bool is_bonded_dsi, struct msm_dsi_phy *phy);
|
2015-03-31 14:36:33 -04:00
|
|
|
int msm_dsi_host_power_off(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
|
2018-04-06 17:39:01 +03:00
|
|
|
const struct drm_display_mode *mode);
|
2022-04-06 15:10:29 +05:30
|
|
|
enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
|
|
|
|
const struct drm_display_mode *mode);
|
2019-06-17 16:12:52 -04:00
|
|
|
unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
|
2021-10-25 17:15:36 +02:00
|
|
|
int msm_dsi_host_register(struct mipi_dsi_host *host);
|
2015-03-31 14:36:33 -04:00
|
|
|
void msm_dsi_host_unregister(struct mipi_dsi_host *host);
|
2021-10-06 23:48:27 +03:00
|
|
|
void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
|
|
|
|
struct msm_dsi_phy *src_phy);
|
2015-05-15 13:04:05 -04:00
|
|
|
int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
|
2021-03-31 13:57:21 +03:00
|
|
|
struct msm_dsi_phy *src_phy);
|
2015-07-29 12:14:12 -04:00
|
|
|
void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
|
2017-01-07 14:24:38 +05:30
|
|
|
void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
|
2018-04-18 12:45:14 -07:00
|
|
|
struct msm_dsi_phy_clk_request *clk_req,
|
2021-07-17 15:40:10 +03:00
|
|
|
bool is_bonded_dsi);
|
2015-03-31 14:36:33 -04:00
|
|
|
void msm_dsi_host_destroy(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
|
|
|
|
struct drm_device *dev);
|
|
|
|
int msm_dsi_host_init(struct msm_dsi *msm_dsi);
|
2017-07-28 16:17:04 +05:30
|
|
|
int msm_dsi_runtime_suspend(struct device *dev);
|
|
|
|
int msm_dsi_runtime_resume(struct device *dev);
|
2019-06-30 07:18:31 -07:00
|
|
|
int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host);
|
2025-06-18 16:32:36 +02:00
|
|
|
int dsi_link_clk_set_rate_6g_v2_9(struct msm_dsi_host *msm_host);
|
2019-06-30 07:18:31 -07:00
|
|
|
int dsi_link_clk_set_rate_v2(struct msm_dsi_host *msm_host);
|
2018-05-29 19:50:32 +05:30
|
|
|
int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
|
|
|
|
int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
|
|
|
|
void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
|
|
|
|
void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
|
2023-01-11 16:15:59 -08:00
|
|
|
unsigned long dsi_byte_clk_get_rate(struct mipi_dsi_host *host, bool is_bonded_dsi,
|
|
|
|
const struct drm_display_mode *mode);
|
2018-05-29 19:50:32 +05:30
|
|
|
int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
|
|
|
|
int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
|
|
|
|
void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
|
|
|
|
void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
|
|
|
|
void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
|
2023-10-12 04:29:09 +03:00
|
|
|
void msm_dsi_tx_buf_free(struct mipi_dsi_host *mipi_host);
|
2018-05-29 19:50:32 +05:30
|
|
|
int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
|
|
|
|
int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
|
|
|
|
int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
|
|
|
|
int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
|
2025-06-18 16:32:36 +02:00
|
|
|
int dsi_clk_init_6g_v2_9(struct msm_dsi_host *msm_host);
|
2021-07-17 15:40:10 +03:00
|
|
|
int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
|
|
|
|
int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
|
2021-04-27 03:18:25 +03:00
|
|
|
void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
|
2021-07-21 19:50:32 -07:00
|
|
|
void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
|
2022-07-11 13:04:32 +03:00
|
|
|
struct drm_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
|
2023-08-22 10:42:07 -07:00
|
|
|
bool msm_dsi_host_is_wide_bus_enabled(struct mipi_dsi_host *host);
|
2021-07-21 19:50:32 -07:00
|
|
|
|
2015-03-31 14:36:33 -04:00
|
|
|
/* dsi phy */
|
|
|
|
struct msm_dsi_phy;
|
2016-09-15 14:34:49 +05:30
|
|
|
struct msm_dsi_phy_shared_timings {
|
|
|
|
u32 clk_post;
|
|
|
|
u32 clk_pre;
|
|
|
|
bool clk_pre_inc_by_2;
|
2023-01-18 15:00:27 +02:00
|
|
|
bool byte_intf_clk_div_2;
|
2016-09-15 14:34:49 +05:30
|
|
|
};
|
2017-01-07 14:24:38 +05:30
|
|
|
|
|
|
|
struct msm_dsi_phy_clk_request {
|
|
|
|
unsigned long bitclk_rate;
|
|
|
|
unsigned long escclk_rate;
|
|
|
|
};
|
|
|
|
|
2015-05-15 13:04:06 -04:00
|
|
|
void msm_dsi_phy_driver_register(void);
|
|
|
|
void msm_dsi_phy_driver_unregister(void);
|
2021-03-31 13:57:35 +03:00
|
|
|
int msm_dsi_phy_enable(struct msm_dsi_phy *phy,
|
2021-07-10 00:07:29 +03:00
|
|
|
struct msm_dsi_phy_clk_request *clk_req,
|
|
|
|
struct msm_dsi_phy_shared_timings *shared_timings);
|
2015-08-13 17:45:51 -04:00
|
|
|
void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
|
2016-09-15 14:44:22 +05:30
|
|
|
void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
|
|
|
|
enum msm_dsi_phy_usecase uc);
|
2021-03-31 13:57:24 +03:00
|
|
|
void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy);
|
|
|
|
int msm_dsi_phy_pll_restore_state(struct msm_dsi_phy *phy);
|
2021-04-27 03:18:28 +03:00
|
|
|
void msm_dsi_phy_snapshot(struct msm_disp_state *disp_state, struct msm_dsi_phy *phy);
|
2021-08-05 20:08:17 +03:00
|
|
|
bool msm_dsi_phy_set_continuous_clock(struct msm_dsi_phy *phy, bool enable);
|
2015-05-15 13:04:05 -04:00
|
|
|
|
2015-03-31 14:36:33 -04:00
|
|
|
#endif /* __DSI_CONNECTOR_H__ */
|
|
|
|
|