1 // SPDX-License-Identifier: GPL-2.0+
3 * i.MX drm driver - LVDS display bridge
5 * Copyright (C) 2012 Sascha Hauer, Pengutronix
9 #include <linux/component.h>
10 #include <linux/i2c.h>
11 #include <linux/media-bus-format.h>
12 #include <linux/mfd/syscon.h>
13 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
14 #include <linux/module.h>
16 #include <linux/of_graph.h>
17 #include <linux/platform_device.h>
18 #include <linux/property.h>
19 #include <linux/regmap.h>
20 #include <linux/videodev2.h>
22 #include <video/of_display_timing.h>
23 #include <video/of_videomode.h>
25 #include <drm/drm_atomic.h>
26 #include <drm/drm_atomic_helper.h>
27 #include <drm/drm_bridge.h>
28 #include <drm/drm_edid.h>
29 #include <drm/drm_managed.h>
30 #include <drm/drm_of.h>
31 #include <drm/drm_panel.h>
32 #include <drm/drm_print.h>
33 #include <drm/drm_probe_helper.h>
34 #include <drm/drm_simple_kms_helper.h>
38 #define DRIVER_NAME "imx-ldb"
40 #define LDB_CH0_MODE_EN_TO_DI0 (1 << 0)
41 #define LDB_CH0_MODE_EN_TO_DI1 (3 << 0)
42 #define LDB_CH0_MODE_EN_MASK (3 << 0)
43 #define LDB_CH1_MODE_EN_TO_DI0 (1 << 2)
44 #define LDB_CH1_MODE_EN_TO_DI1 (3 << 2)
45 #define LDB_CH1_MODE_EN_MASK (3 << 2)
46 #define LDB_SPLIT_MODE_EN (1 << 4)
47 #define LDB_DATA_WIDTH_CH0_24 (1 << 5)
48 #define LDB_BIT_MAP_CH0_JEIDA (1 << 6)
49 #define LDB_DATA_WIDTH_CH1_24 (1 << 7)
50 #define LDB_BIT_MAP_CH1_JEIDA (1 << 8)
51 #define LDB_DI0_VS_POL_ACT_LOW (1 << 9)
52 #define LDB_DI1_VS_POL_ACT_LOW (1 << 10)
53 #define LDB_BGREF_RMODE_INT (1 << 15)
55 struct imx_ldb_channel;
57 struct imx_ldb_encoder {
58 struct drm_connector connector;
59 struct drm_encoder encoder;
60 struct imx_ldb_channel *channel;
65 struct imx_ldb_channel {
68 /* Defines what is connected to the ldb, only one at a time */
69 struct drm_panel *panel;
70 struct drm_bridge *bridge;
72 struct device_node *child;
73 struct i2c_adapter *ddc;
75 const struct drm_edid *drm_edid;
76 struct drm_display_mode mode;
82 static inline struct imx_ldb_channel *con_to_imx_ldb_ch(struct drm_connector *c)
84 return container_of(c, struct imx_ldb_encoder, connector)->channel;
87 static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e)
89 return container_of(e, struct imx_ldb_encoder, encoder)->channel;
99 struct regmap *regmap;
101 struct imx_ldb_channel channel[2];
102 struct clk *clk[2]; /* our own clock */
103 struct clk *clk_sel[4]; /* parent of display clock */
104 struct clk *clk_parent[4]; /* original parent of clk_sel */
105 struct clk *clk_pll[2]; /* upstream clock we can adjust */
107 const struct bus_mux *lvds_mux;
110 static void imx_ldb_ch_set_bus_format(struct imx_ldb_channel *imx_ldb_ch,
113 struct imx_ldb *ldb = imx_ldb_ch->ldb;
114 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
116 switch (bus_format) {
117 case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
119 case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
120 if (imx_ldb_ch->chno == 0 || dual)
121 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24;
122 if (imx_ldb_ch->chno == 1 || dual)
123 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24;
125 case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
126 if (imx_ldb_ch->chno == 0 || dual)
127 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 |
128 LDB_BIT_MAP_CH0_JEIDA;
129 if (imx_ldb_ch->chno == 1 || dual)
130 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 |
131 LDB_BIT_MAP_CH1_JEIDA;
136 static int imx_ldb_connector_get_modes(struct drm_connector *connector)
138 struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
141 num_modes = drm_panel_get_modes(imx_ldb_ch->panel, connector);
145 if (!imx_ldb_ch->drm_edid && imx_ldb_ch->ddc) {
146 imx_ldb_ch->drm_edid = drm_edid_read_ddc(connector,
148 drm_edid_connector_update(connector, imx_ldb_ch->drm_edid);
151 if (imx_ldb_ch->drm_edid)
152 num_modes = drm_edid_connector_add_modes(connector);
154 if (imx_ldb_ch->mode_valid) {
155 struct drm_display_mode *mode;
157 mode = drm_mode_duplicate(connector->dev, &imx_ldb_ch->mode);
160 mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
161 drm_mode_probed_add(connector, mode);
168 static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
169 unsigned long serial_clk, unsigned long di_clk)
173 dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
174 clk_get_rate(ldb->clk_pll[chno]), serial_clk);
175 clk_set_rate(ldb->clk_pll[chno], serial_clk);
177 dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
178 clk_get_rate(ldb->clk_pll[chno]));
180 dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
181 clk_get_rate(ldb->clk[chno]),
183 clk_set_rate(ldb->clk[chno], di_clk);
185 dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
186 clk_get_rate(ldb->clk[chno]));
188 /* set display clock mux to LDB input clock */
189 ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]);
192 "unable to set di%d parent clock to ldb_di%d\n", mux,
196 static void imx_ldb_encoder_enable(struct drm_encoder *encoder)
198 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
199 struct imx_ldb *ldb = imx_ldb_ch->ldb;
200 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
201 int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
203 if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) {
204 dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux);
208 drm_panel_prepare(imx_ldb_ch->panel);
211 clk_set_parent(ldb->clk_sel[mux], ldb->clk[0]);
212 clk_set_parent(ldb->clk_sel[mux], ldb->clk[1]);
214 clk_prepare_enable(ldb->clk[0]);
215 clk_prepare_enable(ldb->clk[1]);
217 clk_set_parent(ldb->clk_sel[mux], ldb->clk[imx_ldb_ch->chno]);
220 if (imx_ldb_ch == &ldb->channel[0] || dual) {
221 ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
222 if (mux == 0 || ldb->lvds_mux)
223 ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI0;
225 ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI1;
227 if (imx_ldb_ch == &ldb->channel[1] || dual) {
228 ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
229 if (mux == 1 || ldb->lvds_mux)
230 ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI1;
232 ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI0;
236 const struct bus_mux *lvds_mux = NULL;
238 if (imx_ldb_ch == &ldb->channel[0])
239 lvds_mux = &ldb->lvds_mux[0];
240 else if (imx_ldb_ch == &ldb->channel[1])
241 lvds_mux = &ldb->lvds_mux[1];
243 regmap_update_bits(ldb->regmap, lvds_mux->reg, lvds_mux->mask,
244 mux << lvds_mux->shift);
247 regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
249 drm_panel_enable(imx_ldb_ch->panel);
253 imx_ldb_encoder_atomic_mode_set(struct drm_encoder *encoder,
254 struct drm_crtc_state *crtc_state,
255 struct drm_connector_state *connector_state)
257 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
258 struct drm_display_mode *mode = &crtc_state->adjusted_mode;
259 struct imx_ldb *ldb = imx_ldb_ch->ldb;
260 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
261 unsigned long serial_clk;
262 unsigned long di_clk = mode->clock * 1000;
263 int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
264 u32 bus_format = imx_ldb_ch->bus_format;
266 if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) {
267 dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux);
271 if (mode->clock > 170000) {
273 "%s: mode exceeds 170 MHz pixel clock\n", __func__);
275 if (mode->clock > 85000 && !dual) {
277 "%s: mode exceeds 85 MHz pixel clock\n", __func__);
280 if (!IS_ALIGNED(mode->hdisplay, 8)) {
282 "%s: hdisplay does not align to 8 byte\n", __func__);
286 serial_clk = 3500UL * mode->clock;
287 imx_ldb_set_clock(ldb, mux, 0, serial_clk, di_clk);
288 imx_ldb_set_clock(ldb, mux, 1, serial_clk, di_clk);
290 serial_clk = 7000UL * mode->clock;
291 imx_ldb_set_clock(ldb, mux, imx_ldb_ch->chno, serial_clk,
295 /* FIXME - assumes straight connections DI0 --> CH0, DI1 --> CH1 */
296 if (imx_ldb_ch == &ldb->channel[0] || dual) {
297 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
298 ldb->ldb_ctrl |= LDB_DI0_VS_POL_ACT_LOW;
299 else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
300 ldb->ldb_ctrl &= ~LDB_DI0_VS_POL_ACT_LOW;
302 if (imx_ldb_ch == &ldb->channel[1] || dual) {
303 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
304 ldb->ldb_ctrl |= LDB_DI1_VS_POL_ACT_LOW;
305 else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
306 ldb->ldb_ctrl &= ~LDB_DI1_VS_POL_ACT_LOW;
310 struct drm_connector *connector = connector_state->connector;
311 struct drm_display_info *di = &connector->display_info;
313 if (di->num_bus_formats)
314 bus_format = di->bus_formats[0];
316 imx_ldb_ch_set_bus_format(imx_ldb_ch, bus_format);
319 static void imx_ldb_encoder_disable(struct drm_encoder *encoder)
321 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
322 struct imx_ldb *ldb = imx_ldb_ch->ldb;
323 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
326 drm_panel_disable(imx_ldb_ch->panel);
328 if (imx_ldb_ch == &ldb->channel[0] || dual)
329 ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
330 if (imx_ldb_ch == &ldb->channel[1] || dual)
331 ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
333 regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
336 clk_disable_unprepare(ldb->clk[0]);
337 clk_disable_unprepare(ldb->clk[1]);
341 const struct bus_mux *lvds_mux = NULL;
343 if (imx_ldb_ch == &ldb->channel[0])
344 lvds_mux = &ldb->lvds_mux[0];
345 else if (imx_ldb_ch == &ldb->channel[1])
346 lvds_mux = &ldb->lvds_mux[1];
348 regmap_read(ldb->regmap, lvds_mux->reg, &mux);
349 mux &= lvds_mux->mask;
350 mux >>= lvds_mux->shift;
352 mux = (imx_ldb_ch == &ldb->channel[0]) ? 0 : 1;
355 /* set display clock mux back to original input clock */
356 ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk_parent[mux]);
359 "unable to set di%d parent clock to original parent\n",
362 drm_panel_unprepare(imx_ldb_ch->panel);
365 static int imx_ldb_encoder_atomic_check(struct drm_encoder *encoder,
366 struct drm_crtc_state *crtc_state,
367 struct drm_connector_state *conn_state)
369 struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
370 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
371 struct drm_display_info *di = &conn_state->connector->display_info;
372 u32 bus_format = imx_ldb_ch->bus_format;
374 /* Bus format description in DT overrides connector display info. */
375 if (!bus_format && di->num_bus_formats) {
376 bus_format = di->bus_formats[0];
377 imx_crtc_state->bus_flags = di->bus_flags;
379 bus_format = imx_ldb_ch->bus_format;
380 imx_crtc_state->bus_flags = imx_ldb_ch->bus_flags;
382 switch (bus_format) {
383 case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
384 imx_crtc_state->bus_format = MEDIA_BUS_FMT_RGB666_1X18;
386 case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
387 case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
388 imx_crtc_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
394 imx_crtc_state->di_hsync_pin = 2;
395 imx_crtc_state->di_vsync_pin = 3;
401 static const struct drm_connector_funcs imx_ldb_connector_funcs = {
402 .fill_modes = drm_helper_probe_single_connector_modes,
403 .destroy = imx_drm_connector_destroy,
404 .reset = drm_atomic_helper_connector_reset,
405 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
406 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
409 static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
410 .get_modes = imx_ldb_connector_get_modes,
413 static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
414 .atomic_mode_set = imx_ldb_encoder_atomic_mode_set,
415 .enable = imx_ldb_encoder_enable,
416 .disable = imx_ldb_encoder_disable,
417 .atomic_check = imx_ldb_encoder_atomic_check,
420 static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno)
424 snprintf(clkname, sizeof(clkname), "di%d", chno);
425 ldb->clk[chno] = devm_clk_get(ldb->dev, clkname);
426 if (IS_ERR(ldb->clk[chno]))
427 return PTR_ERR(ldb->clk[chno]);
429 snprintf(clkname, sizeof(clkname), "di%d_pll", chno);
430 ldb->clk_pll[chno] = devm_clk_get(ldb->dev, clkname);
432 return PTR_ERR_OR_ZERO(ldb->clk_pll[chno]);
435 static int imx_ldb_register(struct drm_device *drm,
436 struct imx_ldb_channel *imx_ldb_ch)
438 struct imx_ldb *ldb = imx_ldb_ch->ldb;
439 struct imx_ldb_encoder *ldb_encoder;
440 struct drm_connector *connector;
441 struct drm_encoder *encoder;
444 ldb_encoder = drmm_simple_encoder_alloc(drm, struct imx_ldb_encoder,
445 encoder, DRM_MODE_ENCODER_LVDS);
446 if (IS_ERR(ldb_encoder))
447 return PTR_ERR(ldb_encoder);
449 ldb_encoder->channel = imx_ldb_ch;
450 connector = &ldb_encoder->connector;
451 encoder = &ldb_encoder->encoder;
453 ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child);
457 ret = imx_ldb_get_clk(ldb, imx_ldb_ch->chno);
461 if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
462 ret = imx_ldb_get_clk(ldb, 1);
467 drm_encoder_helper_add(encoder, &imx_ldb_encoder_helper_funcs);
469 if (imx_ldb_ch->bridge) {
470 ret = drm_bridge_attach(encoder, imx_ldb_ch->bridge, NULL, 0);
475 * We want to add the connector whenever there is no bridge
476 * that brings its own, not only when there is a panel. For
477 * historical reasons, the ldb driver can also work without
480 drm_connector_helper_add(connector,
481 &imx_ldb_connector_helper_funcs);
482 drm_connector_init_with_ddc(drm, connector,
483 &imx_ldb_connector_funcs,
484 DRM_MODE_CONNECTOR_LVDS,
486 drm_connector_attach_encoder(connector, encoder);
492 struct imx_ldb_bit_mapping {
495 const char * const mapping;
498 static const struct imx_ldb_bit_mapping imx_ldb_bit_mappings[] = {
499 { MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, 18, "spwg" },
500 { MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, 24, "spwg" },
501 { MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, 24, "jeida" },
504 static u32 of_get_bus_format(struct device *dev, struct device_node *np)
510 ret = of_property_read_string(np, "fsl,data-mapping", &bm);
514 of_property_read_u32(np, "fsl,data-width", &datawidth);
516 for (i = 0; i < ARRAY_SIZE(imx_ldb_bit_mappings); i++) {
517 if (!strcasecmp(bm, imx_ldb_bit_mappings[i].mapping) &&
518 datawidth == imx_ldb_bit_mappings[i].datawidth)
519 return imx_ldb_bit_mappings[i].bus_format;
522 dev_err(dev, "invalid data mapping: %d-bit \"%s\"\n", datawidth, bm);
527 static struct bus_mux imx6q_lvds_mux[2] = {
531 .mask = IMX6Q_GPR3_LVDS0_MUX_CTL_MASK,
535 .mask = IMX6Q_GPR3_LVDS1_MUX_CTL_MASK,
540 * For a device declaring compatible = "fsl,imx6q-ldb", "fsl,imx53-ldb",
541 * of_match_device will walk through this list and take the first entry
542 * matching any of its compatible values. Therefore, the more generic
543 * entries (in this case fsl,imx53-ldb) need to be ordered last.
545 static const struct of_device_id imx_ldb_dt_ids[] = {
546 { .compatible = "fsl,imx6q-ldb", .data = imx6q_lvds_mux, },
547 { .compatible = "fsl,imx53-ldb", .data = NULL, },
550 MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids);
552 static int imx_ldb_panel_ddc(struct device *dev,
553 struct imx_ldb_channel *channel, struct device_node *child)
555 struct device_node *ddc_node;
558 ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
560 channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
561 of_node_put(ddc_node);
563 dev_warn(dev, "failed to get ddc i2c adapter\n");
564 return -EPROBE_DEFER;
572 /* if no DDC available, fallback to hardcoded EDID */
573 dev_dbg(dev, "no ddc available\n");
575 edidp = of_get_property(child, "edid", &edid_len);
577 channel->drm_edid = drm_edid_alloc(edidp, edid_len);
578 if (!channel->drm_edid)
580 } else if (!channel->panel) {
581 /* fallback to display-timings node */
582 ret = of_get_drm_display_mode(child,
587 channel->mode_valid = 1;
593 static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
595 struct drm_device *drm = data;
596 struct imx_ldb *imx_ldb = dev_get_drvdata(dev);
600 for (i = 0; i < 2; i++) {
601 struct imx_ldb_channel *channel = &imx_ldb->channel[i];
606 ret = imx_ldb_register(drm, channel);
614 static const struct component_ops imx_ldb_ops = {
615 .bind = imx_ldb_bind,
618 static int imx_ldb_probe(struct platform_device *pdev)
620 struct device *dev = &pdev->dev;
621 struct device_node *np = dev->of_node;
622 struct device_node *child;
623 struct imx_ldb *imx_ldb;
628 imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL);
632 imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
633 if (IS_ERR(imx_ldb->regmap)) {
634 dev_err(dev, "failed to get parent regmap\n");
635 return PTR_ERR(imx_ldb->regmap);
638 /* disable LDB by resetting the control register to POR default */
639 regmap_write(imx_ldb->regmap, IOMUXC_GPR2, 0);
642 imx_ldb->lvds_mux = device_get_match_data(dev);
644 dual = of_property_read_bool(np, "fsl,dual-channel");
646 imx_ldb->ldb_ctrl |= LDB_SPLIT_MODE_EN;
649 * There are three different possible clock mux configurations:
650 * i.MX53: ipu1_di0_sel, ipu1_di1_sel
651 * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel
652 * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel
653 * Map them all to di0_sel...di3_sel.
655 for (i = 0; i < 4; i++) {
658 snprintf(clkname, sizeof(clkname), "di%d_sel", i);
659 imx_ldb->clk_sel[i] = devm_clk_get(imx_ldb->dev, clkname);
660 if (IS_ERR(imx_ldb->clk_sel[i])) {
661 ret = PTR_ERR(imx_ldb->clk_sel[i]);
662 imx_ldb->clk_sel[i] = NULL;
666 imx_ldb->clk_parent[i] = clk_get_parent(imx_ldb->clk_sel[i]);
671 for_each_child_of_node(np, child) {
672 struct imx_ldb_channel *channel;
675 ret = of_property_read_u32(child, "reg", &i);
676 if (ret || i < 0 || i > 1) {
681 if (!of_device_is_available(child))
685 dev_warn(dev, "dual-channel mode, ignoring second output\n");
689 channel = &imx_ldb->channel[i];
690 channel->ldb = imx_ldb;
694 * The output port is port@4 with an external 4-port mux or
695 * port@2 with the internal 2-port mux.
697 ret = drm_of_find_panel_or_bridge(child,
698 imx_ldb->lvds_mux ? 4 : 2, 0,
699 &channel->panel, &channel->bridge);
700 if (ret && ret != -ENODEV)
703 /* panel ddc only if there is no bridge */
704 if (!channel->bridge) {
705 ret = imx_ldb_panel_ddc(dev, channel, child);
710 bus_format = of_get_bus_format(dev, child);
711 if (bus_format == -EINVAL) {
713 * If no bus format was specified in the device tree,
714 * we can still get it from the connected panel later.
716 if (channel->panel && channel->panel->funcs &&
717 channel->panel->funcs->get_modes)
720 if (bus_format < 0) {
721 dev_err(dev, "could not determine data mapping: %d\n",
726 channel->bus_format = bus_format;
727 channel->child = child;
730 platform_set_drvdata(pdev, imx_ldb);
732 return component_add(&pdev->dev, &imx_ldb_ops);
739 static void imx_ldb_remove(struct platform_device *pdev)
741 struct imx_ldb *imx_ldb = platform_get_drvdata(pdev);
744 for (i = 0; i < 2; i++) {
745 struct imx_ldb_channel *channel = &imx_ldb->channel[i];
747 drm_edid_free(channel->drm_edid);
748 i2c_put_adapter(channel->ddc);
751 component_del(&pdev->dev, &imx_ldb_ops);
754 static struct platform_driver imx_ldb_driver = {
755 .probe = imx_ldb_probe,
756 .remove_new = imx_ldb_remove,
758 .of_match_table = imx_ldb_dt_ids,
763 module_platform_driver(imx_ldb_driver);
765 MODULE_DESCRIPTION("i.MX LVDS driver");
766 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
767 MODULE_LICENSE("GPL");
768 MODULE_ALIAS("platform:" DRIVER_NAME);