hdmi.c (79e24da00b1137031245f3341828e4215b1b5b59) hdmi.c (fcda50c8f484cf1140232c8444470449f0619db9)
1/*
2 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
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.

--- 7 unchanged lines hidden (view full) ---

16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/of_irq.h>
20#include <linux/of_gpio.h>
21
22#include "hdmi.h"
23
1/*
2 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
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.

--- 7 unchanged lines hidden (view full) ---

16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/of_irq.h>
20#include <linux/of_gpio.h>
21
22#include "hdmi.h"
23
24void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
24void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on)
25{
26 uint32_t ctrl = 0;
27 unsigned long flags;
28
29 spin_lock_irqsave(&hdmi->reg_lock, flags);
30 if (power_on) {
31 ctrl |= HDMI_CTRL_ENABLE;
32 if (!hdmi->hdmi_mode) {

--- 8 unchanged lines hidden (view full) ---

41 }
42
43 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
44 spin_unlock_irqrestore(&hdmi->reg_lock, flags);
45 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x",
46 power_on ? "Enable" : "Disable", ctrl);
47}
48
25{
26 uint32_t ctrl = 0;
27 unsigned long flags;
28
29 spin_lock_irqsave(&hdmi->reg_lock, flags);
30 if (power_on) {
31 ctrl |= HDMI_CTRL_ENABLE;
32 if (!hdmi->hdmi_mode) {

--- 8 unchanged lines hidden (view full) ---

41 }
42
43 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl);
44 spin_unlock_irqrestore(&hdmi->reg_lock, flags);
45 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x",
46 power_on ? "Enable" : "Disable", ctrl);
47}
48
49static irqreturn_t hdmi_irq(int irq, void *dev_id)
49static irqreturn_t msm_hdmi_irq(int irq, void *dev_id)
50{
51 struct hdmi *hdmi = dev_id;
52
53 /* Process HPD: */
50{
51 struct hdmi *hdmi = dev_id;
52
53 /* Process HPD: */
54 hdmi_connector_irq(hdmi->connector);
54 msm_hdmi_connector_irq(hdmi->connector);
55
56 /* Process DDC: */
55
56 /* Process DDC: */
57 hdmi_i2c_irq(hdmi->i2c);
57 msm_hdmi_i2c_irq(hdmi->i2c);
58
59 /* Process HDCP: */
60 if (hdmi->hdcp_ctrl)
58
59 /* Process HDCP: */
60 if (hdmi->hdcp_ctrl)
61 hdmi_hdcp_irq(hdmi->hdcp_ctrl);
61 msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl);
62
63 /* TODO audio.. */
64
65 return IRQ_HANDLED;
66}
67
62
63 /* TODO audio.. */
64
65 return IRQ_HANDLED;
66}
67
68static void hdmi_destroy(struct hdmi *hdmi)
68static void msm_hdmi_destroy(struct hdmi *hdmi)
69{
69{
70 struct hdmi_phy *phy = hdmi->phy;
71
72 /*
73 * at this point, hpd has been disabled,
74 * after flush workq, it's safe to deinit hdcp
75 */
76 if (hdmi->workq) {
77 flush_workqueue(hdmi->workq);
78 destroy_workqueue(hdmi->workq);
79 }
70 /*
71 * at this point, hpd has been disabled,
72 * after flush workq, it's safe to deinit hdcp
73 */
74 if (hdmi->workq) {
75 flush_workqueue(hdmi->workq);
76 destroy_workqueue(hdmi->workq);
77 }
80 hdmi_hdcp_destroy(hdmi);
81 if (phy)
82 phy->funcs->destroy(phy);
78 msm_hdmi_hdcp_destroy(hdmi);
83
79
80 if (hdmi->phy_dev) {
81 put_device(hdmi->phy_dev);
82 hdmi->phy = NULL;
83 hdmi->phy_dev = NULL;
84 }
85
84 if (hdmi->i2c)
86 if (hdmi->i2c)
85 hdmi_i2c_destroy(hdmi->i2c);
87 msm_hdmi_i2c_destroy(hdmi->i2c);
86
87 platform_set_drvdata(hdmi->pdev, NULL);
88}
89
88
89 platform_set_drvdata(hdmi->pdev, NULL);
90}
91
92static int msm_hdmi_get_phy(struct hdmi *hdmi)
93{
94 struct platform_device *pdev = hdmi->pdev;
95 struct platform_device *phy_pdev;
96 struct device_node *phy_node;
97
98 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
99 if (!phy_node) {
100 dev_err(&pdev->dev, "cannot find phy device\n");
101 return -ENXIO;
102 }
103
104 phy_pdev = of_find_device_by_node(phy_node);
105 if (phy_pdev)
106 hdmi->phy = platform_get_drvdata(phy_pdev);
107
108 of_node_put(phy_node);
109
110 if (!phy_pdev || !hdmi->phy) {
111 dev_err(&pdev->dev, "phy driver is not ready\n");
112 return -EPROBE_DEFER;
113 }
114
115 hdmi->phy_dev = get_device(&phy_pdev->dev);
116
117 return 0;
118}
119
90/* construct hdmi at bind/probe time, grab all the resources. If
91 * we are to EPROBE_DEFER we want to do it here, rather than later
92 * at modeset_init() time
93 */
120/* construct hdmi at bind/probe time, grab all the resources. If
121 * we are to EPROBE_DEFER we want to do it here, rather than later
122 * at modeset_init() time
123 */
94static struct hdmi *hdmi_init(struct platform_device *pdev)
124static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
95{
96 struct hdmi_platform_config *config = pdev->dev.platform_data;
97 struct hdmi *hdmi = NULL;
98 struct resource *res;
99 int i, ret;
100
101 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
102 if (!hdmi) {
103 ret = -ENOMEM;
104 goto fail;
105 }
106
107 hdmi->pdev = pdev;
108 hdmi->config = config;
109 spin_lock_init(&hdmi->reg_lock);
110
125{
126 struct hdmi_platform_config *config = pdev->dev.platform_data;
127 struct hdmi *hdmi = NULL;
128 struct resource *res;
129 int i, ret;
130
131 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
132 if (!hdmi) {
133 ret = -ENOMEM;
134 goto fail;
135 }
136
137 hdmi->pdev = pdev;
138 hdmi->config = config;
139 spin_lock_init(&hdmi->reg_lock);
140
111 /* not sure about which phy maps to which msm.. probably I miss some */
112 if (config->phy_init) {
113 hdmi->phy = config->phy_init(hdmi);
114
115 if (IS_ERR(hdmi->phy)) {
116 ret = PTR_ERR(hdmi->phy);
117 dev_err(&pdev->dev, "failed to load phy: %d\n", ret);
118 hdmi->phy = NULL;
119 goto fail;
120 }
121 }
122
123 hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI");
124 if (IS_ERR(hdmi->mmio)) {
125 ret = PTR_ERR(hdmi->mmio);
126 goto fail;
127 }
128
129 /* HDCP needs physical address of hdmi register */
130 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

--- 86 unchanged lines hidden (view full) ---

217 goto fail;
218 }
219
220 hdmi->pwr_clks[i] = clk;
221 }
222
223 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
224
141 hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI");
142 if (IS_ERR(hdmi->mmio)) {
143 ret = PTR_ERR(hdmi->mmio);
144 goto fail;
145 }
146
147 /* HDCP needs physical address of hdmi register */
148 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

