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_atomic.h>
21 #include <drm/drm_atomic_helper.h>
22 #include <drm/drm_fb_helper.h>
23 #include <drm/drm_crtc_helper.h>
24 #include <drm/drm_of.h>
25 #include <drm/drm_panel.h>
26 #include <linux/mfd/syscon.h>
27 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
28 #include <linux/of_device.h>
29 #include <linux/of_graph.h>
30 #include <video/of_display_timing.h>
31 #include <video/of_videomode.h>
32 #include <linux/regmap.h>
33 #include <linux/videodev2.h>
37 #define DRIVER_NAME "imx-ldb"
39 #define LDB_CH0_MODE_EN_TO_DI0 (1 << 0)
40 #define LDB_CH0_MODE_EN_TO_DI1 (3 << 0)
41 #define LDB_CH0_MODE_EN_MASK (3 << 0)
42 #define LDB_CH1_MODE_EN_TO_DI0 (1 << 2)
43 #define LDB_CH1_MODE_EN_TO_DI1 (3 << 2)
44 #define LDB_CH1_MODE_EN_MASK (3 << 2)
45 #define LDB_SPLIT_MODE_EN (1 << 4)
46 #define LDB_DATA_WIDTH_CH0_24 (1 << 5)
47 #define LDB_BIT_MAP_CH0_JEIDA (1 << 6)
48 #define LDB_DATA_WIDTH_CH1_24 (1 << 7)
49 #define LDB_BIT_MAP_CH1_JEIDA (1 << 8)
50 #define LDB_DI0_VS_POL_ACT_LOW (1 << 9)
51 #define LDB_DI1_VS_POL_ACT_LOW (1 << 10)
52 #define LDB_BGREF_RMODE_INT (1 << 15)
56 struct imx_ldb_channel {
58 struct drm_connector connector;
59 struct drm_encoder encoder;
61 /* Defines what is connected to the ldb, only one at a time */
62 struct drm_panel *panel;
63 struct drm_bridge *bridge;
65 struct device_node *child;
66 struct i2c_adapter *ddc;
70 struct drm_display_mode mode;
76 static inline struct imx_ldb_channel *con_to_imx_ldb_ch(struct drm_connector *c)
78 return container_of(c, struct imx_ldb_channel, connector);
81 static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e)
83 return container_of(e, struct imx_ldb_channel, encoder);
93 struct regmap *regmap;
95 struct imx_ldb_channel channel[2];
96 struct clk *clk[2]; /* our own clock */
97 struct clk *clk_sel[4]; /* parent of display clock */
98 struct clk *clk_parent[4]; /* original parent of clk_sel */
99 struct clk *clk_pll[2]; /* upstream clock we can adjust */
101 const struct bus_mux *lvds_mux;
104 static void imx_ldb_ch_set_bus_format(struct imx_ldb_channel *imx_ldb_ch,
107 struct imx_ldb *ldb = imx_ldb_ch->ldb;
108 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
110 switch (bus_format) {
111 case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
113 case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
114 if (imx_ldb_ch->chno == 0 || dual)
115 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24;
116 if (imx_ldb_ch->chno == 1 || dual)
117 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24;
119 case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
120 if (imx_ldb_ch->chno == 0 || dual)
121 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 |
122 LDB_BIT_MAP_CH0_JEIDA;
123 if (imx_ldb_ch->chno == 1 || dual)
124 ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 |
125 LDB_BIT_MAP_CH1_JEIDA;
130 static int imx_ldb_connector_get_modes(struct drm_connector *connector)
132 struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
135 if (imx_ldb_ch->panel && imx_ldb_ch->panel->funcs &&
136 imx_ldb_ch->panel->funcs->get_modes) {
137 num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
142 if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
143 imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
145 if (imx_ldb_ch->edid) {
146 drm_connector_update_edid_property(connector,
148 num_modes = drm_add_edid_modes(connector, imx_ldb_ch->edid);
151 if (imx_ldb_ch->mode_valid) {
152 struct drm_display_mode *mode;
154 mode = drm_mode_create(connector->dev);
157 drm_mode_copy(mode, &imx_ldb_ch->mode);
158 mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
159 drm_mode_probed_add(connector, mode);
166 static struct drm_encoder *imx_ldb_connector_best_encoder(
167 struct drm_connector *connector)
169 struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
171 return &imx_ldb_ch->encoder;
174 static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
175 unsigned long serial_clk, unsigned long di_clk)
179 dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
180 clk_get_rate(ldb->clk_pll[chno]), serial_clk);
181 clk_set_rate(ldb->clk_pll[chno], serial_clk);
183 dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
184 clk_get_rate(ldb->clk_pll[chno]));
186 dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
187 clk_get_rate(ldb->clk[chno]),
189 clk_set_rate(ldb->clk[chno], di_clk);
191 dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
192 clk_get_rate(ldb->clk[chno]));
194 /* set display clock mux to LDB input clock */
195 ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]);
198 "unable to set di%d parent clock to ldb_di%d\n", mux,
202 static void imx_ldb_encoder_enable(struct drm_encoder *encoder)
204 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
205 struct imx_ldb *ldb = imx_ldb_ch->ldb;
206 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
207 int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
209 if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) {
210 dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux);
214 drm_panel_prepare(imx_ldb_ch->panel);
217 clk_set_parent(ldb->clk_sel[mux], ldb->clk[0]);
218 clk_set_parent(ldb->clk_sel[mux], ldb->clk[1]);
220 clk_prepare_enable(ldb->clk[0]);
221 clk_prepare_enable(ldb->clk[1]);
223 clk_set_parent(ldb->clk_sel[mux], ldb->clk[imx_ldb_ch->chno]);
226 if (imx_ldb_ch == &ldb->channel[0] || dual) {
227 ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
228 if (mux == 0 || ldb->lvds_mux)
229 ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI0;
231 ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI1;
233 if (imx_ldb_ch == &ldb->channel[1] || dual) {
234 ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
235 if (mux == 1 || ldb->lvds_mux)
236 ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI1;
238 ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI0;
242 const struct bus_mux *lvds_mux = NULL;
244 if (imx_ldb_ch == &ldb->channel[0])
245 lvds_mux = &ldb->lvds_mux[0];
246 else if (imx_ldb_ch == &ldb->channel[1])
247 lvds_mux = &ldb->lvds_mux[1];
249 regmap_update_bits(ldb->regmap, lvds_mux->reg, lvds_mux->mask,
250 mux << lvds_mux->shift);
253 regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
255 drm_panel_enable(imx_ldb_ch->panel);
259 imx_ldb_encoder_atomic_mode_set(struct drm_encoder *encoder,
260 struct drm_crtc_state *crtc_state,
261 struct drm_connector_state *connector_state)
263 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
264 struct drm_display_mode *mode = &crtc_state->adjusted_mode;
265 struct imx_ldb *ldb = imx_ldb_ch->ldb;
266 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
267 unsigned long serial_clk;
268 unsigned long di_clk = mode->clock * 1000;
269 int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
270 u32 bus_format = imx_ldb_ch->bus_format;
272 if (mux < 0 || mux >= ARRAY_SIZE(ldb->clk_sel)) {
273 dev_warn(ldb->dev, "%s: invalid mux %d\n", __func__, mux);
277 if (mode->clock > 170000) {
279 "%s: mode exceeds 170 MHz pixel clock\n", __func__);
281 if (mode->clock > 85000 && !dual) {
283 "%s: mode exceeds 85 MHz pixel clock\n", __func__);
287 serial_clk = 3500UL * mode->clock;
288 imx_ldb_set_clock(ldb, mux, 0, serial_clk, di_clk);
289 imx_ldb_set_clock(ldb, mux, 1, serial_clk, di_clk);
291 serial_clk = 7000UL * mode->clock;
292 imx_ldb_set_clock(ldb, mux, imx_ldb_ch->chno, serial_clk,
296 /* FIXME - assumes straight connections DI0 --> CH0, DI1 --> CH1 */
297 if (imx_ldb_ch == &ldb->channel[0] || dual) {
298 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
299 ldb->ldb_ctrl |= LDB_DI0_VS_POL_ACT_LOW;
300 else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
301 ldb->ldb_ctrl &= ~LDB_DI0_VS_POL_ACT_LOW;
303 if (imx_ldb_ch == &ldb->channel[1] || dual) {
304 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
305 ldb->ldb_ctrl |= LDB_DI1_VS_POL_ACT_LOW;
306 else if (mode->flags & DRM_MODE_FLAG_PVSYNC)
307 ldb->ldb_ctrl &= ~LDB_DI1_VS_POL_ACT_LOW;
311 struct drm_connector *connector = connector_state->connector;
312 struct drm_display_info *di = &connector->display_info;
314 if (di->num_bus_formats)
315 bus_format = di->bus_formats[0];
317 imx_ldb_ch_set_bus_format(imx_ldb_ch, bus_format);
320 static void imx_ldb_encoder_disable(struct drm_encoder *encoder)
322 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
323 struct imx_ldb *ldb = imx_ldb_ch->ldb;
324 int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
327 drm_panel_disable(imx_ldb_ch->panel);
329 if (imx_ldb_ch == &ldb->channel[0] || dual)
330 ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
331 if (imx_ldb_ch == &ldb->channel[1] || dual)
332 ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK;
334 regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
337 clk_disable_unprepare(ldb->clk[0]);
338 clk_disable_unprepare(ldb->clk[1]);
342 const struct bus_mux *lvds_mux = NULL;
344 if (imx_ldb_ch == &ldb->channel[0])
345 lvds_mux = &ldb->lvds_mux[0];
346 else if (imx_ldb_ch == &ldb->channel[1])
347 lvds_mux = &ldb->lvds_mux[1];
349 regmap_read(ldb->regmap, lvds_mux->reg, &mux);
350 mux &= lvds_mux->mask;
351 mux >>= lvds_mux->shift;
353 mux = (imx_ldb_ch == &ldb->channel[0]) ? 0 : 1;
356 /* set display clock mux back to original input clock */
357 ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk_parent[mux]);
360 "unable to set di%d parent clock to original parent\n",
363 drm_panel_unprepare(imx_ldb_ch->panel);
366 static int imx_ldb_encoder_atomic_check(struct drm_encoder *encoder,
367 struct drm_crtc_state *crtc_state,
368 struct drm_connector_state *conn_state)
370 struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
371 struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
372 struct drm_display_info *di = &conn_state->connector->display_info;
373 u32 bus_format = imx_ldb_ch->bus_format;
375 /* Bus format description in DT overrides connector display info. */
376 if (!bus_format && di->num_bus_formats) {
377 bus_format = di->bus_formats[0];
378 imx_crtc_state->bus_flags = di->bus_flags;
380 bus_format = imx_ldb_ch->bus_format;
381 imx_crtc_state->bus_flags = imx_ldb_ch->bus_flags;
383 switch (bus_format) {
384 case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
385 imx_crtc_state->bus_format = MEDIA_BUS_FMT_RGB666_1X18;
387 case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
388 case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
389 imx_crtc_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
395 imx_crtc_state->di_hsync_pin = 2;
396 imx_crtc_state->di_vsync_pin = 3;
402 static const struct drm_connector_funcs imx_ldb_connector_funcs = {
403 .fill_modes = drm_helper_probe_single_connector_modes,
404 .destroy = imx_drm_connector_destroy,
405 .reset = drm_atomic_helper_connector_reset,
406 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
407 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
410 static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = {
411 .get_modes = imx_ldb_connector_get_modes,
412 .best_encoder = imx_ldb_connector_best_encoder,
415 static const struct drm_encoder_funcs imx_ldb_encoder_funcs = {
416 .destroy = imx_drm_encoder_destroy,
419 static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
420 .atomic_mode_set = imx_ldb_encoder_atomic_mode_set,
421 .enable = imx_ldb_encoder_enable,
422 .disable = imx_ldb_encoder_disable,
423 .atomic_check = imx_ldb_encoder_atomic_check,
426 static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno)
430 snprintf(clkname, sizeof(clkname), "di%d", chno);
431 ldb->clk[chno] = devm_clk_get(ldb->dev, clkname);
432 if (IS_ERR(ldb->clk[chno]))
433 return PTR_ERR(ldb->clk[chno]);
435 snprintf(clkname, sizeof(clkname), "di%d_pll", chno);
436 ldb->clk_pll[chno] = devm_clk_get(ldb->dev, clkname);
438 return PTR_ERR_OR_ZERO(ldb->clk_pll[chno]);
441 static int imx_ldb_register(struct drm_device *drm,
442 struct imx_ldb_channel *imx_ldb_ch)
444 struct imx_ldb *ldb = imx_ldb_ch->ldb;
445 struct drm_encoder *encoder = &imx_ldb_ch->encoder;
448 ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child);
452 ret = imx_ldb_get_clk(ldb, imx_ldb_ch->chno);
456 if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) {
457 ret = imx_ldb_get_clk(ldb, 1);
462 drm_encoder_helper_add(encoder, &imx_ldb_encoder_helper_funcs);
463 drm_encoder_init(drm, encoder, &imx_ldb_encoder_funcs,
464 DRM_MODE_ENCODER_LVDS, NULL);
466 if (imx_ldb_ch->bridge) {
467 ret = drm_bridge_attach(&imx_ldb_ch->encoder,
468 imx_ldb_ch->bridge, NULL);
470 DRM_ERROR("Failed to initialize bridge with drm\n");
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(&imx_ldb_ch->connector,
481 &imx_ldb_connector_helper_funcs);
482 drm_connector_init(drm, &imx_ldb_ch->connector,
483 &imx_ldb_connector_funcs,
484 DRM_MODE_CONNECTOR_LVDS);
485 drm_connector_attach_encoder(&imx_ldb_ch->connector, encoder);
488 if (imx_ldb_ch->panel) {
489 ret = drm_panel_attach(imx_ldb_ch->panel,
490 &imx_ldb_ch->connector);
503 struct imx_ldb_bit_mapping {
506 const char * const mapping;
509 static const struct imx_ldb_bit_mapping imx_ldb_bit_mappings[] = {
510 { MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, 18, "spwg" },
511 { MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, 24, "spwg" },
512 { MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, 24, "jeida" },
515 static u32 of_get_bus_format(struct device *dev, struct device_node *np)
521 ret = of_property_read_string(np, "fsl,data-mapping", &bm);
525 of_property_read_u32(np, "fsl,data-width", &datawidth);
527 for (i = 0; i < ARRAY_SIZE(imx_ldb_bit_mappings); i++) {
528 if (!strcasecmp(bm, imx_ldb_bit_mappings[i].mapping) &&
529 datawidth == imx_ldb_bit_mappings[i].datawidth)
530 return imx_ldb_bit_mappings[i].bus_format;
533 dev_err(dev, "invalid data mapping: %d-bit \"%s\"\n", datawidth, bm);
538 static struct bus_mux imx6q_lvds_mux[2] = {
542 .mask = IMX6Q_GPR3_LVDS0_MUX_CTL_MASK,
546 .mask = IMX6Q_GPR3_LVDS1_MUX_CTL_MASK,
551 * For a device declaring compatible = "fsl,imx6q-ldb", "fsl,imx53-ldb",
552 * of_match_device will walk through this list and take the first entry
553 * matching any of its compatible values. Therefore, the more generic
554 * entries (in this case fsl,imx53-ldb) need to be ordered last.
556 static const struct of_device_id imx_ldb_dt_ids[] = {
557 { .compatible = "fsl,imx6q-ldb", .data = imx6q_lvds_mux, },
558 { .compatible = "fsl,imx53-ldb", .data = NULL, },
561 MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids);
563 static int imx_ldb_panel_ddc(struct device *dev,
564 struct imx_ldb_channel *channel, struct device_node *child)
566 struct device_node *ddc_node;
570 ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
572 channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
573 of_node_put(ddc_node);
575 dev_warn(dev, "failed to get ddc i2c adapter\n");
576 return -EPROBE_DEFER;
581 /* if no DDC available, fallback to hardcoded EDID */
582 dev_dbg(dev, "no ddc available\n");
584 edidp = of_get_property(child, "edid",
587 channel->edid = kmemdup(edidp,
590 } else if (!channel->panel) {
591 /* fallback to display-timings node */
592 ret = of_get_drm_display_mode(child,
597 channel->mode_valid = 1;
603 static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
605 struct drm_device *drm = data;
606 struct device_node *np = dev->of_node;
607 const struct of_device_id *of_id =
608 of_match_device(imx_ldb_dt_ids, dev);
609 struct device_node *child;
610 struct imx_ldb *imx_ldb;
615 imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL);
619 imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
620 if (IS_ERR(imx_ldb->regmap)) {
621 dev_err(dev, "failed to get parent regmap\n");
622 return PTR_ERR(imx_ldb->regmap);
625 /* disable LDB by resetting the control register to POR default */
626 regmap_write(imx_ldb->regmap, IOMUXC_GPR2, 0);
631 imx_ldb->lvds_mux = of_id->data;
633 dual = of_property_read_bool(np, "fsl,dual-channel");
635 imx_ldb->ldb_ctrl |= LDB_SPLIT_MODE_EN;
638 * There are three different possible clock mux configurations:
639 * i.MX53: ipu1_di0_sel, ipu1_di1_sel
640 * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel
641 * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel
642 * Map them all to di0_sel...di3_sel.
644 for (i = 0; i < 4; i++) {
647 sprintf(clkname, "di%d_sel", i);
648 imx_ldb->clk_sel[i] = devm_clk_get(imx_ldb->dev, clkname);
649 if (IS_ERR(imx_ldb->clk_sel[i])) {
650 ret = PTR_ERR(imx_ldb->clk_sel[i]);
651 imx_ldb->clk_sel[i] = NULL;
655 imx_ldb->clk_parent[i] = clk_get_parent(imx_ldb->clk_sel[i]);
660 for_each_child_of_node(np, child) {
661 struct imx_ldb_channel *channel;
664 ret = of_property_read_u32(child, "reg", &i);
665 if (ret || i < 0 || i > 1) {
670 if (!of_device_is_available(child))
674 dev_warn(dev, "dual-channel mode, ignoring second output\n");
678 channel = &imx_ldb->channel[i];
679 channel->ldb = imx_ldb;
683 * The output port is port@4 with an external 4-port mux or
684 * port@2 with the internal 2-port mux.
686 ret = drm_of_find_panel_or_bridge(child,
687 imx_ldb->lvds_mux ? 4 : 2, 0,
688 &channel->panel, &channel->bridge);
689 if (ret && ret != -ENODEV)
692 /* panel ddc only if there is no bridge */
693 if (!channel->bridge) {
694 ret = imx_ldb_panel_ddc(dev, channel, child);
699 bus_format = of_get_bus_format(dev, child);
700 if (bus_format == -EINVAL) {
702 * If no bus format was specified in the device tree,
703 * we can still get it from the connected panel later.
705 if (channel->panel && channel->panel->funcs &&
706 channel->panel->funcs->get_modes)
709 if (bus_format < 0) {
710 dev_err(dev, "could not determine data mapping: %d\n",
715 channel->bus_format = bus_format;
716 channel->child = child;
718 ret = imx_ldb_register(drm, channel);
720 channel->child = NULL;
725 dev_set_drvdata(dev, imx_ldb);
734 static void imx_ldb_unbind(struct device *dev, struct device *master,
737 struct imx_ldb *imx_ldb = dev_get_drvdata(dev);
740 for (i = 0; i < 2; i++) {
741 struct imx_ldb_channel *channel = &imx_ldb->channel[i];
744 drm_panel_detach(channel->panel);
746 kfree(channel->edid);
747 i2c_put_adapter(channel->ddc);
751 static const struct component_ops imx_ldb_ops = {
752 .bind = imx_ldb_bind,
753 .unbind = imx_ldb_unbind,
756 static int imx_ldb_probe(struct platform_device *pdev)
758 return component_add(&pdev->dev, &imx_ldb_ops);
761 static int imx_ldb_remove(struct platform_device *pdev)
763 component_del(&pdev->dev, &imx_ldb_ops);
767 static struct platform_driver imx_ldb_driver = {
768 .probe = imx_ldb_probe,
769 .remove = imx_ldb_remove,
771 .of_match_table = imx_ldb_dt_ids,
776 module_platform_driver(imx_ldb_driver);
778 MODULE_DESCRIPTION("i.MX LVDS driver");
779 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
780 MODULE_LICENSE("GPL");
781 MODULE_ALIAS("platform:" DRIVER_NAME);