2 * i.MX drm driver - LVDS display bridge
4 * Copyright (C) 2012 Sascha Hauer, Pengutronix
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <linux/module.h>
17 #include <linux/clk.h>
18 #include <linux/component.h>
20 #include <drm/drm_fb_helper.h>
21 #include <drm/drm_crtc_helper.h>
22 #include <drm/drm_of.h>
23 #include <drm/drm_panel.h>
24 #include <linux/mfd/syscon.h>
25 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
26 #include <linux/of_device.h>
27 #include <linux/of_graph.h>
28 #include <video/of_videomode.h>
29 #include <linux/regmap.h>
30 #include <linux/videodev2.h>
34 #define DRIVER_NAME "imx-ldb"
36 #define LDB_CH0_MODE_EN_TO_DI0 (1 << 0)
37 #define LDB_CH0_MODE_EN_TO_DI1 (3 << 0)
38 #define LDB_CH0_MODE_EN_MASK (3 << 0)
39 #define LDB_CH1_MODE_EN_TO_DI0 (1 << 2)
40 #define LDB_CH1_MODE_EN_TO_DI1 (3 << 2)
41 #define LDB_CH1_MODE_EN_MASK (3 << 2)
42 #define LDB_SPLIT_MODE_EN (1 << 4)
43 #define LDB_DATA_WIDTH_CH0_24 (1 << 5)
44 #define LDB_BIT_MAP_CH0_JEIDA (1 << 6)
45 #define LDB_DATA_WIDTH_CH1_24 (1 << 7)
46 #define LDB_BIT_MAP_CH1_JEIDA (1 << 8)
47 #define LDB_DI0_VS_POL_ACT_LOW (1 << 9)
48 #define LDB_DI1_VS_POL_ACT_LOW (1 << 10)
49 #define LDB_BGREF_RMODE_INT (1 << 15)
51 #define con_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, connector)
52 #define enc_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, encoder)
56 struct imx_ldb_channel
{
58 struct drm_connector connector
;
59 struct drm_encoder encoder
;
60 struct drm_panel
*panel
;
61 struct device_node
*child
;
62 struct i2c_adapter
*ddc
;
66 struct drm_display_mode mode
;
78 struct regmap
*regmap
;
80 struct imx_ldb_channel channel
[2];
81 struct clk
*clk
[2]; /* our own clock */
82 struct clk
*clk_sel
[4]; /* parent of display clock */
83 struct clk
*clk_parent
[4]; /* original parent of clk_sel */
84 struct clk
*clk_pll
[2]; /* upstream clock we can adjust */
86 const struct bus_mux
*lvds_mux
;
89 static enum drm_connector_status
imx_ldb_connector_detect(
90 struct drm_connector
*connector
, bool force
)
92 return connector_status_connected
;
95 static int imx_ldb_connector_get_modes(struct drm_connector
*connector
)
97 struct imx_ldb_channel
*imx_ldb_ch
= con_to_imx_ldb_ch(connector
);
100 if (imx_ldb_ch
->panel
&& imx_ldb_ch
->panel
->funcs
&&
101 imx_ldb_ch
->panel
->funcs
->get_modes
) {
102 struct drm_display_info
*di
= &connector
->display_info
;
104 num_modes
= imx_ldb_ch
->panel
->funcs
->get_modes(imx_ldb_ch
->panel
);
105 if (!imx_ldb_ch
->bus_format
&& di
->num_bus_formats
)
106 imx_ldb_ch
->bus_format
= di
->bus_formats
[0];
111 if (!imx_ldb_ch
->edid
&& imx_ldb_ch
->ddc
)
112 imx_ldb_ch
->edid
= drm_get_edid(connector
, imx_ldb_ch
->ddc
);
114 if (imx_ldb_ch
->edid
) {
115 drm_mode_connector_update_edid_property(connector
,
117 num_modes
= drm_add_edid_modes(connector
, imx_ldb_ch
->edid
);
120 if (imx_ldb_ch
->mode_valid
) {
121 struct drm_display_mode
*mode
;
123 mode
= drm_mode_create(connector
->dev
);
126 drm_mode_copy(mode
, &imx_ldb_ch
->mode
);
127 mode
->type
|= DRM_MODE_TYPE_DRIVER
| DRM_MODE_TYPE_PREFERRED
;
128 drm_mode_probed_add(connector
, mode
);
135 static struct drm_encoder
*imx_ldb_connector_best_encoder(
136 struct drm_connector
*connector
)
138 struct imx_ldb_channel
*imx_ldb_ch
= con_to_imx_ldb_ch(connector
);
140 return &imx_ldb_ch
->encoder
;
143 static void imx_ldb_encoder_dpms(struct drm_encoder
*encoder
, int mode
)
147 static void imx_ldb_set_clock(struct imx_ldb
*ldb
, int mux
, int chno
,
148 unsigned long serial_clk
, unsigned long di_clk
)
152 dev_dbg(ldb
->dev
, "%s: now: %ld want: %ld\n", __func__
,
153 clk_get_rate(ldb
->clk_pll
[chno
]), serial_clk
);
154 clk_set_rate(ldb
->clk_pll
[chno
], serial_clk
);
156 dev_dbg(ldb
->dev
, "%s after: %ld\n", __func__
,
157 clk_get_rate(ldb
->clk_pll
[chno
]));
159 dev_dbg(ldb
->dev
, "%s: now: %ld want: %ld\n", __func__
,
160 clk_get_rate(ldb
->clk
[chno
]),
162 clk_set_rate(ldb
->clk
[chno
], di_clk
);
164 dev_dbg(ldb
->dev
, "%s after: %ld\n", __func__
,
165 clk_get_rate(ldb
->clk
[chno
]));
167 /* set display clock mux to LDB input clock */
168 ret
= clk_set_parent(ldb
->clk_sel
[mux
], ldb
->clk
[chno
]);
171 "unable to set di%d parent clock to ldb_di%d\n", mux
,
175 static void imx_ldb_encoder_prepare(struct drm_encoder
*encoder
)
177 struct imx_ldb_channel
*imx_ldb_ch
= enc_to_imx_ldb_ch(encoder
);
178 struct imx_ldb
*ldb
= imx_ldb_ch
->ldb
;
179 int dual
= ldb
->ldb_ctrl
& LDB_SPLIT_MODE_EN
;
182 switch (imx_ldb_ch
->bus_format
) {
185 "could not determine data mapping, default to 18-bit \"spwg\"\n");
187 case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG
:
188 bus_format
= MEDIA_BUS_FMT_RGB666_1X18
;
190 case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG
:
191 bus_format
= MEDIA_BUS_FMT_RGB888_1X24
;
192 if (imx_ldb_ch
->chno
== 0 || dual
)
193 ldb
->ldb_ctrl
|= LDB_DATA_WIDTH_CH0_24
;
194 if (imx_ldb_ch
->chno
== 1 || dual
)
195 ldb
->ldb_ctrl
|= LDB_DATA_WIDTH_CH1_24
;
197 case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA
:
198 bus_format
= MEDIA_BUS_FMT_RGB888_1X24
;
199 if (imx_ldb_ch
->chno
== 0 || dual
)
200 ldb
->ldb_ctrl
|= LDB_DATA_WIDTH_CH0_24
|
201 LDB_BIT_MAP_CH0_JEIDA
;
202 if (imx_ldb_ch
->chno
== 1 || dual
)
203 ldb
->ldb_ctrl
|= LDB_DATA_WIDTH_CH1_24
|
204 LDB_BIT_MAP_CH1_JEIDA
;
208 imx_drm_set_bus_format(encoder
, bus_format
);
211 static void imx_ldb_encoder_commit(struct drm_encoder
*encoder
)
213 struct imx_ldb_channel
*imx_ldb_ch
= enc_to_imx_ldb_ch(encoder
);
214 struct imx_ldb
*ldb
= imx_ldb_ch
->ldb
;
215 int dual
= ldb
->ldb_ctrl
& LDB_SPLIT_MODE_EN
;
216 int mux
= drm_of_encoder_active_port_id(imx_ldb_ch
->child
, encoder
);
218 drm_panel_prepare(imx_ldb_ch
->panel
);
221 clk_prepare_enable(ldb
->clk
[0]);
222 clk_prepare_enable(ldb
->clk
[1]);
225 if (imx_ldb_ch
== &ldb
->channel
[0] || dual
) {
226 ldb
->ldb_ctrl
&= ~LDB_CH0_MODE_EN_MASK
;
227 if (mux
== 0 || ldb
->lvds_mux
)
228 ldb
->ldb_ctrl
|= LDB_CH0_MODE_EN_TO_DI0
;
230 ldb
->ldb_ctrl
|= LDB_CH0_MODE_EN_TO_DI1
;
232 if (imx_ldb_ch
== &ldb
->channel
[1] || dual
) {
233 ldb
->ldb_ctrl
&= ~LDB_CH1_MODE_EN_MASK
;
234 if (mux
== 1 || ldb
->lvds_mux
)
235 ldb
->ldb_ctrl
|= LDB_CH1_MODE_EN_TO_DI1
;
237 ldb
->ldb_ctrl
|= LDB_CH1_MODE_EN_TO_DI0
;
241 const struct bus_mux
*lvds_mux
= NULL
;
243 if (imx_ldb_ch
== &ldb
->channel
[0])
244 lvds_mux
= &ldb
->lvds_mux
[0];
245 else if (imx_ldb_ch
== &ldb
->channel
[1])
246 lvds_mux
= &ldb
->lvds_mux
[1];
248 regmap_update_bits(ldb
->regmap
, lvds_mux
->reg
, lvds_mux
->mask
,
249 mux
<< lvds_mux
->shift
);
252 regmap_write(ldb
->regmap
, IOMUXC_GPR2
, ldb
->ldb_ctrl
);
254 drm_panel_enable(imx_ldb_ch
->panel
);
257 static void imx_ldb_encoder_mode_set(struct drm_encoder
*encoder
,
258 struct drm_display_mode
*orig_mode
,
259 struct drm_display_mode
*mode
)
261 struct imx_ldb_channel
*imx_ldb_ch
= enc_to_imx_ldb_ch(encoder
);
262 struct imx_ldb
*ldb
= imx_ldb_ch
->ldb
;
263 int dual
= ldb
->ldb_ctrl
& LDB_SPLIT_MODE_EN
;
264 unsigned long serial_clk
;
265 unsigned long di_clk
= mode
->clock
* 1000;
266 int mux
= drm_of_encoder_active_port_id(imx_ldb_ch
->child
, encoder
);
268 if (mode
->clock
> 170000) {
270 "%s: mode exceeds 170 MHz pixel clock\n", __func__
);
272 if (mode
->clock
> 85000 && !dual
) {
274 "%s: mode exceeds 85 MHz pixel clock\n", __func__
);
278 serial_clk
= 3500UL * mode
->clock
;
279 imx_ldb_set_clock(ldb
, mux
, 0, serial_clk
, di_clk
);
280 imx_ldb_set_clock(ldb
, mux
, 1, serial_clk
, di_clk
);
282 serial_clk
= 7000UL * mode
->clock
;
283 imx_ldb_set_clock(ldb
, mux
, imx_ldb_ch
->chno
, serial_clk
,
287 /* FIXME - assumes straight connections DI0 --> CH0, DI1 --> CH1 */
288 if (imx_ldb_ch
== &ldb
->channel
[0]) {
289 if (mode
->flags
& DRM_MODE_FLAG_NVSYNC
)
290 ldb
->ldb_ctrl
|= LDB_DI0_VS_POL_ACT_LOW
;
291 else if (mode
->flags
& DRM_MODE_FLAG_PVSYNC
)
292 ldb
->ldb_ctrl
&= ~LDB_DI0_VS_POL_ACT_LOW
;
294 if (imx_ldb_ch
== &ldb
->channel
[1]) {
295 if (mode
->flags
& DRM_MODE_FLAG_NVSYNC
)
296 ldb
->ldb_ctrl
|= LDB_DI1_VS_POL_ACT_LOW
;
297 else if (mode
->flags
& DRM_MODE_FLAG_PVSYNC
)
298 ldb
->ldb_ctrl
&= ~LDB_DI1_VS_POL_ACT_LOW
;
302 static void imx_ldb_encoder_disable(struct drm_encoder
*encoder
)
304 struct imx_ldb_channel
*imx_ldb_ch
= enc_to_imx_ldb_ch(encoder
);
305 struct imx_ldb
*ldb
= imx_ldb_ch
->ldb
;
309 * imx_ldb_encoder_disable is called by
310 * drm_helper_disable_unused_functions without
311 * the encoder being enabled before.
313 if (imx_ldb_ch
== &ldb
->channel
[0] &&
314 (ldb
->ldb_ctrl
& LDB_CH0_MODE_EN_MASK
) == 0)
316 else if (imx_ldb_ch
== &ldb
->channel
[1] &&
317 (ldb
->ldb_ctrl
& LDB_CH1_MODE_EN_MASK
) == 0)
320 drm_panel_disable(imx_ldb_ch
->panel
);
322 if (imx_ldb_ch
== &ldb
->channel
[0])
323 ldb
->ldb_ctrl
&= ~LDB_CH0_MODE_EN_MASK
;
324 else if (imx_ldb_ch
== &ldb
->channel
[1])
325 ldb
->ldb_ctrl
&= ~LDB_CH1_MODE_EN_MASK
;
327 regmap_write(ldb
->regmap
, IOMUXC_GPR2
, ldb
->ldb_ctrl
);
329 if (ldb
->ldb_ctrl
& LDB_SPLIT_MODE_EN
) {
330 clk_disable_unprepare(ldb
->clk
[0]);
331 clk_disable_unprepare(ldb
->clk
[1]);
335 const struct bus_mux
*lvds_mux
= NULL
;
337 if (imx_ldb_ch
== &ldb
->channel
[0])
338 lvds_mux
= &ldb
->lvds_mux
[0];
339 else if (imx_ldb_ch
== &ldb
->channel
[1])
340 lvds_mux
= &ldb
->lvds_mux
[1];
342 regmap_read(ldb
->regmap
, lvds_mux
->reg
, &mux
);
343 mux
&= lvds_mux
->mask
;
344 mux
>>= lvds_mux
->shift
;
346 mux
= (imx_ldb_ch
== &ldb
->channel
[0]) ? 0 : 1;
349 /* set display clock mux back to original input clock */
350 ret
= clk_set_parent(ldb
->clk_sel
[mux
], ldb
->clk_parent
[mux
]);
353 "unable to set di%d parent clock to original parent\n",
356 drm_panel_unprepare(imx_ldb_ch
->panel
);
359 static const struct drm_connector_funcs imx_ldb_connector_funcs
= {
360 .dpms
= drm_helper_connector_dpms
,
361 .fill_modes
= drm_helper_probe_single_connector_modes
,
362 .detect
= imx_ldb_connector_detect
,
363 .destroy
= imx_drm_connector_destroy
,
366 static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs
= {
367 .get_modes
= imx_ldb_connector_get_modes
,
368 .best_encoder
= imx_ldb_connector_best_encoder
,
371 static const struct drm_encoder_funcs imx_ldb_encoder_funcs
= {
372 .destroy
= imx_drm_encoder_destroy
,
375 static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs
= {
376 .dpms
= imx_ldb_encoder_dpms
,
377 .prepare
= imx_ldb_encoder_prepare
,
378 .commit
= imx_ldb_encoder_commit
,
379 .mode_set
= imx_ldb_encoder_mode_set
,
380 .disable
= imx_ldb_encoder_disable
,
383 static int imx_ldb_get_clk(struct imx_ldb
*ldb
, int chno
)
387 snprintf(clkname
, sizeof(clkname
), "di%d", chno
);
388 ldb
->clk
[chno
] = devm_clk_get(ldb
->dev
, clkname
);
389 if (IS_ERR(ldb
->clk
[chno
]))
390 return PTR_ERR(ldb
->clk
[chno
]);
392 snprintf(clkname
, sizeof(clkname
), "di%d_pll", chno
);
393 ldb
->clk_pll
[chno
] = devm_clk_get(ldb
->dev
, clkname
);
395 return PTR_ERR_OR_ZERO(ldb
->clk_pll
[chno
]);
398 static int imx_ldb_register(struct drm_device
*drm
,
399 struct imx_ldb_channel
*imx_ldb_ch
)
401 struct imx_ldb
*ldb
= imx_ldb_ch
->ldb
;
404 ret
= imx_drm_encoder_parse_of(drm
, &imx_ldb_ch
->encoder
,
409 ret
= imx_ldb_get_clk(ldb
, imx_ldb_ch
->chno
);
413 if (ldb
->ldb_ctrl
& LDB_SPLIT_MODE_EN
) {
414 ret
= imx_ldb_get_clk(ldb
, 1);
419 drm_encoder_helper_add(&imx_ldb_ch
->encoder
,
420 &imx_ldb_encoder_helper_funcs
);
421 drm_encoder_init(drm
, &imx_ldb_ch
->encoder
, &imx_ldb_encoder_funcs
,
422 DRM_MODE_ENCODER_LVDS
, NULL
);
424 drm_connector_helper_add(&imx_ldb_ch
->connector
,
425 &imx_ldb_connector_helper_funcs
);
426 drm_connector_init(drm
, &imx_ldb_ch
->connector
,
427 &imx_ldb_connector_funcs
, DRM_MODE_CONNECTOR_LVDS
);
429 if (imx_ldb_ch
->panel
)
430 drm_panel_attach(imx_ldb_ch
->panel
, &imx_ldb_ch
->connector
);
432 drm_mode_connector_attach_encoder(&imx_ldb_ch
->connector
,
433 &imx_ldb_ch
->encoder
);
443 struct imx_ldb_bit_mapping
{
446 const char * const mapping
;
449 static const struct imx_ldb_bit_mapping imx_ldb_bit_mappings
[] = {
450 { MEDIA_BUS_FMT_RGB666_1X7X3_SPWG
, 18, "spwg" },
451 { MEDIA_BUS_FMT_RGB888_1X7X4_SPWG
, 24, "spwg" },
452 { MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA
, 24, "jeida" },
455 static u32
of_get_bus_format(struct device
*dev
, struct device_node
*np
)
461 ret
= of_property_read_string(np
, "fsl,data-mapping", &bm
);
465 of_property_read_u32(np
, "fsl,data-width", &datawidth
);
467 for (i
= 0; i
< ARRAY_SIZE(imx_ldb_bit_mappings
); i
++) {
468 if (!strcasecmp(bm
, imx_ldb_bit_mappings
[i
].mapping
) &&
469 datawidth
== imx_ldb_bit_mappings
[i
].datawidth
)
470 return imx_ldb_bit_mappings
[i
].bus_format
;
473 dev_err(dev
, "invalid data mapping: %d-bit \"%s\"\n", datawidth
, bm
);
478 static struct bus_mux imx6q_lvds_mux
[2] = {
482 .mask
= IMX6Q_GPR3_LVDS0_MUX_CTL_MASK
,
486 .mask
= IMX6Q_GPR3_LVDS1_MUX_CTL_MASK
,
491 * For a device declaring compatible = "fsl,imx6q-ldb", "fsl,imx53-ldb",
492 * of_match_device will walk through this list and take the first entry
493 * matching any of its compatible values. Therefore, the more generic
494 * entries (in this case fsl,imx53-ldb) need to be ordered last.
496 static const struct of_device_id imx_ldb_dt_ids
[] = {
497 { .compatible
= "fsl,imx6q-ldb", .data
= imx6q_lvds_mux
, },
498 { .compatible
= "fsl,imx53-ldb", .data
= NULL
, },
501 MODULE_DEVICE_TABLE(of
, imx_ldb_dt_ids
);
503 static int imx_ldb_bind(struct device
*dev
, struct device
*master
, void *data
)
505 struct drm_device
*drm
= data
;
506 struct device_node
*np
= dev
->of_node
;
507 const struct of_device_id
*of_id
=
508 of_match_device(imx_ldb_dt_ids
, dev
);
509 struct device_node
*child
;
511 struct imx_ldb
*imx_ldb
;
516 imx_ldb
= devm_kzalloc(dev
, sizeof(*imx_ldb
), GFP_KERNEL
);
520 imx_ldb
->regmap
= syscon_regmap_lookup_by_phandle(np
, "gpr");
521 if (IS_ERR(imx_ldb
->regmap
)) {
522 dev_err(dev
, "failed to get parent regmap\n");
523 return PTR_ERR(imx_ldb
->regmap
);
529 imx_ldb
->lvds_mux
= of_id
->data
;
531 dual
= of_property_read_bool(np
, "fsl,dual-channel");
533 imx_ldb
->ldb_ctrl
|= LDB_SPLIT_MODE_EN
;
536 * There are three different possible clock mux configurations:
537 * i.MX53: ipu1_di0_sel, ipu1_di1_sel
538 * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel
539 * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel
540 * Map them all to di0_sel...di3_sel.
542 for (i
= 0; i
< 4; i
++) {
545 sprintf(clkname
, "di%d_sel", i
);
546 imx_ldb
->clk_sel
[i
] = devm_clk_get(imx_ldb
->dev
, clkname
);
547 if (IS_ERR(imx_ldb
->clk_sel
[i
])) {
548 ret
= PTR_ERR(imx_ldb
->clk_sel
[i
]);
549 imx_ldb
->clk_sel
[i
] = NULL
;
553 imx_ldb
->clk_parent
[i
] = clk_get_parent(imx_ldb
->clk_sel
[i
]);
558 for_each_child_of_node(np
, child
) {
559 struct imx_ldb_channel
*channel
;
560 struct device_node
*ddc_node
;
561 struct device_node
*ep
;
563 ret
= of_property_read_u32(child
, "reg", &i
);
564 if (ret
|| i
< 0 || i
> 1)
568 dev_warn(dev
, "dual-channel mode, ignoring second output\n");
572 if (!of_device_is_available(child
))
575 channel
= &imx_ldb
->channel
[i
];
576 channel
->ldb
= imx_ldb
;
578 channel
->child
= child
;
581 * The output port is port@4 with an external 4-port mux or
582 * port@2 with the internal 2-port mux.
584 ep
= of_graph_get_endpoint_by_regs(child
,
585 imx_ldb
->lvds_mux
? 4 : 2,
588 struct device_node
*remote
;
590 remote
= of_graph_get_remote_port_parent(ep
);
593 channel
->panel
= of_drm_find_panel(remote
);
595 return -EPROBE_DEFER
;
597 if (!channel
->panel
) {
598 dev_err(dev
, "panel not found: %s\n",
600 return -EPROBE_DEFER
;
604 ddc_node
= of_parse_phandle(child
, "ddc-i2c-bus", 0);
606 channel
->ddc
= of_find_i2c_adapter_by_node(ddc_node
);
607 of_node_put(ddc_node
);
609 dev_warn(dev
, "failed to get ddc i2c adapter\n");
610 return -EPROBE_DEFER
;
615 /* if no DDC available, fallback to hardcoded EDID */
616 dev_dbg(dev
, "no ddc available\n");
618 edidp
= of_get_property(child
, "edid",
621 channel
->edid
= kmemdup(edidp
,
624 } else if (!channel
->panel
) {
625 /* fallback to display-timings node */
626 ret
= of_get_drm_display_mode(child
,
630 channel
->mode_valid
= 1;
634 channel
->bus_format
= of_get_bus_format(dev
, child
);
635 if (channel
->bus_format
== -EINVAL
) {
637 * If no bus format was specified in the device tree,
638 * we can still get it from the connected panel later.
640 if (channel
->panel
&& channel
->panel
->funcs
&&
641 channel
->panel
->funcs
->get_modes
)
642 channel
->bus_format
= 0;
644 if (channel
->bus_format
< 0) {
645 dev_err(dev
, "could not determine data mapping: %d\n",
646 channel
->bus_format
);
647 return channel
->bus_format
;
650 ret
= imx_ldb_register(drm
, channel
);
655 dev_set_drvdata(dev
, imx_ldb
);
660 static void imx_ldb_unbind(struct device
*dev
, struct device
*master
,
663 struct imx_ldb
*imx_ldb
= dev_get_drvdata(dev
);
666 for (i
= 0; i
< 2; i
++) {
667 struct imx_ldb_channel
*channel
= &imx_ldb
->channel
[i
];
669 if (!channel
->connector
.funcs
)
672 channel
->connector
.funcs
->destroy(&channel
->connector
);
673 channel
->encoder
.funcs
->destroy(&channel
->encoder
);
675 kfree(channel
->edid
);
676 i2c_put_adapter(channel
->ddc
);
680 static const struct component_ops imx_ldb_ops
= {
681 .bind
= imx_ldb_bind
,
682 .unbind
= imx_ldb_unbind
,
685 static int imx_ldb_probe(struct platform_device
*pdev
)
687 return component_add(&pdev
->dev
, &imx_ldb_ops
);
690 static int imx_ldb_remove(struct platform_device
*pdev
)
692 component_del(&pdev
->dev
, &imx_ldb_ops
);
696 static struct platform_driver imx_ldb_driver
= {
697 .probe
= imx_ldb_probe
,
698 .remove
= imx_ldb_remove
,
700 .of_match_table
= imx_ldb_dt_ids
,
705 module_platform_driver(imx_ldb_driver
);
707 MODULE_DESCRIPTION("i.MX LVDS driver");
708 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
709 MODULE_LICENSE("GPL");
710 MODULE_ALIAS("platform:" DRIVER_NAME
);