Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 1 | /* |
| 2 | * i.MX drm driver - LVDS display bridge |
| 3 | * |
| 4 | * Copyright (C) 2012 Sascha Hauer, Pengutronix |
| 5 | * |
| 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. |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/clk.h> |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 18 | #include <linux/component.h> |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 19 | #include <drm/drmP.h> |
| 20 | #include <drm/drm_fb_helper.h> |
| 21 | #include <drm/drm_crtc_helper.h> |
Philipp Zabel | 53141e4 | 2015-02-24 11:41:28 +0100 | [diff] [blame^] | 22 | #include <drm/drm_of.h> |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 23 | #include <drm/drm_panel.h> |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 24 | #include <linux/mfd/syscon.h> |
| 25 | #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 26 | #include <linux/of_device.h> |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 27 | #include <linux/of_graph.h> |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 28 | #include <video/of_videomode.h> |
| 29 | #include <linux/regmap.h> |
| 30 | #include <linux/videodev2.h> |
| 31 | |
| 32 | #include "imx-drm.h" |
| 33 | |
| 34 | #define DRIVER_NAME "imx-ldb" |
| 35 | |
| 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) |
| 50 | |
| 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) |
| 53 | |
| 54 | struct imx_ldb; |
| 55 | |
| 56 | struct imx_ldb_channel { |
| 57 | struct imx_ldb *ldb; |
| 58 | struct drm_connector connector; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 59 | struct drm_encoder encoder; |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 60 | struct drm_panel *panel; |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 61 | struct device_node *child; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 62 | int chno; |
| 63 | void *edid; |
| 64 | int edid_len; |
| 65 | struct drm_display_mode mode; |
| 66 | int mode_valid; |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 67 | int bus_format; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct bus_mux { |
| 71 | int reg; |
| 72 | int shift; |
| 73 | int mask; |
| 74 | }; |
| 75 | |
| 76 | struct imx_ldb { |
| 77 | struct regmap *regmap; |
| 78 | struct device *dev; |
| 79 | struct imx_ldb_channel channel[2]; |
| 80 | struct clk *clk[2]; /* our own clock */ |
| 81 | struct clk *clk_sel[4]; /* parent of display clock */ |
Philipp Zabel | 3973aff | 2014-11-26 13:59:11 +0100 | [diff] [blame] | 82 | struct clk *clk_parent[4]; /* original parent of clk_sel */ |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 83 | struct clk *clk_pll[2]; /* upstream clock we can adjust */ |
| 84 | u32 ldb_ctrl; |
| 85 | const struct bus_mux *lvds_mux; |
| 86 | }; |
| 87 | |
| 88 | static enum drm_connector_status imx_ldb_connector_detect( |
| 89 | struct drm_connector *connector, bool force) |
| 90 | { |
| 91 | return connector_status_connected; |
| 92 | } |
| 93 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 94 | static int imx_ldb_connector_get_modes(struct drm_connector *connector) |
| 95 | { |
| 96 | struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector); |
| 97 | int num_modes = 0; |
| 98 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 99 | if (imx_ldb_ch->panel && imx_ldb_ch->panel->funcs && |
| 100 | imx_ldb_ch->panel->funcs->get_modes) { |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 101 | struct drm_display_info *di = &connector->display_info; |
| 102 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 103 | num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel); |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 104 | if (!imx_ldb_ch->bus_format && di->num_bus_formats) |
| 105 | imx_ldb_ch->bus_format = di->bus_formats[0]; |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 106 | if (num_modes > 0) |
| 107 | return num_modes; |
| 108 | } |
| 109 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 110 | if (imx_ldb_ch->edid) { |
| 111 | drm_mode_connector_update_edid_property(connector, |
| 112 | imx_ldb_ch->edid); |
| 113 | num_modes = drm_add_edid_modes(connector, imx_ldb_ch->edid); |
| 114 | } |
| 115 | |
| 116 | if (imx_ldb_ch->mode_valid) { |
| 117 | struct drm_display_mode *mode; |
| 118 | |
| 119 | mode = drm_mode_create(connector->dev); |
Fabio Estevam | 9f9b036 | 2014-02-26 20:53:40 -0300 | [diff] [blame] | 120 | if (!mode) |
| 121 | return -EINVAL; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 122 | drm_mode_copy(mode, &imx_ldb_ch->mode); |
| 123 | mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
| 124 | drm_mode_probed_add(connector, mode); |
| 125 | num_modes++; |
| 126 | } |
| 127 | |
| 128 | return num_modes; |
| 129 | } |
| 130 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 131 | static struct drm_encoder *imx_ldb_connector_best_encoder( |
| 132 | struct drm_connector *connector) |
| 133 | { |
| 134 | struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector); |
| 135 | |
| 136 | return &imx_ldb_ch->encoder; |
| 137 | } |
| 138 | |
| 139 | static void imx_ldb_encoder_dpms(struct drm_encoder *encoder, int mode) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | static bool imx_ldb_encoder_mode_fixup(struct drm_encoder *encoder, |
| 144 | const struct drm_display_mode *mode, |
| 145 | struct drm_display_mode *adjusted_mode) |
| 146 | { |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno, |
| 151 | unsigned long serial_clk, unsigned long di_clk) |
| 152 | { |
| 153 | int ret; |
| 154 | |
| 155 | dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__, |
| 156 | clk_get_rate(ldb->clk_pll[chno]), serial_clk); |
| 157 | clk_set_rate(ldb->clk_pll[chno], serial_clk); |
| 158 | |
| 159 | dev_dbg(ldb->dev, "%s after: %ld\n", __func__, |
| 160 | clk_get_rate(ldb->clk_pll[chno])); |
| 161 | |
| 162 | dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__, |
| 163 | clk_get_rate(ldb->clk[chno]), |
| 164 | (long int)di_clk); |
| 165 | clk_set_rate(ldb->clk[chno], di_clk); |
| 166 | |
| 167 | dev_dbg(ldb->dev, "%s after: %ld\n", __func__, |
| 168 | clk_get_rate(ldb->clk[chno])); |
| 169 | |
| 170 | /* set display clock mux to LDB input clock */ |
| 171 | ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]); |
Sima Baymani | 49f4a9c | 2013-11-03 11:18:57 +0100 | [diff] [blame] | 172 | if (ret) |
Aybuke Ozdemir | e5e1b16 | 2014-03-17 23:55:53 +0200 | [diff] [blame] | 173 | dev_err(ldb->dev, |
| 174 | "unable to set di%d parent clock to ldb_di%d\n", mux, |
| 175 | chno); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static void imx_ldb_encoder_prepare(struct drm_encoder *encoder) |
| 179 | { |
| 180 | struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); |
| 181 | struct imx_ldb *ldb = imx_ldb_ch->ldb; |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 182 | int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; |
Philipp Zabel | 2872c80 | 2015-02-02 17:25:59 +0100 | [diff] [blame] | 183 | u32 bus_format; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 184 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 185 | switch (imx_ldb_ch->bus_format) { |
Markus Niebel | 000d73f | 2013-06-18 09:23:58 +0800 | [diff] [blame] | 186 | default: |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 187 | dev_warn(ldb->dev, |
| 188 | "could not determine data mapping, default to 18-bit \"spwg\"\n"); |
| 189 | /* fallthrough */ |
| 190 | case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG: |
| 191 | bus_format = MEDIA_BUS_FMT_RGB666_1X18; |
| 192 | break; |
| 193 | case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG: |
Philipp Zabel | 2872c80 | 2015-02-02 17:25:59 +0100 | [diff] [blame] | 194 | bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 195 | if (imx_ldb_ch->chno == 0 || dual) |
| 196 | ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24; |
| 197 | if (imx_ldb_ch->chno == 1 || dual) |
| 198 | ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24; |
| 199 | break; |
| 200 | case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA: |
| 201 | bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
| 202 | if (imx_ldb_ch->chno == 0 || dual) |
| 203 | ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 | |
| 204 | LDB_BIT_MAP_CH0_JEIDA; |
| 205 | if (imx_ldb_ch->chno == 1 || dual) |
| 206 | ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 | |
| 207 | LDB_BIT_MAP_CH1_JEIDA; |
| 208 | break; |
Markus Niebel | 000d73f | 2013-06-18 09:23:58 +0800 | [diff] [blame] | 209 | } |
| 210 | |
Philipp Zabel | 2872c80 | 2015-02-02 17:25:59 +0100 | [diff] [blame] | 211 | imx_drm_set_bus_format(encoder, bus_format); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void imx_ldb_encoder_commit(struct drm_encoder *encoder) |
| 215 | { |
| 216 | struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); |
| 217 | struct imx_ldb *ldb = imx_ldb_ch->ldb; |
| 218 | int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; |
Philipp Zabel | 53141e4 | 2015-02-24 11:41:28 +0100 | [diff] [blame^] | 219 | int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 220 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 221 | drm_panel_prepare(imx_ldb_ch->panel); |
| 222 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 223 | if (dual) { |
| 224 | clk_prepare_enable(ldb->clk[0]); |
| 225 | clk_prepare_enable(ldb->clk[1]); |
| 226 | } |
| 227 | |
| 228 | if (imx_ldb_ch == &ldb->channel[0] || dual) { |
| 229 | ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK; |
| 230 | if (mux == 0 || ldb->lvds_mux) |
| 231 | ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI0; |
| 232 | else if (mux == 1) |
| 233 | ldb->ldb_ctrl |= LDB_CH0_MODE_EN_TO_DI1; |
| 234 | } |
| 235 | if (imx_ldb_ch == &ldb->channel[1] || dual) { |
| 236 | ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK; |
| 237 | if (mux == 1 || ldb->lvds_mux) |
| 238 | ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI1; |
| 239 | else if (mux == 0) |
| 240 | ldb->ldb_ctrl |= LDB_CH1_MODE_EN_TO_DI0; |
| 241 | } |
| 242 | |
| 243 | if (ldb->lvds_mux) { |
| 244 | const struct bus_mux *lvds_mux = NULL; |
| 245 | |
| 246 | if (imx_ldb_ch == &ldb->channel[0]) |
| 247 | lvds_mux = &ldb->lvds_mux[0]; |
| 248 | else if (imx_ldb_ch == &ldb->channel[1]) |
| 249 | lvds_mux = &ldb->lvds_mux[1]; |
| 250 | |
| 251 | regmap_update_bits(ldb->regmap, lvds_mux->reg, lvds_mux->mask, |
| 252 | mux << lvds_mux->shift); |
| 253 | } |
| 254 | |
| 255 | regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl); |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 256 | |
| 257 | drm_panel_enable(imx_ldb_ch->panel); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder, |
Steve Longerbeam | eb10d63 | 2014-12-18 18:00:24 -0800 | [diff] [blame] | 261 | struct drm_display_mode *orig_mode, |
| 262 | struct drm_display_mode *mode) |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 263 | { |
| 264 | struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); |
| 265 | struct imx_ldb *ldb = imx_ldb_ch->ldb; |
| 266 | int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; |
Philipp Zabel | 51dac94 | 2015-01-23 17:10:01 +0100 | [diff] [blame] | 267 | unsigned long serial_clk; |
| 268 | unsigned long di_clk = mode->clock * 1000; |
Philipp Zabel | 53141e4 | 2015-02-24 11:41:28 +0100 | [diff] [blame^] | 269 | int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 270 | |
| 271 | if (mode->clock > 170000) { |
| 272 | dev_warn(ldb->dev, |
| 273 | "%s: mode exceeds 170 MHz pixel clock\n", __func__); |
| 274 | } |
| 275 | if (mode->clock > 85000 && !dual) { |
| 276 | dev_warn(ldb->dev, |
| 277 | "%s: mode exceeds 85 MHz pixel clock\n", __func__); |
| 278 | } |
| 279 | |
Philipp Zabel | 51dac94 | 2015-01-23 17:10:01 +0100 | [diff] [blame] | 280 | if (dual) { |
| 281 | serial_clk = 3500UL * mode->clock; |
| 282 | imx_ldb_set_clock(ldb, mux, 0, serial_clk, di_clk); |
| 283 | imx_ldb_set_clock(ldb, mux, 1, serial_clk, di_clk); |
| 284 | } else { |
| 285 | serial_clk = 7000UL * mode->clock; |
| 286 | imx_ldb_set_clock(ldb, mux, imx_ldb_ch->chno, serial_clk, |
| 287 | di_clk); |
| 288 | } |
| 289 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 290 | /* FIXME - assumes straight connections DI0 --> CH0, DI1 --> CH1 */ |
| 291 | if (imx_ldb_ch == &ldb->channel[0]) { |
| 292 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
| 293 | ldb->ldb_ctrl |= LDB_DI0_VS_POL_ACT_LOW; |
| 294 | else if (mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 295 | ldb->ldb_ctrl &= ~LDB_DI0_VS_POL_ACT_LOW; |
| 296 | } |
| 297 | if (imx_ldb_ch == &ldb->channel[1]) { |
| 298 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
| 299 | ldb->ldb_ctrl |= LDB_DI1_VS_POL_ACT_LOW; |
| 300 | else if (mode->flags & DRM_MODE_FLAG_PVSYNC) |
| 301 | ldb->ldb_ctrl &= ~LDB_DI1_VS_POL_ACT_LOW; |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | static void imx_ldb_encoder_disable(struct drm_encoder *encoder) |
| 306 | { |
| 307 | struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); |
| 308 | struct imx_ldb *ldb = imx_ldb_ch->ldb; |
Philipp Zabel | 3973aff | 2014-11-26 13:59:11 +0100 | [diff] [blame] | 309 | int mux, ret; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 310 | |
| 311 | /* |
| 312 | * imx_ldb_encoder_disable is called by |
| 313 | * drm_helper_disable_unused_functions without |
| 314 | * the encoder being enabled before. |
| 315 | */ |
| 316 | if (imx_ldb_ch == &ldb->channel[0] && |
| 317 | (ldb->ldb_ctrl & LDB_CH0_MODE_EN_MASK) == 0) |
| 318 | return; |
| 319 | else if (imx_ldb_ch == &ldb->channel[1] && |
| 320 | (ldb->ldb_ctrl & LDB_CH1_MODE_EN_MASK) == 0) |
| 321 | return; |
| 322 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 323 | drm_panel_disable(imx_ldb_ch->panel); |
| 324 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 325 | if (imx_ldb_ch == &ldb->channel[0]) |
| 326 | ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK; |
| 327 | else if (imx_ldb_ch == &ldb->channel[1]) |
| 328 | ldb->ldb_ctrl &= ~LDB_CH1_MODE_EN_MASK; |
| 329 | |
| 330 | regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl); |
| 331 | |
| 332 | if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) { |
| 333 | clk_disable_unprepare(ldb->clk[0]); |
| 334 | clk_disable_unprepare(ldb->clk[1]); |
| 335 | } |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 336 | |
Philipp Zabel | 3973aff | 2014-11-26 13:59:11 +0100 | [diff] [blame] | 337 | if (ldb->lvds_mux) { |
| 338 | const struct bus_mux *lvds_mux = NULL; |
| 339 | |
| 340 | if (imx_ldb_ch == &ldb->channel[0]) |
| 341 | lvds_mux = &ldb->lvds_mux[0]; |
| 342 | else if (imx_ldb_ch == &ldb->channel[1]) |
| 343 | lvds_mux = &ldb->lvds_mux[1]; |
| 344 | |
| 345 | regmap_read(ldb->regmap, lvds_mux->reg, &mux); |
| 346 | mux &= lvds_mux->mask; |
| 347 | mux >>= lvds_mux->shift; |
| 348 | } else { |
| 349 | mux = (imx_ldb_ch == &ldb->channel[0]) ? 0 : 1; |
| 350 | } |
| 351 | |
| 352 | /* set display clock mux back to original input clock */ |
| 353 | ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk_parent[mux]); |
| 354 | if (ret) |
| 355 | dev_err(ldb->dev, |
| 356 | "unable to set di%d parent clock to original parent\n", |
| 357 | mux); |
| 358 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 359 | drm_panel_unprepare(imx_ldb_ch->panel); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 360 | } |
| 361 | |
Ville Syrjälä | 7ae847d | 2015-12-15 12:21:09 +0100 | [diff] [blame] | 362 | static const struct drm_connector_funcs imx_ldb_connector_funcs = { |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 363 | .dpms = drm_helper_connector_dpms, |
| 364 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 365 | .detect = imx_ldb_connector_detect, |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 366 | .destroy = imx_drm_connector_destroy, |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 367 | }; |
| 368 | |
Ville Syrjälä | 7ae847d | 2015-12-15 12:21:09 +0100 | [diff] [blame] | 369 | static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs = { |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 370 | .get_modes = imx_ldb_connector_get_modes, |
| 371 | .best_encoder = imx_ldb_connector_best_encoder, |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 372 | }; |
| 373 | |
Ville Syrjälä | 7ae847d | 2015-12-15 12:21:09 +0100 | [diff] [blame] | 374 | static const struct drm_encoder_funcs imx_ldb_encoder_funcs = { |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 375 | .destroy = imx_drm_encoder_destroy, |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 376 | }; |
| 377 | |
Ville Syrjälä | 7ae847d | 2015-12-15 12:21:09 +0100 | [diff] [blame] | 378 | static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 379 | .dpms = imx_ldb_encoder_dpms, |
| 380 | .mode_fixup = imx_ldb_encoder_mode_fixup, |
| 381 | .prepare = imx_ldb_encoder_prepare, |
| 382 | .commit = imx_ldb_encoder_commit, |
| 383 | .mode_set = imx_ldb_encoder_mode_set, |
| 384 | .disable = imx_ldb_encoder_disable, |
| 385 | }; |
| 386 | |
| 387 | static int imx_ldb_get_clk(struct imx_ldb *ldb, int chno) |
| 388 | { |
| 389 | char clkname[16]; |
| 390 | |
Fabio Estevam | 98dd3b2 | 2014-02-28 11:39:42 -0300 | [diff] [blame] | 391 | snprintf(clkname, sizeof(clkname), "di%d", chno); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 392 | ldb->clk[chno] = devm_clk_get(ldb->dev, clkname); |
| 393 | if (IS_ERR(ldb->clk[chno])) |
| 394 | return PTR_ERR(ldb->clk[chno]); |
| 395 | |
Fabio Estevam | 98dd3b2 | 2014-02-28 11:39:42 -0300 | [diff] [blame] | 396 | snprintf(clkname, sizeof(clkname), "di%d_pll", chno); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 397 | ldb->clk_pll[chno] = devm_clk_get(ldb->dev, clkname); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 398 | |
Valentina Manea | 1f933fa | 2013-10-23 10:29:55 +0300 | [diff] [blame] | 399 | return PTR_ERR_OR_ZERO(ldb->clk_pll[chno]); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 400 | } |
| 401 | |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 402 | static int imx_ldb_register(struct drm_device *drm, |
| 403 | struct imx_ldb_channel *imx_ldb_ch) |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 404 | { |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 405 | struct imx_ldb *ldb = imx_ldb_ch->ldb; |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 406 | int ret; |
| 407 | |
| 408 | ret = imx_drm_encoder_parse_of(drm, &imx_ldb_ch->encoder, |
| 409 | imx_ldb_ch->child); |
| 410 | if (ret) |
| 411 | return ret; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 412 | |
| 413 | ret = imx_ldb_get_clk(ldb, imx_ldb_ch->chno); |
| 414 | if (ret) |
| 415 | return ret; |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 416 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 417 | if (ldb->ldb_ctrl & LDB_SPLIT_MODE_EN) { |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 418 | ret = imx_ldb_get_clk(ldb, 1); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 419 | if (ret) |
| 420 | return ret; |
| 421 | } |
| 422 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 423 | drm_encoder_helper_add(&imx_ldb_ch->encoder, |
| 424 | &imx_ldb_encoder_helper_funcs); |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 425 | drm_encoder_init(drm, &imx_ldb_ch->encoder, &imx_ldb_encoder_funcs, |
Ville Syrjälä | 13a3d91 | 2015-12-09 16:20:18 +0200 | [diff] [blame] | 426 | DRM_MODE_ENCODER_LVDS, NULL); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 427 | |
| 428 | drm_connector_helper_add(&imx_ldb_ch->connector, |
| 429 | &imx_ldb_connector_helper_funcs); |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 430 | drm_connector_init(drm, &imx_ldb_ch->connector, |
| 431 | &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 432 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 433 | if (imx_ldb_ch->panel) |
| 434 | drm_panel_attach(imx_ldb_ch->panel, &imx_ldb_ch->connector); |
| 435 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 436 | drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, |
| 437 | &imx_ldb_ch->encoder); |
| 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | enum { |
| 443 | LVDS_BIT_MAP_SPWG, |
| 444 | LVDS_BIT_MAP_JEIDA |
| 445 | }; |
| 446 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 447 | struct imx_ldb_bit_mapping { |
| 448 | u32 bus_format; |
| 449 | u32 datawidth; |
| 450 | const char * const mapping; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 451 | }; |
| 452 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 453 | static const struct imx_ldb_bit_mapping imx_ldb_bit_mappings[] = { |
| 454 | { MEDIA_BUS_FMT_RGB666_1X7X3_SPWG, 18, "spwg" }, |
| 455 | { MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, 24, "spwg" }, |
| 456 | { MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, 24, "jeida" }, |
| 457 | }; |
| 458 | |
| 459 | static u32 of_get_bus_format(struct device *dev, struct device_node *np) |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 460 | { |
| 461 | const char *bm; |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 462 | u32 datawidth = 0; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 463 | int ret, i; |
| 464 | |
| 465 | ret = of_property_read_string(np, "fsl,data-mapping", &bm); |
| 466 | if (ret < 0) |
| 467 | return ret; |
| 468 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 469 | of_property_read_u32(np, "fsl,data-width", &datawidth); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 470 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 471 | for (i = 0; i < ARRAY_SIZE(imx_ldb_bit_mappings); i++) { |
| 472 | if (!strcasecmp(bm, imx_ldb_bit_mappings[i].mapping) && |
| 473 | datawidth == imx_ldb_bit_mappings[i].datawidth) |
| 474 | return imx_ldb_bit_mappings[i].bus_format; |
| 475 | } |
| 476 | |
| 477 | dev_err(dev, "invalid data mapping: %d-bit \"%s\"\n", datawidth, bm); |
| 478 | |
| 479 | return -ENOENT; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | static struct bus_mux imx6q_lvds_mux[2] = { |
| 483 | { |
| 484 | .reg = IOMUXC_GPR3, |
| 485 | .shift = 6, |
| 486 | .mask = IMX6Q_GPR3_LVDS0_MUX_CTL_MASK, |
| 487 | }, { |
| 488 | .reg = IOMUXC_GPR3, |
| 489 | .shift = 8, |
| 490 | .mask = IMX6Q_GPR3_LVDS1_MUX_CTL_MASK, |
| 491 | } |
| 492 | }; |
| 493 | |
| 494 | /* |
| 495 | * For a device declaring compatible = "fsl,imx6q-ldb", "fsl,imx53-ldb", |
| 496 | * of_match_device will walk through this list and take the first entry |
| 497 | * matching any of its compatible values. Therefore, the more generic |
| 498 | * entries (in this case fsl,imx53-ldb) need to be ordered last. |
| 499 | */ |
| 500 | static const struct of_device_id imx_ldb_dt_ids[] = { |
| 501 | { .compatible = "fsl,imx6q-ldb", .data = imx6q_lvds_mux, }, |
| 502 | { .compatible = "fsl,imx53-ldb", .data = NULL, }, |
| 503 | { } |
| 504 | }; |
| 505 | MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids); |
| 506 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 507 | static int imx_ldb_bind(struct device *dev, struct device *master, void *data) |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 508 | { |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 509 | struct drm_device *drm = data; |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 510 | struct device_node *np = dev->of_node; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 511 | const struct of_device_id *of_id = |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 512 | of_match_device(imx_ldb_dt_ids, dev); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 513 | struct device_node *child; |
| 514 | const u8 *edidp; |
| 515 | struct imx_ldb *imx_ldb; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 516 | int dual; |
| 517 | int ret; |
| 518 | int i; |
| 519 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 520 | imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 521 | if (!imx_ldb) |
| 522 | return -ENOMEM; |
| 523 | |
| 524 | imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr"); |
| 525 | if (IS_ERR(imx_ldb->regmap)) { |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 526 | dev_err(dev, "failed to get parent regmap\n"); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 527 | return PTR_ERR(imx_ldb->regmap); |
| 528 | } |
| 529 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 530 | imx_ldb->dev = dev; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 531 | |
| 532 | if (of_id) |
| 533 | imx_ldb->lvds_mux = of_id->data; |
| 534 | |
| 535 | dual = of_property_read_bool(np, "fsl,dual-channel"); |
| 536 | if (dual) |
| 537 | imx_ldb->ldb_ctrl |= LDB_SPLIT_MODE_EN; |
| 538 | |
| 539 | /* |
Masanari Iida | 4599934 | 2013-07-24 01:05:07 +0900 | [diff] [blame] | 540 | * There are three different possible clock mux configurations: |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 541 | * i.MX53: ipu1_di0_sel, ipu1_di1_sel |
| 542 | * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel |
| 543 | * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel |
| 544 | * Map them all to di0_sel...di3_sel. |
| 545 | */ |
| 546 | for (i = 0; i < 4; i++) { |
| 547 | char clkname[16]; |
| 548 | |
| 549 | sprintf(clkname, "di%d_sel", i); |
| 550 | imx_ldb->clk_sel[i] = devm_clk_get(imx_ldb->dev, clkname); |
| 551 | if (IS_ERR(imx_ldb->clk_sel[i])) { |
| 552 | ret = PTR_ERR(imx_ldb->clk_sel[i]); |
| 553 | imx_ldb->clk_sel[i] = NULL; |
| 554 | break; |
| 555 | } |
Philipp Zabel | 3973aff | 2014-11-26 13:59:11 +0100 | [diff] [blame] | 556 | |
| 557 | imx_ldb->clk_parent[i] = clk_get_parent(imx_ldb->clk_sel[i]); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 558 | } |
| 559 | if (i == 0) |
| 560 | return ret; |
| 561 | |
| 562 | for_each_child_of_node(np, child) { |
| 563 | struct imx_ldb_channel *channel; |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 564 | struct device_node *port; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 565 | |
| 566 | ret = of_property_read_u32(child, "reg", &i); |
| 567 | if (ret || i < 0 || i > 1) |
| 568 | return -EINVAL; |
| 569 | |
| 570 | if (dual && i > 0) { |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 571 | dev_warn(dev, "dual-channel mode, ignoring second output\n"); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 572 | continue; |
| 573 | } |
| 574 | |
| 575 | if (!of_device_is_available(child)) |
| 576 | continue; |
| 577 | |
| 578 | channel = &imx_ldb->channel[i]; |
| 579 | channel->ldb = imx_ldb; |
| 580 | channel->chno = i; |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 581 | channel->child = child; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 582 | |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 583 | /* |
| 584 | * The output port is port@4 with an external 4-port mux or |
| 585 | * port@2 with the internal 2-port mux. |
| 586 | */ |
| 587 | port = of_graph_get_port_by_id(child, imx_ldb->lvds_mux ? 4 : 2); |
| 588 | if (port) { |
| 589 | struct device_node *endpoint, *remote; |
| 590 | |
| 591 | endpoint = of_get_child_by_name(port, "endpoint"); |
| 592 | if (endpoint) { |
| 593 | remote = of_graph_get_remote_port_parent(endpoint); |
| 594 | if (remote) |
| 595 | channel->panel = of_drm_find_panel(remote); |
| 596 | else |
| 597 | return -EPROBE_DEFER; |
| 598 | if (!channel->panel) { |
| 599 | dev_err(dev, "panel not found: %s\n", |
| 600 | remote->full_name); |
| 601 | return -EPROBE_DEFER; |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 606 | edidp = of_get_property(child, "edid", &channel->edid_len); |
| 607 | if (edidp) { |
| 608 | channel->edid = kmemdup(edidp, channel->edid_len, |
| 609 | GFP_KERNEL); |
Philipp Zabel | 751e267 | 2014-03-06 14:54:39 +0100 | [diff] [blame] | 610 | } else if (!channel->panel) { |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 611 | ret = of_get_drm_display_mode(child, &channel->mode, 0); |
| 612 | if (!ret) |
| 613 | channel->mode_valid = 1; |
| 614 | } |
| 615 | |
Philipp Zabel | 5e501ed | 2014-12-02 20:22:49 +0100 | [diff] [blame] | 616 | channel->bus_format = of_get_bus_format(dev, child); |
| 617 | if (channel->bus_format == -EINVAL) { |
| 618 | /* |
| 619 | * If no bus format was specified in the device tree, |
| 620 | * we can still get it from the connected panel later. |
| 621 | */ |
| 622 | if (channel->panel && channel->panel->funcs && |
| 623 | channel->panel->funcs->get_modes) |
| 624 | channel->bus_format = 0; |
| 625 | } |
| 626 | if (channel->bus_format < 0) { |
| 627 | dev_err(dev, "could not determine data mapping: %d\n", |
| 628 | channel->bus_format); |
| 629 | return channel->bus_format; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 630 | } |
| 631 | |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 632 | ret = imx_ldb_register(drm, channel); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 633 | if (ret) |
| 634 | return ret; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 635 | } |
| 636 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 637 | dev_set_drvdata(dev, imx_ldb); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 638 | |
| 639 | return 0; |
| 640 | } |
| 641 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 642 | static void imx_ldb_unbind(struct device *dev, struct device *master, |
| 643 | void *data) |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 644 | { |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 645 | struct imx_ldb *imx_ldb = dev_get_drvdata(dev); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 646 | int i; |
| 647 | |
| 648 | for (i = 0; i < 2; i++) { |
| 649 | struct imx_ldb_channel *channel = &imx_ldb->channel[i]; |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 650 | |
Russell King | d9fdb9f | 2014-09-01 18:07:38 +0100 | [diff] [blame] | 651 | if (!channel->connector.funcs) |
| 652 | continue; |
| 653 | |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 654 | channel->connector.funcs->destroy(&channel->connector); |
| 655 | channel->encoder.funcs->destroy(&channel->encoder); |
Peter Seiderer | f4876ff | 2013-12-08 22:03:57 +0100 | [diff] [blame] | 656 | |
| 657 | kfree(channel->edid); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 658 | } |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 659 | } |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 660 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 661 | static const struct component_ops imx_ldb_ops = { |
| 662 | .bind = imx_ldb_bind, |
| 663 | .unbind = imx_ldb_unbind, |
| 664 | }; |
| 665 | |
| 666 | static int imx_ldb_probe(struct platform_device *pdev) |
| 667 | { |
| 668 | return component_add(&pdev->dev, &imx_ldb_ops); |
| 669 | } |
| 670 | |
| 671 | static int imx_ldb_remove(struct platform_device *pdev) |
| 672 | { |
| 673 | component_del(&pdev->dev, &imx_ldb_ops); |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 674 | return 0; |
| 675 | } |
| 676 | |
| 677 | static struct platform_driver imx_ldb_driver = { |
| 678 | .probe = imx_ldb_probe, |
| 679 | .remove = imx_ldb_remove, |
| 680 | .driver = { |
| 681 | .of_match_table = imx_ldb_dt_ids, |
| 682 | .name = DRIVER_NAME, |
Sascha Hauer | ac4c1a9 | 2013-06-18 09:23:57 +0800 | [diff] [blame] | 683 | }, |
| 684 | }; |
| 685 | |
| 686 | module_platform_driver(imx_ldb_driver); |
| 687 | |
| 688 | MODULE_DESCRIPTION("i.MX LVDS driver"); |
| 689 | MODULE_AUTHOR("Sascha Hauer, Pengutronix"); |
| 690 | MODULE_LICENSE("GPL"); |
Fabio Estevam | bc62738 | 2013-08-18 21:40:03 -0300 | [diff] [blame] | 691 | MODULE_ALIAS("platform:" DRIVER_NAME); |