--- 86 unchanged lines hidden (view full) ---

235 goto fail;
236 }
237
238 hdmi->pwr_clks[i] = clk;
239 }
240
241 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
242
225 hdmi->i2c = hdmi_i2c_init(hdmi);
243 hdmi->i2c = msm_hdmi_i2c_init(hdmi);
226 if (IS_ERR(hdmi->i2c)) {
227 ret = PTR_ERR(hdmi->i2c);
228 dev_err(&pdev->dev, "failed to get i2c: %d\n", ret);
229 hdmi->i2c = NULL;
230 goto fail;
231 }
232
244 if (IS_ERR(hdmi->i2c)) {
245 ret = PTR_ERR(hdmi->i2c);
246 dev_err(&pdev->dev, "failed to get i2c: %d\n", ret);
247 hdmi->i2c = NULL;
248 goto fail;
249 }
250
233 hdmi->hdcp_ctrl = hdmi_hdcp_init(hdmi);
251 ret = msm_hdmi_get_phy(hdmi);
252 if (ret) {
253 dev_err(&pdev->dev, "failed to get phy\n");
254 goto fail;
255 }
256
257 hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
234 if (IS_ERR(hdmi->hdcp_ctrl)) {
235 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
236 hdmi->hdcp_ctrl = NULL;
237 }
238
239 return hdmi;
240
241fail:
242 if (hdmi)
258 if (IS_ERR(hdmi->hdcp_ctrl)) {
259 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
260 hdmi->hdcp_ctrl = NULL;
261 }
262
263 return hdmi;
264
265fail:
266 if (hdmi)
243 hdmi_destroy(hdmi);
267 msm_hdmi_destroy(hdmi);
244
245 return ERR_PTR(ret);
246}
247
248/* Second part of initialization, the drm/kms level modeset_init,
249 * constructs/initializes mode objects, etc, is called from master
250 * driver (not hdmi sub-device's probe/bind!)
251 *
252 * Any resource (regulator/clk/etc) which could be missing at boot
268
269 return ERR_PTR(ret);
270}
271
272/* Second part of initialization, the drm/kms level modeset_init,
273 * constructs/initializes mode objects, etc, is called from master
274 * driver (not hdmi sub-device's probe/bind!)
275 *
276 * Any resource (regulator/clk/etc) which could be missing at boot
253 * should be handled in hdmi_init() so that failure happens from
277 * should be handled in msm_hdmi_init() so that failure happens from
254 * hdmi sub-device's probe.
255 */
278 * hdmi sub-device's probe.
279 */
256int hdmi_modeset_init(struct hdmi *hdmi,
280int msm_hdmi_modeset_init(struct hdmi *hdmi,
257 struct drm_device *dev, struct drm_encoder *encoder)
258{
259 struct msm_drm_private *priv = dev->dev_private;
260 struct platform_device *pdev = hdmi->pdev;
261 int ret;
262
263 hdmi->dev = dev;
264 hdmi->encoder = encoder;
265
266 hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
267
281 struct drm_device *dev, struct drm_encoder *encoder)
282{
283 struct msm_drm_private *priv = dev->dev_private;
284 struct platform_device *pdev = hdmi->pdev;
285 int ret;
286
287 hdmi->dev = dev;
288 hdmi->encoder = encoder;
289
290 hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
291
268 hdmi->bridge = hdmi_bridge_init(hdmi);
292 hdmi->bridge = msm_hdmi_bridge_init(hdmi);
269 if (IS_ERR(hdmi->bridge)) {
270 ret = PTR_ERR(hdmi->bridge);
271 dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret);
272 hdmi->bridge = NULL;
273 goto fail;
274 }
275
293 if (IS_ERR(hdmi->bridge)) {
294 ret = PTR_ERR(hdmi->bridge);
295 dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret);
296 hdmi->bridge = NULL;
297 goto fail;
298 }
299
276 hdmi->connector = hdmi_connector_init(hdmi);
300 hdmi->connector = msm_hdmi_connector_init(hdmi);
277 if (IS_ERR(hdmi->connector)) {
278 ret = PTR_ERR(hdmi->connector);
279 dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret);
280 hdmi->connector = NULL;
281 goto fail;
282 }
283
284 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
285 if (hdmi->irq < 0) {
286 ret = hdmi->irq;
287 dev_err(dev->dev, "failed to get irq: %d\n", ret);
288 goto fail;
289 }
290
291 ret = devm_request_irq(&pdev->dev, hdmi->irq,
301 if (IS_ERR(hdmi->connector)) {
302 ret = PTR_ERR(hdmi->connector);
303 dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret);
304 hdmi->connector = NULL;
305 goto fail;
306 }
307
308 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
309 if (hdmi->irq < 0) {
310 ret = hdmi->irq;
311 dev_err(dev->dev, "failed to get irq: %d\n", ret);
312 goto fail;
313 }
314
315 ret = devm_request_irq(&pdev->dev, hdmi->irq,
292 hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
316 msm_hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
293 "hdmi_isr", hdmi);
294 if (ret < 0) {
295 dev_err(dev->dev, "failed to request IRQ%u: %d\n",
296 hdmi->irq, ret);
297 goto fail;
298 }
299
300 encoder->bridge = hdmi->bridge;
301
302 priv->bridges[priv->num_bridges++] = hdmi->bridge;
303 priv->connectors[priv->num_connectors++] = hdmi->connector;
304
305 platform_set_drvdata(pdev, hdmi);
306
307 return 0;
308
309fail:
310 /* bridge is normally destroyed by drm: */
311 if (hdmi->bridge) {
317 "hdmi_isr", hdmi);
318 if (ret < 0) {
319 dev_err(dev->dev, "failed to request IRQ%u: %d\n",
320 hdmi->irq, ret);
321 goto fail;
322 }
323
324 encoder->bridge = hdmi->bridge;
325
326 priv->bridges[priv->num_bridges++] = hdmi->bridge;
327 priv->connectors[priv->num_connectors++] = hdmi->connector;
328
329 platform_set_drvdata(pdev, hdmi);
330
331 return 0;
332
333fail:
334 /* bridge is normally destroyed by drm: */
335 if (hdmi->bridge) {
312 hdmi_bridge_destroy(hdmi->bridge);
336 msm_hdmi_bridge_destroy(hdmi->bridge);
313 hdmi->bridge = NULL;
314 }
315 if (hdmi->connector) {
316 hdmi->connector->funcs->destroy(hdmi->connector);
317 hdmi->connector = NULL;
318 }
319
320 return ret;

