Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 1 | /* |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame^] | 2 | * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 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 | */ |
| 23 | static 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 Parmar | aa9152d | 2016-05-16 18:02:07 -0700 | [diff] [blame] | 31 | ctrl->ops.setup_cmd_stream = dsi_ctrl_hw_14_setup_cmd_stream; |
Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 32 | 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; |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame^] | 40 | ctrl->ops.ulps_ops.ulps_request = dsi_ctrl_hw_14_ulps_request; |
| 41 | ctrl->ops.ulps_ops.ulps_exit = dsi_ctrl_hw_14_ulps_exit; |
| 42 | ctrl->ops.ulps_ops.wait_for_lane_idle = dsi_ctrl_hw_wait_for_lane_idle; |
| 43 | ctrl->ops.ulps_ops.get_lanes_in_ulps = dsi_ctrl_hw_14_get_lanes_in_ulps; |
Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 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; |
Ajay Singh Parmar | 48ea427 | 2016-06-27 11:44:34 -0700 | [diff] [blame] | 62 | ctrl->ops.reg_dump_to_buffer = dsi_ctrl_hw_14_reg_dump_to_buffer; |
Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /** |
| 66 | * dsi_catalog_20_init() - catalog init for dsi controller v2.0 |
| 67 | */ |
| 68 | static void dsi_catalog_20_init(struct dsi_ctrl_hw *ctrl) |
| 69 | { |
| 70 | set_bit(DSI_CTRL_CPHY, ctrl->feature_map); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * dsi_catalog_ctrl_setup() - return catalog info for dsi controller |
| 75 | * @ctrl: Pointer to DSI controller hw object. |
| 76 | * @version: DSI controller version. |
| 77 | * @index: DSI controller instance ID. |
| 78 | * |
| 79 | * This function setups the catalog information in the dsi_ctrl_hw object. |
| 80 | * |
| 81 | * return: error code for failure and 0 for success. |
| 82 | */ |
| 83 | int dsi_catalog_ctrl_setup(struct dsi_ctrl_hw *ctrl, |
| 84 | enum dsi_ctrl_version version, |
| 85 | u32 index) |
| 86 | { |
| 87 | int rc = 0; |
| 88 | |
| 89 | if (version == DSI_CTRL_VERSION_UNKNOWN || |
| 90 | version >= DSI_CTRL_VERSION_MAX) { |
| 91 | pr_err("Unsupported version: %d\n", version); |
| 92 | return -ENOTSUPP; |
| 93 | } |
| 94 | |
| 95 | ctrl->index = index; |
| 96 | set_bit(DSI_CTRL_VIDEO_TPG, ctrl->feature_map); |
| 97 | set_bit(DSI_CTRL_CMD_TPG, ctrl->feature_map); |
| 98 | set_bit(DSI_CTRL_VARIABLE_REFRESH_RATE, ctrl->feature_map); |
| 99 | set_bit(DSI_CTRL_DYNAMIC_REFRESH, ctrl->feature_map); |
| 100 | set_bit(DSI_CTRL_DESKEW_CALIB, ctrl->feature_map); |
| 101 | set_bit(DSI_CTRL_DPHY, ctrl->feature_map); |
| 102 | |
| 103 | switch (version) { |
| 104 | case DSI_CTRL_VERSION_1_4: |
| 105 | dsi_catalog_14_init(ctrl); |
| 106 | break; |
| 107 | case DSI_CTRL_VERSION_2_0: |
| 108 | dsi_catalog_20_init(ctrl); |
| 109 | break; |
| 110 | default: |
| 111 | return -ENOTSUPP; |
| 112 | } |
| 113 | |
| 114 | return rc; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * dsi_catalog_phy_4_0_init() - catalog init for DSI PHY v4.0 |
| 119 | */ |
| 120 | static void dsi_catalog_phy_4_0_init(struct dsi_phy_hw *phy) |
| 121 | { |
| 122 | phy->ops.regulator_enable = dsi_phy_hw_v4_0_regulator_enable; |
| 123 | phy->ops.regulator_disable = dsi_phy_hw_v4_0_regulator_disable; |
| 124 | phy->ops.enable = dsi_phy_hw_v4_0_enable; |
| 125 | phy->ops.disable = dsi_phy_hw_v4_0_disable; |
| 126 | phy->ops.calculate_timing_params = |
| 127 | dsi_phy_hw_v4_0_calculate_timing_params; |
Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame^] | 128 | phy->ops.phy_idle_on = dsi_phy_hw_v4_0_idle_on; |
| 129 | phy->ops.phy_idle_off = dsi_phy_hw_v4_0_idle_off; |
Ajay Singh Parmar | 0e18781 | 2016-05-16 17:45:31 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /** |
| 133 | * dsi_catalog_phy_setup() - return catalog info for dsi phy hardware |
| 134 | * @ctrl: Pointer to DSI PHY hw object. |
| 135 | * @version: DSI PHY version. |
| 136 | * @index: DSI PHY instance ID. |
| 137 | * |
| 138 | * This function setups the catalog information in the dsi_phy_hw object. |
| 139 | * |
| 140 | * return: error code for failure and 0 for success. |
| 141 | */ |
| 142 | int dsi_catalog_phy_setup(struct dsi_phy_hw *phy, |
| 143 | enum dsi_phy_version version, |
| 144 | u32 index) |
| 145 | { |
| 146 | int rc = 0; |
| 147 | |
| 148 | if (version == DSI_PHY_VERSION_UNKNOWN || |
| 149 | version >= DSI_PHY_VERSION_MAX) { |
| 150 | pr_err("Unsupported version: %d\n", version); |
| 151 | return -ENOTSUPP; |
| 152 | } |
| 153 | |
| 154 | phy->index = index; |
| 155 | set_bit(DSI_PHY_DPHY, phy->feature_map); |
| 156 | |
| 157 | switch (version) { |
| 158 | case DSI_PHY_VERSION_4_0: |
| 159 | dsi_catalog_phy_4_0_init(phy); |
| 160 | break; |
| 161 | case DSI_PHY_VERSION_1_0: |
| 162 | case DSI_PHY_VERSION_2_0: |
| 163 | case DSI_PHY_VERSION_3_0: |
| 164 | default: |
| 165 | return -ENOTSUPP; |
| 166 | } |
| 167 | |
| 168 | return rc; |
| 169 | } |
| 170 | |
| 171 | |