blob: 814536202efe589f691f35c65fc603ddb053293c [file] [log] [blame]
Rob Clarkc8afe682013-06-26 12:44:06 -04001/*
Stephane Viau5eba5d82015-01-07 16:27:27 -05002 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
Rob Clarkc8afe682013-06-26 12:44:06 -04003 * 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 Clarkf6a8eac2014-11-17 15:28:07 -050019#include <linux/of_irq.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040020#include "hdmi.h"
21
Rob Clarkc8afe682013-06-26 12:44:06 -040022void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
23{
24 uint32_t ctrl = 0;
25
26 if (power_on) {
27 ctrl |= HDMI_CTRL_ENABLE;
28 if (!hdmi->hdmi_mode) {
29 ctrl |= HDMI_CTRL_HDMI;
30 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
31 ctrl &= ~HDMI_CTRL_HDMI;
32 } else {
33 ctrl |= HDMI_CTRL_HDMI;
34 }
35 } else {
36 ctrl = HDMI_CTRL_HDMI;
37 }
38
39 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
40 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x",
41 power_on ? "Enable" : "Disable", ctrl);
42}
43
Rob Clarkf6a8eac2014-11-17 15:28:07 -050044static irqreturn_t hdmi_irq(int irq, void *dev_id)
Rob Clarkc8afe682013-06-26 12:44:06 -040045{
46 struct hdmi *hdmi = dev_id;
47
48 /* Process HPD: */
49 hdmi_connector_irq(hdmi->connector);
50
51 /* Process DDC: */
52 hdmi_i2c_irq(hdmi->i2c);
53
54 /* TODO audio.. */
55
56 return IRQ_HANDLED;
57}
58
Rob Clarkd1a717b2014-11-18 08:40:44 -050059static void hdmi_destroy(struct hdmi *hdmi)
Rob Clarkc8afe682013-06-26 12:44:06 -040060{
61 struct hdmi_phy *phy = hdmi->phy;
62
63 if (phy)
64 phy->funcs->destroy(phy);
65
66 if (hdmi->i2c)
67 hdmi_i2c_destroy(hdmi->i2c);
68
Rob Clarkc0c0d9e2013-12-11 14:44:02 -050069 platform_set_drvdata(hdmi->pdev, NULL);
Rob Clarkc8afe682013-06-26 12:44:06 -040070}
71
Rob Clark067fef32014-11-04 13:33:14 -050072/* construct hdmi at bind/probe time, grab all the resources. If
73 * we are to EPROBE_DEFER we want to do it here, rather than later
74 * at modeset_init() time
75 */
76static struct hdmi *hdmi_init(struct platform_device *pdev)
Rob Clarkc8afe682013-06-26 12:44:06 -040077{
Rob Clark067fef32014-11-04 13:33:14 -050078 struct hdmi_platform_config *config = pdev->dev.platform_data;
Rob Clarka3376e32013-08-30 13:02:15 -040079 struct hdmi *hdmi = NULL;
Rob Clarkdada25b2013-12-01 12:12:54 -050080 int i, ret;
Rob Clarkc8afe682013-06-26 12:44:06 -040081
Rob Clark067fef32014-11-04 13:33:14 -050082 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
Rob Clarka3376e32013-08-30 13:02:15 -040083 if (!hdmi) {
84 ret = -ENOMEM;
85 goto fail;
86 }
87
Rob Clarkc8afe682013-06-26 12:44:06 -040088 hdmi->pdev = pdev;
Rob Clarkdada25b2013-12-01 12:12:54 -050089 hdmi->config = config;
Rob Clarkc0c0d9e2013-12-11 14:44:02 -050090
Rob Clarkc8afe682013-06-26 12:44:06 -040091 /* not sure about which phy maps to which msm.. probably I miss some */
92 if (config->phy_init)
93 hdmi->phy = config->phy_init(hdmi);
94 else
95 hdmi->phy = ERR_PTR(-ENXIO);
96
97 if (IS_ERR(hdmi->phy)) {
98 ret = PTR_ERR(hdmi->phy);
Rob Clark067fef32014-11-04 13:33:14 -050099 dev_err(&pdev->dev, "failed to load phy: %d\n", ret);
Rob Clarkc8afe682013-06-26 12:44:06 -0400100 hdmi->phy = NULL;
101 goto fail;
102 }
103
Rob Clarkdada25b2013-12-01 12:12:54 -0500104 hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI");
Rob Clarkc8afe682013-06-26 12:44:06 -0400105 if (IS_ERR(hdmi->mmio)) {
106 ret = PTR_ERR(hdmi->mmio);
107 goto fail;
108 }
109
Stephane Viau447fa522015-01-13 14:33:40 -0500110 hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
111 config->hpd_reg_cnt, GFP_KERNEL);
112 if (!hdmi->hpd_regs) {
113 ret = -ENOMEM;
114 goto fail;
115 }
Rob Clarkdada25b2013-12-01 12:12:54 -0500116 for (i = 0; i < config->hpd_reg_cnt; i++) {
117 struct regulator *reg;
118
Rob Clark3e875992014-08-01 13:08:11 -0400119 reg = devm_regulator_get(&pdev->dev,
Rob Clark41e69772013-12-15 16:23:05 -0500120 config->hpd_reg_names[i]);
Rob Clarkdada25b2013-12-01 12:12:54 -0500121 if (IS_ERR(reg)) {
122 ret = PTR_ERR(reg);
Rob Clark067fef32014-11-04 13:33:14 -0500123 dev_err(&pdev->dev, "failed to get hpd regulator: %s (%d)\n",
Rob Clarkdada25b2013-12-01 12:12:54 -0500124 config->hpd_reg_names[i], ret);
125 goto fail;
126 }
127
128 hdmi->hpd_regs[i] = reg;
Rob Clarkc8afe682013-06-26 12:44:06 -0400129 }
130
Stephane Viau447fa522015-01-13 14:33:40 -0500131 hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
132 config->pwr_reg_cnt, GFP_KERNEL);
133 if (!hdmi->pwr_regs) {
134 ret = -ENOMEM;
135 goto fail;
136 }
Rob Clarkdada25b2013-12-01 12:12:54 -0500137 for (i = 0; i < config->pwr_reg_cnt; i++) {
138 struct regulator *reg;
Rob Clarkc8afe682013-06-26 12:44:06 -0400139
Rob Clark3e875992014-08-01 13:08:11 -0400140 reg = devm_regulator_get(&pdev->dev,
Rob Clark41e69772013-12-15 16:23:05 -0500141 config->pwr_reg_names[i]);
Rob Clarkdada25b2013-12-01 12:12:54 -0500142 if (IS_ERR(reg)) {
143 ret = PTR_ERR(reg);
Rob Clark067fef32014-11-04 13:33:14 -0500144 dev_err(&pdev->dev, "failed to get pwr regulator: %s (%d)\n",
Rob Clarkdada25b2013-12-01 12:12:54 -0500145 config->pwr_reg_names[i], ret);
146 goto fail;
147 }
148
149 hdmi->pwr_regs[i] = reg;
Rob Clarkc8afe682013-06-26 12:44:06 -0400150 }
151
Stephane Viau447fa522015-01-13 14:33:40 -0500152 hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
153 config->hpd_clk_cnt, GFP_KERNEL);
154 if (!hdmi->hpd_clks) {
155 ret = -ENOMEM;
156 goto fail;
157 }
Rob Clarkdada25b2013-12-01 12:12:54 -0500158 for (i = 0; i < config->hpd_clk_cnt; i++) {
159 struct clk *clk;
160
161 clk = devm_clk_get(&pdev->dev, config->hpd_clk_names[i]);
162 if (IS_ERR(clk)) {
163 ret = PTR_ERR(clk);
Rob Clark067fef32014-11-04 13:33:14 -0500164 dev_err(&pdev->dev, "failed to get hpd clk: %s (%d)\n",
Rob Clarkdada25b2013-12-01 12:12:54 -0500165 config->hpd_clk_names[i], ret);
166 goto fail;
167 }
168
169 hdmi->hpd_clks[i] = clk;
Rob Clarkc8afe682013-06-26 12:44:06 -0400170 }
171
Stephane Viau447fa522015-01-13 14:33:40 -0500172 hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
173 config->pwr_clk_cnt, GFP_KERNEL);
174 if (!hdmi->pwr_clks) {
175 ret = -ENOMEM;
176 goto fail;
177 }
Rob Clarkdada25b2013-12-01 12:12:54 -0500178 for (i = 0; i < config->pwr_clk_cnt; i++) {
179 struct clk *clk;
180
181 clk = devm_clk_get(&pdev->dev, config->pwr_clk_names[i]);
182 if (IS_ERR(clk)) {
183 ret = PTR_ERR(clk);
Rob Clark067fef32014-11-04 13:33:14 -0500184 dev_err(&pdev->dev, "failed to get pwr clk: %s (%d)\n",
Rob Clarkdada25b2013-12-01 12:12:54 -0500185 config->pwr_clk_names[i], ret);
186 goto fail;
187 }
188
189 hdmi->pwr_clks[i] = clk;
Rob Clarkc8afe682013-06-26 12:44:06 -0400190 }
191
192 hdmi->i2c = hdmi_i2c_init(hdmi);
193 if (IS_ERR(hdmi->i2c)) {
194 ret = PTR_ERR(hdmi->i2c);
Rob Clark067fef32014-11-04 13:33:14 -0500195 dev_err(&pdev->dev, "failed to get i2c: %d\n", ret);
Rob Clarkc8afe682013-06-26 12:44:06 -0400196 hdmi->i2c = NULL;
197 goto fail;
198 }
199
Rob Clark067fef32014-11-04 13:33:14 -0500200 return hdmi;
201
202fail:
203 if (hdmi)
Rob Clarkd1a717b2014-11-18 08:40:44 -0500204 hdmi_destroy(hdmi);
Rob Clark067fef32014-11-04 13:33:14 -0500205
206 return ERR_PTR(ret);
207}
208
209/* Second part of initialization, the drm/kms level modeset_init,
210 * constructs/initializes mode objects, etc, is called from master
211 * driver (not hdmi sub-device's probe/bind!)
212 *
213 * Any resource (regulator/clk/etc) which could be missing at boot
214 * should be handled in hdmi_init() so that failure happens from
215 * hdmi sub-device's probe.
216 */
217int hdmi_modeset_init(struct hdmi *hdmi,
218 struct drm_device *dev, struct drm_encoder *encoder)
219{
220 struct msm_drm_private *priv = dev->dev_private;
221 struct platform_device *pdev = hdmi->pdev;
Rob Clark067fef32014-11-04 13:33:14 -0500222 int ret;
223
224 hdmi->dev = dev;
225 hdmi->encoder = encoder;
226
227 hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
228
Rob Clarka3376e32013-08-30 13:02:15 -0400229 hdmi->bridge = hdmi_bridge_init(hdmi);
230 if (IS_ERR(hdmi->bridge)) {
231 ret = PTR_ERR(hdmi->bridge);
232 dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret);
233 hdmi->bridge = NULL;
234 goto fail;
235 }
236
237 hdmi->connector = hdmi_connector_init(hdmi);
238 if (IS_ERR(hdmi->connector)) {
239 ret = PTR_ERR(hdmi->connector);
240 dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret);
241 hdmi->connector = NULL;
242 goto fail;
243 }
244
Rob Clarkf6a8eac2014-11-17 15:28:07 -0500245 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
246 if (hdmi->irq < 0) {
247 ret = hdmi->irq;
248 dev_err(dev->dev, "failed to get irq: %d\n", ret);
249 goto fail;
250 }
Rob Clarkc8afe682013-06-26 12:44:06 -0400251
Rob Clarkf6a8eac2014-11-17 15:28:07 -0500252 ret = devm_request_irq(&pdev->dev, hdmi->irq,
253 hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
254 "hdmi_isr", hdmi);
255 if (ret < 0) {
256 dev_err(dev->dev, "failed to request IRQ%u: %d\n",
257 hdmi->irq, ret);
258 goto fail;
Rob Clarkc8afe682013-06-26 12:44:06 -0400259 }
260
Rob Clarka3376e32013-08-30 13:02:15 -0400261 encoder->bridge = hdmi->bridge;
262
263 priv->bridges[priv->num_bridges++] = hdmi->bridge;
264 priv->connectors[priv->num_connectors++] = hdmi->connector;
265
Rob Clarkc0c0d9e2013-12-11 14:44:02 -0500266 platform_set_drvdata(pdev, hdmi);
267
Rob Clark067fef32014-11-04 13:33:14 -0500268 return 0;
Rob Clarkc8afe682013-06-26 12:44:06 -0400269
270fail:
Ajay Kumar3d3f8b12015-01-20 22:08:44 +0530271 /* bridge is normally destroyed by drm: */
Rob Clark067fef32014-11-04 13:33:14 -0500272 if (hdmi->bridge) {
Ajay Kumar3d3f8b12015-01-20 22:08:44 +0530273 hdmi_bridge_destroy(hdmi->bridge);
Rob Clark067fef32014-11-04 13:33:14 -0500274 hdmi->bridge = NULL;
275 }
276 if (hdmi->connector) {
277 hdmi->connector->funcs->destroy(hdmi->connector);
278 hdmi->connector = NULL;
Rob Clarka3376e32013-08-30 13:02:15 -0400279 }
Rob Clarkc8afe682013-06-26 12:44:06 -0400280
Rob Clark067fef32014-11-04 13:33:14 -0500281 return ret;
Rob Clarkc8afe682013-06-26 12:44:06 -0400282}
283
284/*
285 * The hdmi device:
286 */
287
Rob Clarkdada25b2013-12-01 12:12:54 -0500288#include <linux/of_gpio.h>
289
Stephane Viau5eba5d82015-01-07 16:27:27 -0500290#define HDMI_CFG(item, entry) \
291 .item ## _names = item ##_names_ ## entry, \
292 .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry)
293
294static struct hdmi_platform_config hdmi_tx_8660_config = {
295 .phy_init = hdmi_phy_8x60_init,
296};
297
298static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"};
299static const char *hpd_clk_names_8960[] = {"core_clk", "master_iface_clk", "slave_iface_clk"};
300
301static struct hdmi_platform_config hdmi_tx_8960_config = {
302 .phy_init = hdmi_phy_8960_init,
303 HDMI_CFG(hpd_reg, 8960),
304 HDMI_CFG(hpd_clk, 8960),
305};
306
307static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
308static const char *hpd_reg_names_8x74[] = {"hpd-gdsc", "hpd-5v"};
309static const char *pwr_clk_names_8x74[] = {"extp_clk", "alt_iface_clk"};
310static const char *hpd_clk_names_8x74[] = {"iface_clk", "core_clk", "mdp_core_clk"};
311static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0};
312
313static struct hdmi_platform_config hdmi_tx_8074_config = {
314 .phy_init = hdmi_phy_8x74_init,
315 HDMI_CFG(pwr_reg, 8x74),
316 HDMI_CFG(hpd_reg, 8x74),
317 HDMI_CFG(pwr_clk, 8x74),
318 HDMI_CFG(hpd_clk, 8x74),
319 .hpd_freq = hpd_clk_freq_8x74,
320};
321
322static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"};
323
324static struct hdmi_platform_config hdmi_tx_8084_config = {
325 .phy_init = hdmi_phy_8x74_init,
326 HDMI_CFG(pwr_reg, 8x74),
327 HDMI_CFG(hpd_reg, 8084),
328 HDMI_CFG(pwr_clk, 8x74),
329 HDMI_CFG(hpd_clk, 8x74),
330 .hpd_freq = hpd_clk_freq_8x74,
331};
332
333static const struct of_device_id dt_match[] = {
334 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config },
335 { .compatible = "qcom,hdmi-tx-8074", .data = &hdmi_tx_8074_config },
336 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
337 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8660_config },
338 {}
339};
340
Mark Charleboisfc886102014-08-29 11:05:50 -0700341#ifdef CONFIG_OF
342static int get_gpio(struct device *dev, struct device_node *of_node, const char *name)
343{
344 int gpio = of_get_named_gpio(of_node, name, 0);
345 if (gpio < 0) {
346 char name2[32];
347 snprintf(name2, sizeof(name2), "%s-gpio", name);
348 gpio = of_get_named_gpio(of_node, name2, 0);
349 if (gpio < 0) {
350 dev_err(dev, "failed to get gpio: %s (%d)\n",
351 name, gpio);
352 gpio = -1;
353 }
354 }
355 return gpio;
356}
357#endif
358
Rob Clark060530f2014-03-03 14:19:12 -0500359static int hdmi_bind(struct device *dev, struct device *master, void *data)
Rob Clarkc8afe682013-06-26 12:44:06 -0400360{
Rob Clarkd1a717b2014-11-18 08:40:44 -0500361 struct drm_device *drm = dev_get_drvdata(master);
362 struct msm_drm_private *priv = drm->dev_private;
Stephane Viau5eba5d82015-01-07 16:27:27 -0500363 static struct hdmi_platform_config *hdmi_cfg;
Rob Clark067fef32014-11-04 13:33:14 -0500364 struct hdmi *hdmi;
Rob Clarkc8afe682013-06-26 12:44:06 -0400365#ifdef CONFIG_OF
Rob Clark060530f2014-03-03 14:19:12 -0500366 struct device_node *of_node = dev->of_node;
Stephane Viau5eba5d82015-01-07 16:27:27 -0500367 const struct of_device_id *match;
Rob Clarkdada25b2013-12-01 12:12:54 -0500368
Stephane Viau5eba5d82015-01-07 16:27:27 -0500369 match = of_match_node(dt_match, of_node);
370 if (match && match->data) {
371 hdmi_cfg = (struct hdmi_platform_config *)match->data;
372 DBG("hdmi phy: %s", match->compatible);
Rob Clark41e69772013-12-15 16:23:05 -0500373 } else {
374 dev_err(dev, "unknown phy: %s\n", of_node->name);
Stephane Viau5eba5d82015-01-07 16:27:27 -0500375 return -ENXIO;
Rob Clark41e69772013-12-15 16:23:05 -0500376 }
Rob Clarkdada25b2013-12-01 12:12:54 -0500377
Stephane Viau5eba5d82015-01-07 16:27:27 -0500378 hdmi_cfg->mmio_name = "core_physical";
379 hdmi_cfg->ddc_clk_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-clk");
380 hdmi_cfg->ddc_data_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-data");
381 hdmi_cfg->hpd_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-hpd");
382 hdmi_cfg->mux_en_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-en");
383 hdmi_cfg->mux_sel_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-sel");
384 hdmi_cfg->mux_lpm_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-lpm");
Rob Clarkdada25b2013-12-01 12:12:54 -0500385
Rob Clarkc8afe682013-06-26 12:44:06 -0400386#else
Stephane Viau5eba5d82015-01-07 16:27:27 -0500387 static struct hdmi_platform_config config = {};
Rob Clarkdada25b2013-12-01 12:12:54 -0500388 static const char *hpd_clk_names[] = {
389 "core_clk", "master_iface_clk", "slave_iface_clk",
390 };
Rob Clarkc8afe682013-06-26 12:44:06 -0400391 if (cpu_is_apq8064()) {
Rob Clarkdada25b2013-12-01 12:12:54 -0500392 static const char *hpd_reg_names[] = {"8921_hdmi_mvs"};
Rob Clarkc8afe682013-06-26 12:44:06 -0400393 config.phy_init = hdmi_phy_8960_init;
Rob Clarkdada25b2013-12-01 12:12:54 -0500394 config.mmio_name = "hdmi_msm_hdmi_addr";
395 config.hpd_reg_names = hpd_reg_names;
396 config.hpd_reg_cnt = ARRAY_SIZE(hpd_reg_names);
397 config.hpd_clk_names = hpd_clk_names;
398 config.hpd_clk_cnt = ARRAY_SIZE(hpd_clk_names);
Rob Clarkc8afe682013-06-26 12:44:06 -0400399 config.ddc_clk_gpio = 70;
400 config.ddc_data_gpio = 71;
401 config.hpd_gpio = 72;
Rob Clarkdada25b2013-12-01 12:12:54 -0500402 config.mux_en_gpio = -1;
Rob Clarkc0c0d9e2013-12-11 14:44:02 -0500403 config.mux_sel_gpio = -1;
Rob Clarke529c7e2013-11-16 13:07:31 -0500404 } else if (cpu_is_msm8960() || cpu_is_msm8960ab()) {
Rob Clarkdada25b2013-12-01 12:12:54 -0500405 static const char *hpd_reg_names[] = {"8921_hdmi_mvs"};
Rob Clarkc8afe682013-06-26 12:44:06 -0400406 config.phy_init = hdmi_phy_8960_init;
Rob Clarkdada25b2013-12-01 12:12:54 -0500407 config.mmio_name = "hdmi_msm_hdmi_addr";
408 config.hpd_reg_names = hpd_reg_names;
409 config.hpd_reg_cnt = ARRAY_SIZE(hpd_reg_names);
410 config.hpd_clk_names = hpd_clk_names;
411 config.hpd_clk_cnt = ARRAY_SIZE(hpd_clk_names);
Rob Clarkc8afe682013-06-26 12:44:06 -0400412 config.ddc_clk_gpio = 100;
413 config.ddc_data_gpio = 101;
414 config.hpd_gpio = 102;
Rob Clarkdada25b2013-12-01 12:12:54 -0500415 config.mux_en_gpio = -1;
416 config.mux_sel_gpio = -1;
Rob Clarkc8afe682013-06-26 12:44:06 -0400417 } else if (cpu_is_msm8x60()) {
Rob Clarkdada25b2013-12-01 12:12:54 -0500418 static const char *hpd_reg_names[] = {
419 "8901_hdmi_mvs", "8901_mpp0"
420 };
Rob Clarkc8afe682013-06-26 12:44:06 -0400421 config.phy_init = hdmi_phy_8x60_init;
Rob Clarkdada25b2013-12-01 12:12:54 -0500422 config.mmio_name = "hdmi_msm_hdmi_addr";
423 config.hpd_reg_names = hpd_reg_names;
424 config.hpd_reg_cnt = ARRAY_SIZE(hpd_reg_names);
425 config.hpd_clk_names = hpd_clk_names;
426 config.hpd_clk_cnt = ARRAY_SIZE(hpd_clk_names);
Rob Clarkc8afe682013-06-26 12:44:06 -0400427 config.ddc_clk_gpio = 170;
428 config.ddc_data_gpio = 171;
429 config.hpd_gpio = 172;
Rob Clarkdada25b2013-12-01 12:12:54 -0500430 config.mux_en_gpio = -1;
431 config.mux_sel_gpio = -1;
Rob Clarkc8afe682013-06-26 12:44:06 -0400432 }
Stephane Viau5eba5d82015-01-07 16:27:27 -0500433 hdmi_cfg = &config;
Rob Clarkc8afe682013-06-26 12:44:06 -0400434#endif
Stephane Viau5eba5d82015-01-07 16:27:27 -0500435 dev->platform_data = hdmi_cfg;
436
Rob Clark067fef32014-11-04 13:33:14 -0500437 hdmi = hdmi_init(to_platform_device(dev));
438 if (IS_ERR(hdmi))
439 return PTR_ERR(hdmi);
Rob Clarkd1a717b2014-11-18 08:40:44 -0500440 priv->hdmi = hdmi;
Stephane Viau5eba5d82015-01-07 16:27:27 -0500441
Rob Clarkc8afe682013-06-26 12:44:06 -0400442 return 0;
443}
444
Rob Clark060530f2014-03-03 14:19:12 -0500445static void hdmi_unbind(struct device *dev, struct device *master,
446 void *data)
447{
Rob Clarkd1a717b2014-11-18 08:40:44 -0500448 struct drm_device *drm = dev_get_drvdata(master);
449 struct msm_drm_private *priv = drm->dev_private;
450 if (priv->hdmi) {
451 hdmi_destroy(priv->hdmi);
452 priv->hdmi = NULL;
453 }
Rob Clark060530f2014-03-03 14:19:12 -0500454}
455
456static const struct component_ops hdmi_ops = {
457 .bind = hdmi_bind,
458 .unbind = hdmi_unbind,
459};
460
461static int hdmi_dev_probe(struct platform_device *pdev)
462{
463 return component_add(&pdev->dev, &hdmi_ops);
464}
465
Rob Clarkc8afe682013-06-26 12:44:06 -0400466static int hdmi_dev_remove(struct platform_device *pdev)
467{
Rob Clark060530f2014-03-03 14:19:12 -0500468 component_del(&pdev->dev, &hdmi_ops);
Rob Clarkc8afe682013-06-26 12:44:06 -0400469 return 0;
470}
471
472static struct platform_driver hdmi_driver = {
473 .probe = hdmi_dev_probe,
474 .remove = hdmi_dev_remove,
Rob Clarkdada25b2013-12-01 12:12:54 -0500475 .driver = {
476 .name = "hdmi_msm",
477 .of_match_table = dt_match,
478 },
Rob Clarkc8afe682013-06-26 12:44:06 -0400479};
480
481void __init hdmi_register(void)
482{
483 platform_driver_register(&hdmi_driver);
484}
485
486void __exit hdmi_unregister(void)
487{
488 platform_driver_unregister(&hdmi_driver);
489}