--- 5 unchanged lines hidden (view full) ---

326
327#define HDMI_CFG(item, entry) \
328 .item ## _names = item ##_names_ ## entry, \
329 .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry)
330
331static const char *pwr_reg_names_none[] = {};
332static const char *hpd_reg_names_none[] = {};
333
337 hdmi->bridge = NULL;
338 }
339 if (hdmi->connector) {
340 hdmi->connector->funcs->destroy(hdmi->connector);
341 hdmi->connector = NULL;
342 }
343
344 return ret;

--- 5 unchanged lines hidden (view full) ---

350
351#define HDMI_CFG(item, entry) \
352 .item ## _names = item ##_names_ ## entry, \
353 .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry)
354
355static const char *pwr_reg_names_none[] = {};
356static const char *hpd_reg_names_none[] = {};
357
334static struct hdmi_platform_config hdmi_tx_8660_config = {
335 .phy_init = hdmi_phy_8x60_init,
336};
358static struct hdmi_platform_config hdmi_tx_8660_config;
337
338static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"};
339static const char *hpd_clk_names_8960[] = {"core_clk", "master_iface_clk", "slave_iface_clk"};
340
341static struct hdmi_platform_config hdmi_tx_8960_config = {
359
360static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"};
361static const char *hpd_clk_names_8960[] = {"core_clk", "master_iface_clk", "slave_iface_clk"};
362
363static struct hdmi_platform_config hdmi_tx_8960_config = {
342 .phy_init = hdmi_phy_8960_init,
343 HDMI_CFG(hpd_reg, 8960),
344 HDMI_CFG(hpd_clk, 8960),
345};
346
347static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
348static const char *hpd_reg_names_8x74[] = {"hpd-gdsc", "hpd-5v"};
349static const char *pwr_clk_names_8x74[] = {"extp_clk", "alt_iface_clk"};
350static const char *hpd_clk_names_8x74[] = {"iface_clk", "core_clk", "mdp_core_clk"};
351static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0};
352
353static struct hdmi_platform_config hdmi_tx_8974_config = {
364 HDMI_CFG(hpd_reg, 8960),
365 HDMI_CFG(hpd_clk, 8960),
366};
367
368static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
369static const char *hpd_reg_names_8x74[] = {"hpd-gdsc", "hpd-5v"};
370static const char *pwr_clk_names_8x74[] = {"extp_clk", "alt_iface_clk"};
371static const char *hpd_clk_names_8x74[] = {"iface_clk", "core_clk", "mdp_core_clk"};
372static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0};
373
374static struct hdmi_platform_config hdmi_tx_8974_config = {
354 .phy_init = hdmi_phy_8x74_init,
355 HDMI_CFG(pwr_reg, 8x74),
356 HDMI_CFG(hpd_reg, 8x74),
357 HDMI_CFG(pwr_clk, 8x74),
358 HDMI_CFG(hpd_clk, 8x74),
359 .hpd_freq = hpd_clk_freq_8x74,
360};
361
362static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"};
363
364static struct hdmi_platform_config hdmi_tx_8084_config = {
375 HDMI_CFG(pwr_reg, 8x74),
376 HDMI_CFG(hpd_reg, 8x74),
377 HDMI_CFG(pwr_clk, 8x74),
378 HDMI_CFG(hpd_clk, 8x74),
379 .hpd_freq = hpd_clk_freq_8x74,
380};
381
382static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"};
383
384static struct hdmi_platform_config hdmi_tx_8084_config = {
365 .phy_init = hdmi_phy_8x74_init,
366 HDMI_CFG(pwr_reg, 8x74),
367 HDMI_CFG(hpd_reg, 8084),
368 HDMI_CFG(pwr_clk, 8x74),
369 HDMI_CFG(hpd_clk, 8x74),
370 .hpd_freq = hpd_clk_freq_8x74,
371};
372
373static struct hdmi_platform_config hdmi_tx_8994_config = {
385 HDMI_CFG(pwr_reg, 8x74),
386 HDMI_CFG(hpd_reg, 8084),
387 HDMI_CFG(pwr_clk, 8x74),
388 HDMI_CFG(hpd_clk, 8x74),
389 .hpd_freq = hpd_clk_freq_8x74,
390};
391
392static struct hdmi_platform_config hdmi_tx_8994_config = {
374 .phy_init = NULL, /* nothing to do for this HDMI PHY 20nm */
375 HDMI_CFG(pwr_reg, 8x74),
376 HDMI_CFG(hpd_reg, none),
377 HDMI_CFG(pwr_clk, 8x74),
378 HDMI_CFG(hpd_clk, 8x74),
379 .hpd_freq = hpd_clk_freq_8x74,
380};
381
382static struct hdmi_platform_config hdmi_tx_8996_config = {
393 HDMI_CFG(pwr_reg, 8x74),
394 HDMI_CFG(hpd_reg, none),
395 HDMI_CFG(pwr_clk, 8x74),
396 HDMI_CFG(hpd_clk, 8x74),
397 .hpd_freq = hpd_clk_freq_8x74,
398};
399
400static struct hdmi_platform_config hdmi_tx_8996_config = {
383 .phy_init = NULL,
384 HDMI_CFG(pwr_reg, none),
385 HDMI_CFG(hpd_reg, none),
386 HDMI_CFG(pwr_clk, 8x74),
387 HDMI_CFG(hpd_clk, 8x74),
388 .hpd_freq = hpd_clk_freq_8x74,
389};
390
401 HDMI_CFG(pwr_reg, none),
402 HDMI_CFG(hpd_reg, none),
403 HDMI_CFG(pwr_clk, 8x74),
404 HDMI_CFG(hpd_clk, 8x74),
405 .hpd_freq = hpd_clk_freq_8x74,
406};
407
391static int get_gpio(struct device *dev, struct device_node *of_node, const char *name)
408static const struct {
409 const char *name;
410 const bool output;
411 const int value;
412 const char *label;
413} msm_hdmi_gpio_pdata[] = {
414 { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" },
415 { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" },
416 { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" },
417 { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" },
418 { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" },
419 { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" },
420};
421
422static int msm_hdmi_get_gpio(struct device_node *of_node, const char *name)
392{
393 int gpio = of_get_named_gpio(of_node, name, 0);
394 if (gpio < 0) {
395 char name2[32];
396 snprintf(name2, sizeof(name2), "%s-gpio", name);
397 gpio = of_get_named_gpio(of_node, name2, 0);
398 if (gpio < 0) {
399 DBG("failed to get gpio: %s (%d)", name, gpio);
400 gpio = -1;
401 }
402 }
403 return gpio;
404}
405
423{
424 int gpio = of_get_named_gpio(of_node, name, 0);
425 if (gpio < 0) {
426 char name2[32];
427 snprintf(name2, sizeof(name2), "%s-gpio", name);
428 gpio = of_get_named_gpio(of_node, name2, 0);
429 if (gpio < 0) {
430 DBG("failed to get gpio: %s (%d)", name, gpio);
431 gpio = -1;
432 }
433 }
434 return gpio;
435}
436
406static int hdmi_bind(struct device *dev, struct device *master, void *data)
437static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
407{
408 struct drm_device *drm = dev_get_drvdata(master);
409 struct msm_drm_private *priv = drm->dev_private;
410 static struct hdmi_platform_config *hdmi_cfg;
411 struct hdmi *hdmi;
412 struct device_node *of_node = dev->of_node;
438{
439 struct drm_device *drm = dev_get_drvdata(master);
440 struct msm_drm_private *priv = drm->dev_private;
441 static struct hdmi_platform_config *hdmi_cfg;
442 struct hdmi *hdmi;
443 struct device_node *of_node = dev->of_node;
444 int i;
413
414 hdmi_cfg = (struct hdmi_platform_config *)
415 of_device_get_match_data(dev);
416 if (!hdmi_cfg) {
417 dev_err(dev, "unknown hdmi_cfg: %s\n", of_node->name);
418 return -ENXIO;
419 }
420
421 hdmi_cfg->mmio_name = "core_physical";
422 hdmi_cfg->qfprom_mmio_name = "qfprom_physical";
445
446 hdmi_cfg = (struct hdmi_platform_config *)
447 of_device_get_match_data(dev);
448 if (!hdmi_cfg) {
449 dev_err(dev, "unknown hdmi_cfg: %s\n", of_node->name);
450 return -ENXIO;
451 }
452
453 hdmi_cfg->mmio_name = "core_physical";
454 hdmi_cfg->qfprom_mmio_name = "qfprom_physical";
423 hdmi_cfg->ddc_clk_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-clk");
424 hdmi_cfg->ddc_data_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-data");
425 hdmi_cfg->hpd_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-hpd");
426 hdmi_cfg->mux_en_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-en");
427 hdmi_cfg->mux_sel_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-sel");
428 hdmi_cfg->mux_lpm_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-lpm");
429
455
456 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
457 hdmi_cfg->gpios[i].num = msm_hdmi_get_gpio(of_node,
458 msm_hdmi_gpio_pdata[i].name);
459 hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output;
460 hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value;
461 hdmi_cfg->gpios[i].label = msm_hdmi_gpio_pdata[i].label;
462 }
463
430 dev->platform_data = hdmi_cfg;
431
464 dev->platform_data = hdmi_cfg;
465
432 hdmi = hdmi_init(to_platform_device(dev));
466 hdmi = msm_hdmi_init(to_platform_device(dev));
433 if (IS_ERR(hdmi))
434 return PTR_ERR(hdmi);
435 priv->hdmi = hdmi;
436
437 return 0;
438}
439
467 if (IS_ERR(hdmi))
468 return PTR_ERR(hdmi);
469 priv->hdmi = hdmi;
470
471 return 0;
472}
473
440static void hdmi_unbind(struct device *dev, struct device *master,
474static void msm_hdmi_unbind(struct device *dev, struct device *master,
441 void *data)
442{
443 struct drm_device *drm = dev_get_drvdata(master);
444 struct msm_drm_private *priv = drm->dev_private;
445 if (priv->hdmi) {
475 void *data)
476{
477 struct drm_device *drm = dev_get_drvdata(master);
478 struct msm_drm_private *priv = drm->dev_private;
479 if (priv->hdmi) {
446 hdmi_destroy(priv->hdmi);
480 msm_hdmi_destroy(priv->hdmi);
447 priv->hdmi = NULL;
448 }
449}
450
481 priv->hdmi = NULL;
482 }
483}
484
451static const struct component_ops hdmi_ops = {
452 .bind = hdmi_bind,
453 .unbind = hdmi_unbind,
485static const struct component_ops msm_hdmi_ops = {
486 .bind = msm_hdmi_bind,
487 .unbind = msm_hdmi_unbind,
454};
455
488};
489
456static int hdmi_dev_probe(struct platform_device *pdev)
490static int msm_hdmi_dev_probe(struct platform_device *pdev)
457{
491{
458 return component_add(&pdev->dev, &hdmi_ops);
492 return component_add(&pdev->dev, &msm_hdmi_ops);
459}
460
493}
494
461static int hdmi_dev_remove(struct platform_device *pdev)
495static int msm_hdmi_dev_remove(struct platform_device *pdev)
462{
496{
463 component_del(&pdev->dev, &hdmi_ops);
497 component_del(&pdev->dev, &msm_hdmi_ops);
464 return 0;
465}
466
498 return 0;
499}
500
467static const struct of_device_id dt_match[] = {
501static const struct of_device_id msm_hdmi_dt_match[] = {
468 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8996_config },
469 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8994_config },
470 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config },
471 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
472 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
473 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8660_config },
474 {}
475};
476
502 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8996_config },
503 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8994_config },
504 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config },
505 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
506 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
507 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8660_config },
508 {}
509};
510
477static struct platform_driver hdmi_driver = {
478 .probe = hdmi_dev_probe,
479 .remove = hdmi_dev_remove,
511static struct platform_driver msm_hdmi_driver = {
512 .probe = msm_hdmi_dev_probe,
513 .remove = msm_hdmi_dev_remove,
480 .driver = {
481 .name = "hdmi_msm",
514 .driver = {
515 .name = "hdmi_msm",
482 .of_match_table = dt_match,
516 .of_match_table = msm_hdmi_dt_match,
483 },
484};
485
517 },
518};
519
486void __init hdmi_register(void)
520void __init msm_hdmi_register(void)
487{
521{
488 platform_driver_register(&hdmi_driver);
522 msm_hdmi_phy_driver_register();
523 platform_driver_register(&msm_hdmi_driver);
489}
490
524}
525
491void __exit hdmi_unregister(void)
526void __exit msm_hdmi_unregister(void)
492{
527{
493 platform_driver_unregister(&hdmi_driver);
528 platform_driver_unregister(&msm_hdmi_driver);
529 msm_hdmi_phy_driver_unregister();
494}
530}