Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1 | /* |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 2 | * Copyright (c) 2014 The Linux Foundation. All rights reserved. |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 3 | * Copyright (C) 2013 Red Hat |
| 4 | * Author: Rob Clark <robdclark@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
Rob Clark | f6a8eac | 2014-11-17 15:28:07 -0500 | [diff] [blame] | 19 | #include <linux/of_irq.h> |
Archit Taneja | 1fd6a44 | 2015-10-30 12:35:55 +0530 | [diff] [blame] | 20 | #include <linux/of_gpio.h> |
| 21 | |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 22 | #include <sound/hdmi-codec.h> |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 23 | #include "hdmi.h" |
| 24 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 25 | void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 26 | { |
| 27 | uint32_t ctrl = 0; |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 28 | unsigned long flags; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 29 | |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 30 | spin_lock_irqsave(&hdmi->reg_lock, flags); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 31 | if (power_on) { |
| 32 | ctrl |= HDMI_CTRL_ENABLE; |
| 33 | if (!hdmi->hdmi_mode) { |
| 34 | ctrl |= HDMI_CTRL_HDMI; |
| 35 | hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); |
| 36 | ctrl &= ~HDMI_CTRL_HDMI; |
| 37 | } else { |
| 38 | ctrl |= HDMI_CTRL_HDMI; |
| 39 | } |
| 40 | } else { |
| 41 | ctrl = HDMI_CTRL_HDMI; |
| 42 | } |
| 43 | |
| 44 | hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 45 | spin_unlock_irqrestore(&hdmi->reg_lock, flags); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 46 | DBG("HDMI Core: %s, HDMI_CTRL=0x%08x", |
| 47 | power_on ? "Enable" : "Disable", ctrl); |
| 48 | } |
| 49 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 50 | static irqreturn_t msm_hdmi_irq(int irq, void *dev_id) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 51 | { |
| 52 | struct hdmi *hdmi = dev_id; |
| 53 | |
| 54 | /* Process HPD: */ |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 55 | msm_hdmi_connector_irq(hdmi->connector); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 56 | |
| 57 | /* Process DDC: */ |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 58 | msm_hdmi_i2c_irq(hdmi->i2c); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 59 | |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 60 | /* Process HDCP: */ |
| 61 | if (hdmi->hdcp_ctrl) |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 62 | msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl); |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 63 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 64 | /* TODO audio.. */ |
| 65 | |
| 66 | return IRQ_HANDLED; |
| 67 | } |
| 68 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 69 | static void msm_hdmi_destroy(struct hdmi *hdmi) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 70 | { |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 71 | /* |
| 72 | * at this point, hpd has been disabled, |
| 73 | * after flush workq, it's safe to deinit hdcp |
| 74 | */ |
| 75 | if (hdmi->workq) { |
| 76 | flush_workqueue(hdmi->workq); |
| 77 | destroy_workqueue(hdmi->workq); |
| 78 | } |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 79 | msm_hdmi_hdcp_destroy(hdmi); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 80 | |
Archit Taneja | e00012b | 2016-02-25 11:22:40 +0530 | [diff] [blame] | 81 | if (hdmi->phy_dev) { |
| 82 | put_device(hdmi->phy_dev); |
| 83 | hdmi->phy = NULL; |
| 84 | hdmi->phy_dev = NULL; |
| 85 | } |
| 86 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 87 | if (hdmi->i2c) |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 88 | msm_hdmi_i2c_destroy(hdmi->i2c); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 89 | |
Rob Clark | c0c0d9e | 2013-12-11 14:44:02 -0500 | [diff] [blame] | 90 | platform_set_drvdata(hdmi->pdev, NULL); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 91 | } |
| 92 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 93 | static int msm_hdmi_get_phy(struct hdmi *hdmi) |
Archit Taneja | e00012b | 2016-02-25 11:22:40 +0530 | [diff] [blame] | 94 | { |
| 95 | struct platform_device *pdev = hdmi->pdev; |
| 96 | struct platform_device *phy_pdev; |
| 97 | struct device_node *phy_node; |
| 98 | |
| 99 | phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0); |
| 100 | if (!phy_node) { |
| 101 | dev_err(&pdev->dev, "cannot find phy device\n"); |
| 102 | return -ENXIO; |
| 103 | } |
| 104 | |
| 105 | phy_pdev = of_find_device_by_node(phy_node); |
| 106 | if (phy_pdev) |
| 107 | hdmi->phy = platform_get_drvdata(phy_pdev); |
| 108 | |
| 109 | of_node_put(phy_node); |
| 110 | |
| 111 | if (!phy_pdev || !hdmi->phy) { |
| 112 | dev_err(&pdev->dev, "phy driver is not ready\n"); |
| 113 | return -EPROBE_DEFER; |
| 114 | } |
| 115 | |
| 116 | hdmi->phy_dev = get_device(&phy_pdev->dev); |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 121 | /* construct hdmi at bind/probe time, grab all the resources. If |
| 122 | * we are to EPROBE_DEFER we want to do it here, rather than later |
| 123 | * at modeset_init() time |
| 124 | */ |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 125 | static struct hdmi *msm_hdmi_init(struct platform_device *pdev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 126 | { |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 127 | struct hdmi_platform_config *config = pdev->dev.platform_data; |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 128 | struct hdmi *hdmi = NULL; |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 129 | struct resource *res; |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 130 | int i, ret; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 131 | |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 132 | hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 133 | if (!hdmi) { |
| 134 | ret = -ENOMEM; |
| 135 | goto fail; |
| 136 | } |
| 137 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 138 | hdmi->pdev = pdev; |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 139 | hdmi->config = config; |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 140 | spin_lock_init(&hdmi->reg_lock); |
Rob Clark | c0c0d9e | 2013-12-11 14:44:02 -0500 | [diff] [blame] | 141 | |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 142 | hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI"); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 143 | if (IS_ERR(hdmi->mmio)) { |
| 144 | ret = PTR_ERR(hdmi->mmio); |
| 145 | goto fail; |
| 146 | } |
| 147 | |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 148 | /* HDCP needs physical address of hdmi register */ |
| 149 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 150 | config->mmio_name); |
| 151 | hdmi->mmio_phy_addr = res->start; |
| 152 | |
| 153 | hdmi->qfprom_mmio = msm_ioremap(pdev, |
| 154 | config->qfprom_mmio_name, "HDMI_QFPROM"); |
| 155 | if (IS_ERR(hdmi->qfprom_mmio)) { |
| 156 | dev_info(&pdev->dev, "can't find qfprom resource\n"); |
| 157 | hdmi->qfprom_mmio = NULL; |
| 158 | } |
| 159 | |
Stephane Viau | 447fa52 | 2015-01-13 14:33:40 -0500 | [diff] [blame] | 160 | hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) * |
| 161 | config->hpd_reg_cnt, GFP_KERNEL); |
| 162 | if (!hdmi->hpd_regs) { |
| 163 | ret = -ENOMEM; |
| 164 | goto fail; |
| 165 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 166 | for (i = 0; i < config->hpd_reg_cnt; i++) { |
| 167 | struct regulator *reg; |
| 168 | |
Rob Clark | 3e87599 | 2014-08-01 13:08:11 -0400 | [diff] [blame] | 169 | reg = devm_regulator_get(&pdev->dev, |
Rob Clark | 41e6977 | 2013-12-15 16:23:05 -0500 | [diff] [blame] | 170 | config->hpd_reg_names[i]); |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 171 | if (IS_ERR(reg)) { |
| 172 | ret = PTR_ERR(reg); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 173 | dev_err(&pdev->dev, "failed to get hpd regulator: %s (%d)\n", |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 174 | config->hpd_reg_names[i], ret); |
| 175 | goto fail; |
| 176 | } |
| 177 | |
| 178 | hdmi->hpd_regs[i] = reg; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 179 | } |
| 180 | |
Stephane Viau | 447fa52 | 2015-01-13 14:33:40 -0500 | [diff] [blame] | 181 | hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) * |
| 182 | config->pwr_reg_cnt, GFP_KERNEL); |
| 183 | if (!hdmi->pwr_regs) { |
| 184 | ret = -ENOMEM; |
| 185 | goto fail; |
| 186 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 187 | for (i = 0; i < config->pwr_reg_cnt; i++) { |
| 188 | struct regulator *reg; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 189 | |
Rob Clark | 3e87599 | 2014-08-01 13:08:11 -0400 | [diff] [blame] | 190 | reg = devm_regulator_get(&pdev->dev, |
Rob Clark | 41e6977 | 2013-12-15 16:23:05 -0500 | [diff] [blame] | 191 | config->pwr_reg_names[i]); |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 192 | if (IS_ERR(reg)) { |
| 193 | ret = PTR_ERR(reg); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 194 | dev_err(&pdev->dev, "failed to get pwr regulator: %s (%d)\n", |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 195 | config->pwr_reg_names[i], ret); |
| 196 | goto fail; |
| 197 | } |
| 198 | |
| 199 | hdmi->pwr_regs[i] = reg; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 200 | } |
| 201 | |
Stephane Viau | 447fa52 | 2015-01-13 14:33:40 -0500 | [diff] [blame] | 202 | hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) * |
| 203 | config->hpd_clk_cnt, GFP_KERNEL); |
| 204 | if (!hdmi->hpd_clks) { |
| 205 | ret = -ENOMEM; |
| 206 | goto fail; |
| 207 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 208 | for (i = 0; i < config->hpd_clk_cnt; i++) { |
| 209 | struct clk *clk; |
| 210 | |
| 211 | clk = devm_clk_get(&pdev->dev, config->hpd_clk_names[i]); |
| 212 | if (IS_ERR(clk)) { |
| 213 | ret = PTR_ERR(clk); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 214 | dev_err(&pdev->dev, "failed to get hpd clk: %s (%d)\n", |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 215 | config->hpd_clk_names[i], ret); |
| 216 | goto fail; |
| 217 | } |
| 218 | |
| 219 | hdmi->hpd_clks[i] = clk; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 220 | } |
| 221 | |
Stephane Viau | 447fa52 | 2015-01-13 14:33:40 -0500 | [diff] [blame] | 222 | hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) * |
| 223 | config->pwr_clk_cnt, GFP_KERNEL); |
| 224 | if (!hdmi->pwr_clks) { |
| 225 | ret = -ENOMEM; |
| 226 | goto fail; |
| 227 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 228 | for (i = 0; i < config->pwr_clk_cnt; i++) { |
| 229 | struct clk *clk; |
| 230 | |
| 231 | clk = devm_clk_get(&pdev->dev, config->pwr_clk_names[i]); |
| 232 | if (IS_ERR(clk)) { |
| 233 | ret = PTR_ERR(clk); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 234 | dev_err(&pdev->dev, "failed to get pwr clk: %s (%d)\n", |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 235 | config->pwr_clk_names[i], ret); |
| 236 | goto fail; |
| 237 | } |
| 238 | |
| 239 | hdmi->pwr_clks[i] = clk; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 240 | } |
| 241 | |
Archit Taneja | 6ed9ed4 | 2017-07-28 16:17:02 +0530 | [diff] [blame^] | 242 | pm_runtime_enable(&pdev->dev); |
| 243 | |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 244 | hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); |
| 245 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 246 | hdmi->i2c = msm_hdmi_i2c_init(hdmi); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 247 | if (IS_ERR(hdmi->i2c)) { |
| 248 | ret = PTR_ERR(hdmi->i2c); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 249 | dev_err(&pdev->dev, "failed to get i2c: %d\n", ret); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 250 | hdmi->i2c = NULL; |
| 251 | goto fail; |
| 252 | } |
| 253 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 254 | ret = msm_hdmi_get_phy(hdmi); |
Archit Taneja | e00012b | 2016-02-25 11:22:40 +0530 | [diff] [blame] | 255 | if (ret) { |
| 256 | dev_err(&pdev->dev, "failed to get phy\n"); |
| 257 | goto fail; |
| 258 | } |
| 259 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 260 | hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi); |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 261 | if (IS_ERR(hdmi->hdcp_ctrl)) { |
| 262 | dev_warn(&pdev->dev, "failed to init hdcp: disabled\n"); |
| 263 | hdmi->hdcp_ctrl = NULL; |
| 264 | } |
| 265 | |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 266 | return hdmi; |
| 267 | |
| 268 | fail: |
| 269 | if (hdmi) |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 270 | msm_hdmi_destroy(hdmi); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 271 | |
| 272 | return ERR_PTR(ret); |
| 273 | } |
| 274 | |
| 275 | /* Second part of initialization, the drm/kms level modeset_init, |
| 276 | * constructs/initializes mode objects, etc, is called from master |
| 277 | * driver (not hdmi sub-device's probe/bind!) |
| 278 | * |
| 279 | * Any resource (regulator/clk/etc) which could be missing at boot |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 280 | * should be handled in msm_hdmi_init() so that failure happens from |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 281 | * hdmi sub-device's probe. |
| 282 | */ |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 283 | int msm_hdmi_modeset_init(struct hdmi *hdmi, |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 284 | struct drm_device *dev, struct drm_encoder *encoder) |
| 285 | { |
| 286 | struct msm_drm_private *priv = dev->dev_private; |
| 287 | struct platform_device *pdev = hdmi->pdev; |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 288 | int ret; |
| 289 | |
| 290 | hdmi->dev = dev; |
| 291 | hdmi->encoder = encoder; |
| 292 | |
| 293 | hdmi_audio_infoframe_init(&hdmi->audio.infoframe); |
| 294 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 295 | hdmi->bridge = msm_hdmi_bridge_init(hdmi); |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 296 | if (IS_ERR(hdmi->bridge)) { |
| 297 | ret = PTR_ERR(hdmi->bridge); |
| 298 | dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret); |
| 299 | hdmi->bridge = NULL; |
| 300 | goto fail; |
| 301 | } |
| 302 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 303 | hdmi->connector = msm_hdmi_connector_init(hdmi); |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 304 | if (IS_ERR(hdmi->connector)) { |
| 305 | ret = PTR_ERR(hdmi->connector); |
| 306 | dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret); |
| 307 | hdmi->connector = NULL; |
| 308 | goto fail; |
| 309 | } |
| 310 | |
Rob Clark | f6a8eac | 2014-11-17 15:28:07 -0500 | [diff] [blame] | 311 | hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); |
| 312 | if (hdmi->irq < 0) { |
| 313 | ret = hdmi->irq; |
| 314 | dev_err(dev->dev, "failed to get irq: %d\n", ret); |
| 315 | goto fail; |
| 316 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 317 | |
Rob Clark | f6a8eac | 2014-11-17 15:28:07 -0500 | [diff] [blame] | 318 | ret = devm_request_irq(&pdev->dev, hdmi->irq, |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 319 | msm_hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, |
Rob Clark | f6a8eac | 2014-11-17 15:28:07 -0500 | [diff] [blame] | 320 | "hdmi_isr", hdmi); |
| 321 | if (ret < 0) { |
| 322 | dev_err(dev->dev, "failed to request IRQ%u: %d\n", |
| 323 | hdmi->irq, ret); |
| 324 | goto fail; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 325 | } |
| 326 | |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 327 | encoder->bridge = hdmi->bridge; |
| 328 | |
| 329 | priv->bridges[priv->num_bridges++] = hdmi->bridge; |
| 330 | priv->connectors[priv->num_connectors++] = hdmi->connector; |
| 331 | |
Rob Clark | c0c0d9e | 2013-12-11 14:44:02 -0500 | [diff] [blame] | 332 | platform_set_drvdata(pdev, hdmi); |
| 333 | |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 334 | return 0; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 335 | |
| 336 | fail: |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 337 | /* bridge is normally destroyed by drm: */ |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 338 | if (hdmi->bridge) { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 339 | msm_hdmi_bridge_destroy(hdmi->bridge); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 340 | hdmi->bridge = NULL; |
| 341 | } |
| 342 | if (hdmi->connector) { |
| 343 | hdmi->connector->funcs->destroy(hdmi->connector); |
| 344 | hdmi->connector = NULL; |
Rob Clark | a3376e3 | 2013-08-30 13:02:15 -0400 | [diff] [blame] | 345 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 346 | |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 347 | return ret; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | /* |
| 351 | * The hdmi device: |
| 352 | */ |
| 353 | |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 354 | #define HDMI_CFG(item, entry) \ |
| 355 | .item ## _names = item ##_names_ ## entry, \ |
| 356 | .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry) |
| 357 | |
Stephane Viau | 0afbe59 | 2015-09-15 08:41:49 -0400 | [diff] [blame] | 358 | static const char *pwr_reg_names_none[] = {}; |
| 359 | static const char *hpd_reg_names_none[] = {}; |
| 360 | |
Archit Taneja | ba3d7bf | 2016-02-25 11:22:41 +0530 | [diff] [blame] | 361 | static struct hdmi_platform_config hdmi_tx_8660_config; |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 362 | |
| 363 | static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"}; |
| 364 | static const char *hpd_clk_names_8960[] = {"core_clk", "master_iface_clk", "slave_iface_clk"}; |
| 365 | |
| 366 | static struct hdmi_platform_config hdmi_tx_8960_config = { |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 367 | HDMI_CFG(hpd_reg, 8960), |
| 368 | HDMI_CFG(hpd_clk, 8960), |
| 369 | }; |
| 370 | |
| 371 | static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"}; |
| 372 | static const char *hpd_reg_names_8x74[] = {"hpd-gdsc", "hpd-5v"}; |
| 373 | static const char *pwr_clk_names_8x74[] = {"extp_clk", "alt_iface_clk"}; |
| 374 | static const char *hpd_clk_names_8x74[] = {"iface_clk", "core_clk", "mdp_core_clk"}; |
| 375 | static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0}; |
| 376 | |
Rob Clark | 5cf3a4553 | 2015-07-27 20:52:50 -0400 | [diff] [blame] | 377 | static struct hdmi_platform_config hdmi_tx_8974_config = { |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 378 | HDMI_CFG(pwr_reg, 8x74), |
| 379 | HDMI_CFG(hpd_reg, 8x74), |
| 380 | HDMI_CFG(pwr_clk, 8x74), |
| 381 | HDMI_CFG(hpd_clk, 8x74), |
| 382 | .hpd_freq = hpd_clk_freq_8x74, |
| 383 | }; |
| 384 | |
| 385 | static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"}; |
| 386 | |
| 387 | static struct hdmi_platform_config hdmi_tx_8084_config = { |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 388 | HDMI_CFG(pwr_reg, 8x74), |
| 389 | HDMI_CFG(hpd_reg, 8084), |
| 390 | HDMI_CFG(pwr_clk, 8x74), |
| 391 | HDMI_CFG(hpd_clk, 8x74), |
| 392 | .hpd_freq = hpd_clk_freq_8x74, |
| 393 | }; |
| 394 | |
Rob Clark | 5cf3a4553 | 2015-07-27 20:52:50 -0400 | [diff] [blame] | 395 | static struct hdmi_platform_config hdmi_tx_8994_config = { |
Stephane Viau | 3a84f84 | 2015-06-19 16:04:47 -0400 | [diff] [blame] | 396 | HDMI_CFG(pwr_reg, 8x74), |
Stephane Viau | 0afbe59 | 2015-09-15 08:41:49 -0400 | [diff] [blame] | 397 | HDMI_CFG(hpd_reg, none), |
| 398 | HDMI_CFG(pwr_clk, 8x74), |
| 399 | HDMI_CFG(hpd_clk, 8x74), |
| 400 | .hpd_freq = hpd_clk_freq_8x74, |
| 401 | }; |
| 402 | |
| 403 | static struct hdmi_platform_config hdmi_tx_8996_config = { |
Stephane Viau | 0afbe59 | 2015-09-15 08:41:49 -0400 | [diff] [blame] | 404 | HDMI_CFG(pwr_reg, none), |
| 405 | HDMI_CFG(hpd_reg, none), |
Stephane Viau | 3a84f84 | 2015-06-19 16:04:47 -0400 | [diff] [blame] | 406 | HDMI_CFG(pwr_clk, 8x74), |
| 407 | HDMI_CFG(hpd_clk, 8x74), |
| 408 | .hpd_freq = hpd_clk_freq_8x74, |
| 409 | }; |
| 410 | |
Archit Taneja | dc50f782 | 2016-02-25 11:22:36 +0530 | [diff] [blame] | 411 | static const struct { |
| 412 | const char *name; |
| 413 | const bool output; |
| 414 | const int value; |
| 415 | const char *label; |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 416 | } msm_hdmi_gpio_pdata[] = { |
Archit Taneja | dc50f782 | 2016-02-25 11:22:36 +0530 | [diff] [blame] | 417 | { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" }, |
| 418 | { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" }, |
| 419 | { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" }, |
| 420 | { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" }, |
| 421 | { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" }, |
| 422 | { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" }, |
| 423 | }; |
| 424 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 425 | static int msm_hdmi_get_gpio(struct device_node *of_node, const char *name) |
Mark Charlebois | fc88610 | 2014-08-29 11:05:50 -0700 | [diff] [blame] | 426 | { |
Archit Taneja | 5f6f5e0 | 2016-09-13 20:51:35 +0530 | [diff] [blame] | 427 | int gpio; |
| 428 | |
| 429 | /* try with the gpio names as in the table (downstream bindings) */ |
| 430 | gpio = of_get_named_gpio(of_node, name, 0); |
Mark Charlebois | fc88610 | 2014-08-29 11:05:50 -0700 | [diff] [blame] | 431 | if (gpio < 0) { |
| 432 | char name2[32]; |
Archit Taneja | 5f6f5e0 | 2016-09-13 20:51:35 +0530 | [diff] [blame] | 433 | |
| 434 | /* try with the gpio names as in the upstream bindings */ |
| 435 | snprintf(name2, sizeof(name2), "%s-gpios", name); |
Mark Charlebois | fc88610 | 2014-08-29 11:05:50 -0700 | [diff] [blame] | 436 | gpio = of_get_named_gpio(of_node, name2, 0); |
| 437 | if (gpio < 0) { |
Archit Taneja | 5f6f5e0 | 2016-09-13 20:51:35 +0530 | [diff] [blame] | 438 | char name3[32]; |
| 439 | |
| 440 | /* |
| 441 | * try again after stripping out the "qcom,hdmi-tx" |
| 442 | * prefix. This is mainly to match "hpd-gpios" used |
| 443 | * in the upstream bindings |
| 444 | */ |
| 445 | if (sscanf(name2, "qcom,hdmi-tx-%s", name3)) |
| 446 | gpio = of_get_named_gpio(of_node, name3, 0); |
| 447 | } |
| 448 | |
| 449 | if (gpio < 0) { |
Stephane Viau | 3a84f84 | 2015-06-19 16:04:47 -0400 | [diff] [blame] | 450 | DBG("failed to get gpio: %s (%d)", name, gpio); |
Mark Charlebois | fc88610 | 2014-08-29 11:05:50 -0700 | [diff] [blame] | 451 | gpio = -1; |
| 452 | } |
| 453 | } |
| 454 | return gpio; |
| 455 | } |
Mark Charlebois | fc88610 | 2014-08-29 11:05:50 -0700 | [diff] [blame] | 456 | |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 457 | /* |
| 458 | * HDMI audio codec callbacks |
| 459 | */ |
| 460 | static int msm_hdmi_audio_hw_params(struct device *dev, void *data, |
| 461 | struct hdmi_codec_daifmt *daifmt, |
| 462 | struct hdmi_codec_params *params) |
| 463 | { |
| 464 | struct hdmi *hdmi = dev_get_drvdata(dev); |
| 465 | unsigned int chan; |
| 466 | unsigned int channel_allocation = 0; |
| 467 | unsigned int rate; |
| 468 | unsigned int level_shift = 0; /* 0dB */ |
| 469 | bool down_mix = false; |
| 470 | |
| 471 | dev_dbg(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, |
| 472 | params->sample_width, params->cea.channels); |
| 473 | |
| 474 | switch (params->cea.channels) { |
| 475 | case 2: |
| 476 | /* FR and FL speakers */ |
| 477 | channel_allocation = 0; |
| 478 | chan = MSM_HDMI_AUDIO_CHANNEL_2; |
| 479 | break; |
| 480 | case 4: |
| 481 | /* FC, LFE, FR and FL speakers */ |
| 482 | channel_allocation = 0x3; |
| 483 | chan = MSM_HDMI_AUDIO_CHANNEL_4; |
| 484 | break; |
| 485 | case 6: |
| 486 | /* RR, RL, FC, LFE, FR and FL speakers */ |
| 487 | channel_allocation = 0x0B; |
| 488 | chan = MSM_HDMI_AUDIO_CHANNEL_6; |
| 489 | break; |
| 490 | case 8: |
| 491 | /* FRC, FLC, RR, RL, FC, LFE, FR and FL speakers */ |
| 492 | channel_allocation = 0x1F; |
| 493 | chan = MSM_HDMI_AUDIO_CHANNEL_8; |
| 494 | break; |
| 495 | default: |
| 496 | return -EINVAL; |
| 497 | } |
| 498 | |
| 499 | switch (params->sample_rate) { |
| 500 | case 32000: |
| 501 | rate = HDMI_SAMPLE_RATE_32KHZ; |
| 502 | break; |
| 503 | case 44100: |
| 504 | rate = HDMI_SAMPLE_RATE_44_1KHZ; |
| 505 | break; |
| 506 | case 48000: |
| 507 | rate = HDMI_SAMPLE_RATE_48KHZ; |
| 508 | break; |
| 509 | case 88200: |
| 510 | rate = HDMI_SAMPLE_RATE_88_2KHZ; |
| 511 | break; |
| 512 | case 96000: |
| 513 | rate = HDMI_SAMPLE_RATE_96KHZ; |
| 514 | break; |
| 515 | case 176400: |
| 516 | rate = HDMI_SAMPLE_RATE_176_4KHZ; |
| 517 | break; |
| 518 | case 192000: |
| 519 | rate = HDMI_SAMPLE_RATE_192KHZ; |
| 520 | break; |
| 521 | default: |
| 522 | dev_err(dev, "rate[%d] not supported!\n", |
| 523 | params->sample_rate); |
| 524 | return -EINVAL; |
| 525 | } |
| 526 | |
| 527 | msm_hdmi_audio_set_sample_rate(hdmi, rate); |
| 528 | msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation, |
| 529 | level_shift, down_mix); |
| 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | static void msm_hdmi_audio_shutdown(struct device *dev, void *data) |
| 535 | { |
| 536 | struct hdmi *hdmi = dev_get_drvdata(dev); |
| 537 | |
| 538 | msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0); |
| 539 | } |
| 540 | |
| 541 | static const struct hdmi_codec_ops msm_hdmi_audio_codec_ops = { |
| 542 | .hw_params = msm_hdmi_audio_hw_params, |
| 543 | .audio_shutdown = msm_hdmi_audio_shutdown, |
| 544 | }; |
| 545 | |
| 546 | static struct hdmi_codec_pdata codec_data = { |
| 547 | .ops = &msm_hdmi_audio_codec_ops, |
| 548 | .max_i2s_channels = 8, |
| 549 | .i2s = 1, |
| 550 | }; |
| 551 | |
| 552 | static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) |
| 553 | { |
| 554 | hdmi->audio_pdev = platform_device_register_data(dev, |
| 555 | HDMI_CODEC_DRV_NAME, |
| 556 | PLATFORM_DEVID_AUTO, |
| 557 | &codec_data, |
| 558 | sizeof(codec_data)); |
Wei Yongjun | 06f3217 | 2016-07-12 11:06:52 +0000 | [diff] [blame] | 559 | return PTR_ERR_OR_ZERO(hdmi->audio_pdev); |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 560 | } |
| 561 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 562 | static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 563 | { |
Rob Clark | d1a717b | 2014-11-18 08:40:44 -0500 | [diff] [blame] | 564 | struct drm_device *drm = dev_get_drvdata(master); |
| 565 | struct msm_drm_private *priv = drm->dev_private; |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 566 | static struct hdmi_platform_config *hdmi_cfg; |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 567 | struct hdmi *hdmi; |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 568 | struct device_node *of_node = dev->of_node; |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 569 | int i, err; |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 570 | |
Archit Taneja | 1fd6a44 | 2015-10-30 12:35:55 +0530 | [diff] [blame] | 571 | hdmi_cfg = (struct hdmi_platform_config *) |
| 572 | of_device_get_match_data(dev); |
| 573 | if (!hdmi_cfg) { |
| 574 | dev_err(dev, "unknown hdmi_cfg: %s\n", of_node->name); |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 575 | return -ENXIO; |
Rob Clark | 41e6977 | 2013-12-15 16:23:05 -0500 | [diff] [blame] | 576 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 577 | |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 578 | hdmi_cfg->mmio_name = "core_physical"; |
jilai wang | c6a57a5 | 2015-04-02 17:49:01 -0400 | [diff] [blame] | 579 | hdmi_cfg->qfprom_mmio_name = "qfprom_physical"; |
Archit Taneja | dc50f782 | 2016-02-25 11:22:36 +0530 | [diff] [blame] | 580 | |
| 581 | for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 582 | hdmi_cfg->gpios[i].num = msm_hdmi_get_gpio(of_node, |
| 583 | msm_hdmi_gpio_pdata[i].name); |
| 584 | hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output; |
| 585 | hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value; |
| 586 | hdmi_cfg->gpios[i].label = msm_hdmi_gpio_pdata[i].label; |
Archit Taneja | dc50f782 | 2016-02-25 11:22:36 +0530 | [diff] [blame] | 587 | } |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 588 | |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 589 | dev->platform_data = hdmi_cfg; |
| 590 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 591 | hdmi = msm_hdmi_init(to_platform_device(dev)); |
Rob Clark | 067fef3 | 2014-11-04 13:33:14 -0500 | [diff] [blame] | 592 | if (IS_ERR(hdmi)) |
| 593 | return PTR_ERR(hdmi); |
Rob Clark | d1a717b | 2014-11-18 08:40:44 -0500 | [diff] [blame] | 594 | priv->hdmi = hdmi; |
Stephane Viau | 5eba5d8 | 2015-01-07 16:27:27 -0500 | [diff] [blame] | 595 | |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 596 | err = msm_hdmi_register_audio_driver(hdmi, dev); |
| 597 | if (err) { |
| 598 | DRM_ERROR("Failed to attach an audio codec %d\n", err); |
| 599 | hdmi->audio_pdev = NULL; |
| 600 | } |
| 601 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 602 | return 0; |
| 603 | } |
| 604 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 605 | static void msm_hdmi_unbind(struct device *dev, struct device *master, |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 606 | void *data) |
| 607 | { |
Rob Clark | d1a717b | 2014-11-18 08:40:44 -0500 | [diff] [blame] | 608 | struct drm_device *drm = dev_get_drvdata(master); |
| 609 | struct msm_drm_private *priv = drm->dev_private; |
| 610 | if (priv->hdmi) { |
Srinivas Kandagatla | f142701 | 2016-06-10 10:45:56 +0100 | [diff] [blame] | 611 | if (priv->hdmi->audio_pdev) |
| 612 | platform_device_unregister(priv->hdmi->audio_pdev); |
| 613 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 614 | msm_hdmi_destroy(priv->hdmi); |
Rob Clark | d1a717b | 2014-11-18 08:40:44 -0500 | [diff] [blame] | 615 | priv->hdmi = NULL; |
| 616 | } |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 617 | } |
| 618 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 619 | static const struct component_ops msm_hdmi_ops = { |
| 620 | .bind = msm_hdmi_bind, |
| 621 | .unbind = msm_hdmi_unbind, |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 622 | }; |
| 623 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 624 | static int msm_hdmi_dev_probe(struct platform_device *pdev) |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 625 | { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 626 | return component_add(&pdev->dev, &msm_hdmi_ops); |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 627 | } |
| 628 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 629 | static int msm_hdmi_dev_remove(struct platform_device *pdev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 630 | { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 631 | component_del(&pdev->dev, &msm_hdmi_ops); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 632 | return 0; |
| 633 | } |
| 634 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 635 | static const struct of_device_id msm_hdmi_dt_match[] = { |
Archit Taneja | 1fd6a44 | 2015-10-30 12:35:55 +0530 | [diff] [blame] | 636 | { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8996_config }, |
| 637 | { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8994_config }, |
| 638 | { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config }, |
| 639 | { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config }, |
| 640 | { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config }, |
| 641 | { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8660_config }, |
| 642 | {} |
| 643 | }; |
| 644 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 645 | static struct platform_driver msm_hdmi_driver = { |
| 646 | .probe = msm_hdmi_dev_probe, |
| 647 | .remove = msm_hdmi_dev_remove, |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 648 | .driver = { |
| 649 | .name = "hdmi_msm", |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 650 | .of_match_table = msm_hdmi_dt_match, |
Rob Clark | dada25b | 2013-12-01 12:12:54 -0500 | [diff] [blame] | 651 | }, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 652 | }; |
| 653 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 654 | void __init msm_hdmi_register(void) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 655 | { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 656 | msm_hdmi_phy_driver_register(); |
| 657 | platform_driver_register(&msm_hdmi_driver); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 658 | } |
| 659 | |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 660 | void __exit msm_hdmi_unregister(void) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 661 | { |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 662 | platform_driver_unregister(&msm_hdmi_driver); |
| 663 | msm_hdmi_phy_driver_unregister(); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 664 | } |