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