Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #ifndef _DP_PARSER_H_
0007 #define _DP_PARSER_H_
0008 
0009 #include <linux/platform_device.h>
0010 #include <linux/phy/phy.h>
0011 #include <linux/phy/phy-dp.h>
0012 
0013 #include "msm_drv.h"
0014 
0015 #define DP_LABEL "MDSS DP DISPLAY"
0016 #define DP_MAX_PIXEL_CLK_KHZ    675000
0017 #define DP_MAX_NUM_DP_LANES 4
0018 
0019 enum dp_pm_type {
0020     DP_CORE_PM,
0021     DP_CTRL_PM,
0022     DP_STREAM_PM,
0023     DP_PHY_PM,
0024     DP_MAX_PM
0025 };
0026 
0027 struct dss_io_region {
0028     size_t len;
0029     void __iomem *base;
0030 };
0031 
0032 struct dss_io_data {
0033     struct dss_io_region ahb;
0034     struct dss_io_region aux;
0035     struct dss_io_region link;
0036     struct dss_io_region p0;
0037 };
0038 
0039 static inline const char *dp_parser_pm_name(enum dp_pm_type module)
0040 {
0041     switch (module) {
0042     case DP_CORE_PM:    return "DP_CORE_PM";
0043     case DP_CTRL_PM:    return "DP_CTRL_PM";
0044     case DP_STREAM_PM:  return "DP_STREAM_PM";
0045     case DP_PHY_PM:     return "DP_PHY_PM";
0046     default:        return "???";
0047     }
0048 }
0049 
0050 /**
0051  * struct dp_display_data  - display related device tree data.
0052  *
0053  * @ctrl_node: referece to controller device
0054  * @phy_node:  reference to phy device
0055  * @is_active: is the controller currently active
0056  * @name: name of the display
0057  * @display_type: type of the display
0058  */
0059 struct dp_display_data {
0060     struct device_node *ctrl_node;
0061     struct device_node *phy_node;
0062     bool is_active;
0063     const char *name;
0064     const char *display_type;
0065 };
0066 
0067 /**
0068  * struct dp_ctrl_resource - controller's IO related data
0069  *
0070  * @dp_controller: Display Port controller mapped memory address
0071  * @phy_io: phy's mapped memory address
0072  */
0073 struct dp_io {
0074     struct dss_io_data dp_controller;
0075     struct phy *phy;
0076     union phy_configure_opts phy_opts;
0077 };
0078 
0079 /**
0080  * struct dp_pinctrl - DP's pin control
0081  *
0082  * @pin: pin-controller's instance
0083  * @state_active: active state pin control
0084  * @state_hpd_active: hpd active state pin control
0085  * @state_suspend: suspend state pin control
0086  */
0087 struct dp_pinctrl {
0088     struct pinctrl *pin;
0089     struct pinctrl_state *state_active;
0090     struct pinctrl_state *state_hpd_active;
0091     struct pinctrl_state *state_suspend;
0092 };
0093 
0094 /* Regulators for DP devices */
0095 struct dp_reg_entry {
0096     char name[32];
0097     int enable_load;
0098     int disable_load;
0099 };
0100 
0101 struct dss_module_power {
0102     unsigned int num_clk;
0103     struct clk_bulk_data *clocks;
0104 };
0105 
0106 /**
0107  * struct dp_parser - DP parser's data exposed to clients
0108  *
0109  * @pdev: platform data of the client
0110  * @mp: gpio, regulator and clock related data
0111  * @pinctrl: pin-control related data
0112  * @disp_data: controller's display related data
0113  * @parse: function to be called by client to parse device tree.
0114  */
0115 struct dp_parser {
0116     struct platform_device *pdev;
0117     struct dss_module_power mp[DP_MAX_PM];
0118     struct dp_pinctrl pinctrl;
0119     struct dp_io io;
0120     struct dp_display_data disp_data;
0121     u32 max_dp_lanes;
0122     struct drm_bridge *next_bridge;
0123 
0124     int (*parse)(struct dp_parser *parser);
0125 };
0126 
0127 /**
0128  * dp_parser_get() - get the DP's device tree parser module
0129  *
0130  * @pdev: platform data of the client
0131  * return: pointer to dp_parser structure.
0132  *
0133  * This function provides client capability to parse the
0134  * device tree and populate the data structures. The data
0135  * related to clock, regulators, pin-control and other
0136  * can be parsed using this module.
0137  */
0138 struct dp_parser *dp_parser_get(struct platform_device *pdev);
0139 
0140 /**
0141  * dp_parser_find_next_bridge() - find an additional bridge to DP
0142  *
0143  * @parser: dp_parser data from client
0144  *
0145  * This function is used to find any additional bridge attached to
0146  * the DP controller. The eDP interface requires a panel bridge.
0147  *
0148  * Return: 0 if able to get the bridge, otherwise negative errno for failure.
0149  */
0150 int dp_parser_find_next_bridge(struct dp_parser *parser);
0151 
0152 #endif