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