2015-04-01 02:36:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
|
|
* only version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DSI_CONNECTOR_H__
|
|
|
|
#define __DSI_CONNECTOR_H__
|
|
|
|
|
2015-05-16 01:04:06 +08:00
|
|
|
#include <linux/of_platform.h>
|
2015-04-01 02:36:33 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
#include "drm_crtc.h"
|
|
|
|
#include "drm_mipi_dsi.h"
|
|
|
|
#include "drm_panel.h"
|
|
|
|
|
|
|
|
#include "msm_drv.h"
|
|
|
|
|
|
|
|
#define DSI_0 0
|
|
|
|
#define DSI_1 1
|
|
|
|
#define DSI_MAX 2
|
|
|
|
|
2015-05-16 01:04:05 +08:00
|
|
|
enum msm_dsi_phy_type {
|
|
|
|
MSM_DSI_PHY_28NM_HPM,
|
|
|
|
MSM_DSI_PHY_28NM_LP,
|
2015-06-18 22:14:21 +08:00
|
|
|
MSM_DSI_PHY_20NM,
|
2015-10-14 14:30:34 +08:00
|
|
|
MSM_DSI_PHY_28NM_8960,
|
2015-05-16 01:04:05 +08:00
|
|
|
MSM_DSI_PHY_MAX
|
|
|
|
};
|
|
|
|
|
2015-05-16 01:04:06 +08:00
|
|
|
#define DSI_DEV_REGULATOR_MAX 8
|
2015-10-09 17:51:12 +08:00
|
|
|
#define DSI_BUS_CLK_MAX 4
|
2015-05-16 01:04:06 +08:00
|
|
|
|
|
|
|
/* Regulators for DSI devices */
|
|
|
|
struct dsi_reg_entry {
|
|
|
|
char name[32];
|
|
|
|
int enable_load;
|
|
|
|
int disable_load;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dsi_reg_config {
|
|
|
|
int num;
|
|
|
|
struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
|
|
|
|
};
|
|
|
|
|
2015-04-01 02:36:33 +08:00
|
|
|
struct msm_dsi {
|
|
|
|
struct drm_device *dev;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
|
2015-07-31 16:36:10 +08:00
|
|
|
/* connector managed by us when we're connected to a drm_panel */
|
2015-04-01 02:36:33 +08:00
|
|
|
struct drm_connector *connector;
|
2015-07-31 16:36:10 +08:00
|
|
|
/* internal dsi bridge attached to MDP interface */
|
2015-04-01 02:36:33 +08:00
|
|
|
struct drm_bridge *bridge;
|
|
|
|
|
|
|
|
struct mipi_dsi_host *host;
|
|
|
|
struct msm_dsi_phy *phy;
|
2015-07-31 16:36:10 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* panel/external_bridge connected to dsi bridge output, only one of the
|
|
|
|
* two can be valid at a time
|
|
|
|
*/
|
2015-04-01 02:36:33 +08:00
|
|
|
struct drm_panel *panel;
|
2015-07-31 16:36:10 +08:00
|
|
|
struct drm_bridge *external_bridge;
|
2015-08-03 16:35:45 +08:00
|
|
|
unsigned long device_flags;
|
2015-05-16 01:04:05 +08:00
|
|
|
|
2015-05-16 01:04:06 +08:00
|
|
|
struct device *phy_dev;
|
2015-04-01 02:36:33 +08:00
|
|
|
bool phy_enabled;
|
|
|
|
|
|
|
|
/* the encoders we are hooked to (outside of dsi block) */
|
|
|
|
struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
|
|
|
|
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* dsi manager */
|
|
|
|
struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
|
|
|
|
void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
|
|
|
|
struct drm_connector *msm_dsi_manager_connector_init(u8 id);
|
2015-07-31 16:36:10 +08:00
|
|
|
struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
|
2015-04-01 02:36:33 +08:00
|
|
|
int msm_dsi_manager_phy_enable(int id,
|
|
|
|
const unsigned long bit_rate, const unsigned long esc_rate,
|
|
|
|
u32 *clk_pre, u32 *clk_post);
|
|
|
|
void msm_dsi_manager_phy_disable(int id);
|
|
|
|
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
|
2015-10-13 14:50:47 +08:00
|
|
|
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
|
2015-04-01 02:36:33 +08:00
|
|
|
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
|
|
|
|
void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
|
|
|
|
|
|
|
|
/* msm dsi */
|
2015-08-03 16:38:33 +08:00
|
|
|
static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
|
|
|
|
{
|
2015-07-31 16:36:10 +08:00
|
|
|
return msm_dsi->panel || msm_dsi->external_bridge;
|
2015-08-03 16:38:33 +08:00
|
|
|
}
|
|
|
|
|
2015-04-01 02:36:33 +08:00
|
|
|
struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
|
|
|
|
|
2015-05-16 01:04:05 +08:00
|
|
|
/* dsi pll */
|
|
|
|
struct msm_dsi_pll;
|
|
|
|
#ifdef CONFIG_DRM_MSM_DSI_PLL
|
|
|
|
struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
|
|
|
|
enum msm_dsi_phy_type type, int dsi_id);
|
|
|
|
void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
|
|
|
|
int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
|
|
|
|
struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
|
2015-07-03 22:09:46 +08:00
|
|
|
void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
|
|
|
|
int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
|
2015-05-16 01:04:05 +08:00
|
|
|
#else
|
|
|
|
static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
|
|
|
|
enum msm_dsi_phy_type type, int id) {
|
|
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
}
|
|
|
|
static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
|
|
|
|
struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2015-07-03 22:09:46 +08:00
|
|
|
static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-16 01:04:05 +08:00
|
|
|
#endif
|
|
|
|
|
2015-04-01 02:36:33 +08:00
|
|
|
/* dsi host */
|
|
|
|
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 14:50:47 +08:00
|
|
|
u32 dma_base, u32 len);
|
2015-04-01 02:36:33 +08:00
|
|
|
int msm_dsi_host_enable(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_disable(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_power_on(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_power_off(struct mipi_dsi_host *host);
|
|
|
|
int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
|
|
|
|
struct drm_display_mode *mode);
|
|
|
|
struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
|
|
|
|
unsigned long *panel_flags);
|
2015-07-31 16:36:10 +08:00
|
|
|
struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
|
2015-04-01 02:36:33 +08:00
|
|
|
int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
|
|
|
|
void msm_dsi_host_unregister(struct mipi_dsi_host *host);
|
2015-05-16 01:04:05 +08:00
|
|
|
int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
|
|
|
|
struct msm_dsi_pll *src_pll);
|
2015-04-01 02:36:33 +08: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);
|
|
|
|
|
|
|
|
/* dsi phy */
|
|
|
|
struct msm_dsi_phy;
|
2015-05-16 01:04:06 +08:00
|
|
|
void msm_dsi_phy_driver_register(void);
|
|
|
|
void msm_dsi_phy_driver_unregister(void);
|
2015-06-11 01:18:17 +08:00
|
|
|
int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
|
2015-04-01 02:36:33 +08:00
|
|
|
const unsigned long bit_rate, const unsigned long esc_rate);
|
2015-08-14 05:45:51 +08:00
|
|
|
void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
|
2015-04-01 02:36:33 +08:00
|
|
|
void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
|
|
|
|
u32 *clk_pre, u32 *clk_post);
|
2015-05-16 01:04:05 +08:00
|
|
|
struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
|
|
|
|
|
2015-04-01 02:36:33 +08:00
|
|
|
#endif /* __DSI_CONNECTOR_H__ */
|
|
|
|
|