blob: 114998fb8fc5bb175aec3ada983e069533dd4bcb [file] [log] [blame]
Ajay Singh Parmar0e187812016-05-16 17:45:31 -07001/*
2 * Copyright (c) 2015-2016, 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
15#define pr_fmt(fmt) "msm-dsi-catalog:[%s] " fmt, __func__
16#include <linux/errno.h>
17
18#include "dsi_catalog.h"
19
20/**
21 * dsi_catalog_14_init() - catalog init for dsi controller v1.4
22 */
23static void dsi_catalog_14_init(struct dsi_ctrl_hw *ctrl)
24{
25 ctrl->ops.host_setup = dsi_ctrl_hw_14_host_setup;
26 ctrl->ops.setup_lane_map = dsi_ctrl_hw_14_setup_lane_map;
27 ctrl->ops.video_engine_en = dsi_ctrl_hw_14_video_engine_en;
28 ctrl->ops.video_engine_setup = dsi_ctrl_hw_14_video_engine_setup;
29 ctrl->ops.set_video_timing = dsi_ctrl_hw_14_set_video_timing;
30 ctrl->ops.cmd_engine_setup = dsi_ctrl_hw_14_cmd_engine_setup;
31 ctrl->ops.ctrl_en = dsi_ctrl_hw_14_ctrl_en;
32 ctrl->ops.cmd_engine_en = dsi_ctrl_hw_14_cmd_engine_en;
33 ctrl->ops.phy_sw_reset = dsi_ctrl_hw_14_phy_sw_reset;
34 ctrl->ops.soft_reset = dsi_ctrl_hw_14_soft_reset;
35 ctrl->ops.kickoff_command = dsi_ctrl_hw_14_kickoff_command;
36 ctrl->ops.kickoff_fifo_command = dsi_ctrl_hw_14_kickoff_fifo_command;
37 ctrl->ops.reset_cmd_fifo = dsi_ctrl_hw_14_reset_cmd_fifo;
38 ctrl->ops.trigger_command_dma = dsi_ctrl_hw_14_trigger_command_dma;
39 ctrl->ops.ulps_request = dsi_ctrl_hw_14_ulps_request;
40 ctrl->ops.ulps_exit = dsi_ctrl_hw_14_ulps_exit;
41 ctrl->ops.clear_ulps_request = dsi_ctrl_hw_14_clear_ulps_request;
42 ctrl->ops.get_lanes_in_ulps = dsi_ctrl_hw_14_get_lanes_in_ulps;
43 ctrl->ops.clamp_enable = dsi_ctrl_hw_14_clamp_enable;
44 ctrl->ops.clamp_disable = dsi_ctrl_hw_14_clamp_disable;
45 ctrl->ops.get_interrupt_status = dsi_ctrl_hw_14_get_interrupt_status;
46 ctrl->ops.get_error_status = dsi_ctrl_hw_14_get_error_status;
47 ctrl->ops.clear_error_status = dsi_ctrl_hw_14_clear_error_status;
48 ctrl->ops.clear_interrupt_status =
49 dsi_ctrl_hw_14_clear_interrupt_status;
50 ctrl->ops.enable_status_interrupts =
51 dsi_ctrl_hw_14_enable_status_interrupts;
52 ctrl->ops.enable_error_interrupts =
53 dsi_ctrl_hw_14_enable_error_interrupts;
54 ctrl->ops.video_test_pattern_setup =
55 dsi_ctrl_hw_14_video_test_pattern_setup;
56 ctrl->ops.cmd_test_pattern_setup =
57 dsi_ctrl_hw_14_cmd_test_pattern_setup;
58 ctrl->ops.test_pattern_enable = dsi_ctrl_hw_14_test_pattern_enable;
59 ctrl->ops.trigger_cmd_test_pattern =
60 dsi_ctrl_hw_14_trigger_cmd_test_pattern;
61}
62
63/**
64 * dsi_catalog_20_init() - catalog init for dsi controller v2.0
65 */
66static void dsi_catalog_20_init(struct dsi_ctrl_hw *ctrl)
67{
68 set_bit(DSI_CTRL_CPHY, ctrl->feature_map);
69}
70
71/**
72 * dsi_catalog_ctrl_setup() - return catalog info for dsi controller
73 * @ctrl: Pointer to DSI controller hw object.
74 * @version: DSI controller version.
75 * @index: DSI controller instance ID.
76 *
77 * This function setups the catalog information in the dsi_ctrl_hw object.
78 *
79 * return: error code for failure and 0 for success.
80 */
81int dsi_catalog_ctrl_setup(struct dsi_ctrl_hw *ctrl,
82 enum dsi_ctrl_version version,
83 u32 index)
84{
85 int rc = 0;
86
87 if (version == DSI_CTRL_VERSION_UNKNOWN ||
88 version >= DSI_CTRL_VERSION_MAX) {
89 pr_err("Unsupported version: %d\n", version);
90 return -ENOTSUPP;
91 }
92
93 ctrl->index = index;
94 set_bit(DSI_CTRL_VIDEO_TPG, ctrl->feature_map);
95 set_bit(DSI_CTRL_CMD_TPG, ctrl->feature_map);
96 set_bit(DSI_CTRL_VARIABLE_REFRESH_RATE, ctrl->feature_map);
97 set_bit(DSI_CTRL_DYNAMIC_REFRESH, ctrl->feature_map);
98 set_bit(DSI_CTRL_DESKEW_CALIB, ctrl->feature_map);
99 set_bit(DSI_CTRL_DPHY, ctrl->feature_map);
100
101 switch (version) {
102 case DSI_CTRL_VERSION_1_4:
103 dsi_catalog_14_init(ctrl);
104 break;
105 case DSI_CTRL_VERSION_2_0:
106 dsi_catalog_20_init(ctrl);
107 break;
108 default:
109 return -ENOTSUPP;
110 }
111
112 return rc;
113}
114
115/**
116 * dsi_catalog_phy_4_0_init() - catalog init for DSI PHY v4.0
117 */
118static void dsi_catalog_phy_4_0_init(struct dsi_phy_hw *phy)
119{
120 phy->ops.regulator_enable = dsi_phy_hw_v4_0_regulator_enable;
121 phy->ops.regulator_disable = dsi_phy_hw_v4_0_regulator_disable;
122 phy->ops.enable = dsi_phy_hw_v4_0_enable;
123 phy->ops.disable = dsi_phy_hw_v4_0_disable;
124 phy->ops.calculate_timing_params =
125 dsi_phy_hw_v4_0_calculate_timing_params;
126}
127
128/**
129 * dsi_catalog_phy_setup() - return catalog info for dsi phy hardware
130 * @ctrl: Pointer to DSI PHY hw object.
131 * @version: DSI PHY version.
132 * @index: DSI PHY instance ID.
133 *
134 * This function setups the catalog information in the dsi_phy_hw object.
135 *
136 * return: error code for failure and 0 for success.
137 */
138int dsi_catalog_phy_setup(struct dsi_phy_hw *phy,
139 enum dsi_phy_version version,
140 u32 index)
141{
142 int rc = 0;
143
144 if (version == DSI_PHY_VERSION_UNKNOWN ||
145 version >= DSI_PHY_VERSION_MAX) {
146 pr_err("Unsupported version: %d\n", version);
147 return -ENOTSUPP;
148 }
149
150 phy->index = index;
151 set_bit(DSI_PHY_DPHY, phy->feature_map);
152
153 switch (version) {
154 case DSI_PHY_VERSION_4_0:
155 dsi_catalog_phy_4_0_init(phy);
156 break;
157 case DSI_PHY_VERSION_1_0:
158 case DSI_PHY_VERSION_2_0:
159 case DSI_PHY_VERSION_3_0:
160 default:
161 return -ENOTSUPP;
162 }
163
164 return rc;
165}
166
167