blob: d18ad58c5a1993b9d71858bac7bd721bfb5eaad9 [file] [log] [blame]
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +03001/*
2 * linux/drivers/video/omap2/dss/sdi.c
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#define DSS_SUBSYS_NAME "SDI"
21
22#include <linux/kernel.h>
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030023#include <linux/delay.h>
24#include <linux/err.h>
Roger Quadros508886c2010-03-17 13:35:21 +010025#include <linux/regulator/consumer.h>
Paul Gortmakera8a35932011-07-10 13:20:26 -040026#include <linux/export.h>
Tomi Valkeinena57dd4f2012-02-20 16:57:37 +020027#include <linux/platform_device.h>
Tomi Valkeinen13b1ba72012-09-28 10:03:03 +030028#include <linux/string.h>
Tomi Valkeinen2ecef242013-12-16 15:13:24 +020029#include <linux/of.h>
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030030
Peter Ujfalusi32043da2016-05-27 14:40:49 +030031#include "omapdss.h"
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030032#include "dss.h"
33
34static struct {
Tomi Valkeinen46c4b642013-03-19 13:46:40 +020035 struct platform_device *pdev;
36
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030037 bool update_enabled;
Roger Quadros508886c2010-03-17 13:35:21 +010038 struct regulator *vdds_sdi_reg;
Archit Taneja37a57992012-06-29 14:33:18 +053039
40 struct dss_lcd_mgr_config mgr_config;
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +030041 struct videomode vm;
Archit Taneja889b4fd2012-07-20 17:18:49 +053042 int datapairs;
Archit Taneja81b87f52012-09-26 16:30:49 +053043
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +030044 struct omap_dss_device output;
Tomi Valkeinen2ecef242013-12-16 15:13:24 +020045
46 bool port_initialized;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +030047} sdi;
48
Tomi Valkeinen36816fa2013-03-05 17:06:26 +020049struct sdi_clk_calc_ctx {
50 unsigned long pck_min, pck_max;
51
Tomi Valkeinenc56812f2014-01-28 08:50:47 +020052 unsigned long fck;
Tomi Valkeinen36816fa2013-03-05 17:06:26 +020053 struct dispc_clock_info dispc_cinfo;
54};
55
56static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
57 unsigned long pck, void *data)
58{
59 struct sdi_clk_calc_ctx *ctx = data;
60
61 ctx->dispc_cinfo.lck_div = lckd;
62 ctx->dispc_cinfo.pck_div = pckd;
63 ctx->dispc_cinfo.lck = lck;
64 ctx->dispc_cinfo.pck = pck;
65
66 return true;
67}
68
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +020069static bool dpi_calc_dss_cb(unsigned long fck, void *data)
Tomi Valkeinen36816fa2013-03-05 17:06:26 +020070{
71 struct sdi_clk_calc_ctx *ctx = data;
72
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +020073 ctx->fck = fck;
Tomi Valkeinen36816fa2013-03-05 17:06:26 +020074
75 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
76 dpi_calc_dispc_cb, ctx);
77}
78
79static int sdi_calc_clock_div(unsigned long pclk,
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +020080 unsigned long *fck,
Tomi Valkeinen36816fa2013-03-05 17:06:26 +020081 struct dispc_clock_info *dispc_cinfo)
82{
83 int i;
84 struct sdi_clk_calc_ctx ctx;
85
86 /*
87 * DSS fclk gives us very few possibilities, so finding a good pixel
88 * clock may not be possible. We try multiple times to find the clock,
89 * each time widening the pixel clock range we look for, up to
90 * +/- 1MHz.
91 */
92
93 for (i = 0; i < 10; ++i) {
94 bool ok;
95
96 memset(&ctx, 0, sizeof(ctx));
97 if (pclk > 1000 * i * i * i)
98 ctx.pck_min = max(pclk - 1000 * i * i * i, 0lu);
99 else
100 ctx.pck_min = 0;
101 ctx.pck_max = pclk + 1000 * i * i * i;
102
Tomi Valkeinen688af022013-10-31 16:41:57 +0200103 ok = dss_div_calc(pclk, ctx.pck_min, dpi_calc_dss_cb, &ctx);
Tomi Valkeinen36816fa2013-03-05 17:06:26 +0200104 if (ok) {
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200105 *fck = ctx.fck;
Tomi Valkeinen36816fa2013-03-05 17:06:26 +0200106 *dispc_cinfo = ctx.dispc_cinfo;
107 return 0;
108 }
109 }
110
111 return -EINVAL;
112}
113
Archit Taneja37a57992012-06-29 14:33:18 +0530114static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
Sumit Semwal64ba4f72010-12-02 11:27:10 +0000115{
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200116 enum omap_channel channel = dssdev->dispc_channel;
Archit Taneja7d6069e2012-09-04 11:49:30 +0530117
Archit Taneja37a57992012-06-29 14:33:18 +0530118 sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
119
120 sdi.mgr_config.stallmode = false;
121 sdi.mgr_config.fifohandcheck = false;
122
123 sdi.mgr_config.video_port_width = 24;
124 sdi.mgr_config.lcden_sig_polarity = 1;
125
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200126 dss_mgr_set_lcd_config(channel, &sdi.mgr_config);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300127}
128
Tomi Valkeinencd6e9152013-05-22 13:14:37 +0300129static int sdi_display_enable(struct omap_dss_device *dssdev)
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300130{
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +0300131 struct omap_dss_device *out = &sdi.output;
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200132 enum omap_channel channel = dssdev->dispc_channel;
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300133 struct videomode *vm = &sdi.vm;
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200134 unsigned long fck;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300135 struct dispc_clock_info dispc_cinfo;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300136 unsigned long pck;
137 int r;
138
Tomi Valkeinenf1504ad2015-11-05 09:34:51 +0200139 if (!out->dispc_channel_connected) {
Archit Taneja7d6069e2012-09-04 11:49:30 +0530140 DSSERR("failed to enable display: no output/manager\n");
Tomi Valkeinen05e1d602011-06-23 16:38:21 +0300141 return -ENODEV;
142 }
143
Roger Quadros508886c2010-03-17 13:35:21 +0100144 r = regulator_enable(sdi.vdds_sdi_reg);
145 if (r)
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300146 goto err_reg_enable;
Roger Quadros508886c2010-03-17 13:35:21 +0100147
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300148 r = dispc_runtime_get();
149 if (r)
150 goto err_get_dispc;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300151
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300152 /* 15.5.9.1.2 */
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300153 vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_SYNC_POSEDGE;
Archit Tanejaa8d5e412012-06-25 12:26:38 +0530154
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300155 r = sdi_calc_clock_div(vm->pixelclock, &fck, &dispc_cinfo);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300156 if (r)
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300157 goto err_calc_clock_div;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300158
Archit Taneja37a57992012-06-29 14:33:18 +0530159 sdi.mgr_config.clock_info = dispc_cinfo;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300160
Tomi Valkeinend8d789412013-04-10 14:12:14 +0300161 pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300162
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300163 if (pck != vm->pixelclock) {
Peter Ujfalusi7aa91e72016-09-22 14:07:02 +0300164 DSSWARN("Could not find exact pixel clock. Requested %lu Hz, got %lu Hz\n",
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300165 vm->pixelclock, pck);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300166
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300167 vm->pixelclock = pck;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300168 }
169
170
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300171 dss_mgr_set_timings(channel, vm);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300172
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200173 r = dss_set_fck_rate(fck);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300174 if (r)
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300175 goto err_set_dss_clock_div;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300176
Archit Taneja37a57992012-06-29 14:33:18 +0530177 sdi_config_lcd_manager(dssdev);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300178
Tomi Valkeinen35d67862012-08-21 09:09:47 +0300179 /*
180 * LCLK and PCLK divisors are located in shadow registers, and we
181 * normally write them to DISPC registers when enabling the output.
182 * However, SDI uses pck-free as source clock for its PLL, and pck-free
183 * is affected by the divisors. And as we need the PLL before enabling
184 * the output, we need to write the divisors early.
185 *
186 * It seems just writing to the DISPC register is enough, and we don't
187 * need to care about the shadow register mechanism for pck-free. The
188 * exact reason for this is unknown.
189 */
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200190 dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
Archit Taneja889b4fd2012-07-20 17:18:49 +0530191
Tomi Valkeinen66591452012-09-11 11:28:59 +0300192 dss_sdi_init(sdi.datapairs);
Tomi Valkeinen42c9dee2011-03-02 12:29:27 +0200193 r = dss_sdi_enable();
194 if (r)
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300195 goto err_sdi_enable;
Tomi Valkeinen42c9dee2011-03-02 12:29:27 +0200196 mdelay(2);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300197
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200198 r = dss_mgr_enable(channel);
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200199 if (r)
200 goto err_mgr_enable;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300201
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300202 return 0;
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300203
Tomi Valkeinen33ca2372011-11-21 13:42:58 +0200204err_mgr_enable:
205 dss_sdi_disable();
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300206err_sdi_enable:
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300207err_set_dss_clock_div:
208err_calc_clock_div:
209 dispc_runtime_put();
210err_get_dispc:
Roger Quadros508886c2010-03-17 13:35:21 +0100211 regulator_disable(sdi.vdds_sdi_reg);
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300212err_reg_enable:
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300213 return r;
214}
215
Tomi Valkeinencd6e9152013-05-22 13:14:37 +0300216static void sdi_display_disable(struct omap_dss_device *dssdev)
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300217{
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200218 enum omap_channel channel = dssdev->dispc_channel;
Archit Taneja7d6069e2012-09-04 11:49:30 +0530219
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200220 dss_mgr_disable(channel);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300221
222 dss_sdi_disable();
223
Tomi Valkeinen4fbafaf2011-05-27 10:52:19 +0300224 dispc_runtime_put();
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300225
Roger Quadros508886c2010-03-17 13:35:21 +0100226 regulator_disable(sdi.vdds_sdi_reg);
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300227}
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300228
Tomi Valkeinencd6e9152013-05-22 13:14:37 +0300229static void sdi_set_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300230 struct videomode *vm)
Archit Tanejac7833f72012-07-05 17:11:12 +0530231{
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300232 sdi.vm = *vm;
Archit Tanejac7833f72012-07-05 17:11:12 +0530233}
Archit Tanejac7833f72012-07-05 17:11:12 +0530234
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300235static void sdi_get_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300236 struct videomode *vm)
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300237{
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300238 *vm = sdi.vm;
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300239}
240
241static int sdi_check_timings(struct omap_dss_device *dssdev,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300242 struct videomode *vm)
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300243{
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200244 enum omap_channel channel = dssdev->dispc_channel;
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300245
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300246 if (!dispc_mgr_timings_ok(channel, vm))
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300247 return -EINVAL;
248
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300249 if (vm->pixelclock == 0)
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300250 return -EINVAL;
251
252 return 0;
253}
254
Tomi Valkeinend37801b2013-05-17 11:00:15 +0300255static int sdi_init_regulator(void)
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300256{
Tomi Valkeinend37801b2013-05-17 11:00:15 +0300257 struct regulator *vdds_sdi;
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300258
Tomi Valkeinend37801b2013-05-17 11:00:15 +0300259 if (sdi.vdds_sdi_reg)
260 return 0;
Tomi Valkeinen5f42f2ce2011-02-22 15:53:46 +0200261
Tomi Valkeinen349c3d92013-08-29 10:06:43 +0300262 vdds_sdi = devm_regulator_get(&sdi.pdev->dev, "vdds_sdi");
Tomi Valkeinend37801b2013-05-17 11:00:15 +0300263 if (IS_ERR(vdds_sdi)) {
Tomi Valkeinen40359a92013-12-19 16:15:34 +0200264 if (PTR_ERR(vdds_sdi) != -EPROBE_DEFER)
265 DSSERR("can't get VDDS_SDI regulator\n");
Tomi Valkeinen349c3d92013-08-29 10:06:43 +0300266 return PTR_ERR(vdds_sdi);
Tomi Valkeinen5f42f2ce2011-02-22 15:53:46 +0200267 }
268
Tomi Valkeinend37801b2013-05-17 11:00:15 +0300269 sdi.vdds_sdi_reg = vdds_sdi;
270
Tomi Valkeinen23c0a7a2009-08-05 16:18:44 +0300271 return 0;
272}
273
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300274static int sdi_connect(struct omap_dss_device *dssdev,
275 struct omap_dss_device *dst)
276{
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200277 enum omap_channel channel = dssdev->dispc_channel;
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300278 int r;
279
280 r = sdi_init_regulator();
281 if (r)
282 return r;
283
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200284 r = dss_mgr_connect(channel, dssdev);
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300285 if (r)
286 return r;
287
288 r = omapdss_output_set_device(dssdev, dst);
289 if (r) {
290 DSSERR("failed to connect output to new device: %s\n",
291 dst->name);
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200292 dss_mgr_disconnect(channel, dssdev);
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300293 return r;
294 }
295
296 return 0;
297}
298
299static void sdi_disconnect(struct omap_dss_device *dssdev,
300 struct omap_dss_device *dst)
301{
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200302 enum omap_channel channel = dssdev->dispc_channel;
303
Tomi Valkeinen9560dc102013-07-24 13:06:54 +0300304 WARN_ON(dst != dssdev->dst);
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300305
Tomi Valkeinen9560dc102013-07-24 13:06:54 +0300306 if (dst != dssdev->dst)
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300307 return;
308
309 omapdss_output_unset_device(dssdev);
310
Tomi Valkeinenc64b79c2015-11-05 09:57:04 +0200311 dss_mgr_disconnect(channel, dssdev);
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300312}
313
314static const struct omapdss_sdi_ops sdi_ops = {
315 .connect = sdi_connect,
316 .disconnect = sdi_disconnect,
317
Tomi Valkeinencd6e9152013-05-22 13:14:37 +0300318 .enable = sdi_display_enable,
319 .disable = sdi_display_disable,
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300320
321 .check_timings = sdi_check_timings,
Tomi Valkeinencd6e9152013-05-22 13:14:37 +0300322 .set_timings = sdi_set_timings,
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300323 .get_timings = sdi_get_timings,
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300324};
325
Tomi Valkeinend23b3352013-05-02 11:56:35 +0300326static void sdi_init_output(struct platform_device *pdev)
Archit Taneja81b87f52012-09-26 16:30:49 +0530327{
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +0300328 struct omap_dss_device *out = &sdi.output;
Archit Taneja81b87f52012-09-26 16:30:49 +0530329
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +0300330 out->dev = &pdev->dev;
Archit Taneja81b87f52012-09-26 16:30:49 +0530331 out->id = OMAP_DSS_OUTPUT_SDI;
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +0300332 out->output_type = OMAP_DISPLAY_TYPE_SDI;
Tomi Valkeinen7286a082013-02-18 13:06:01 +0200333 out->name = "sdi.0";
Tomi Valkeinen2eea5ae2013-02-13 11:23:54 +0200334 out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
Tomi Valkeinena32442d2014-12-29 09:57:11 +0200335 /* We have SDI only on OMAP3, where it's on port 1 */
336 out->port_num = 1;
Tomi Valkeinenb1082df2013-05-24 13:19:14 +0300337 out->ops.sdi = &sdi_ops;
Tomi Valkeinenb7328e12013-05-03 11:42:18 +0300338 out->owner = THIS_MODULE;
Archit Taneja81b87f52012-09-26 16:30:49 +0530339
Tomi Valkeinen5d47dbc2013-04-24 13:32:51 +0300340 omapdss_register_output(out);
Archit Taneja81b87f52012-09-26 16:30:49 +0530341}
342
Tomi Valkeinenede92692015-06-04 14:12:16 +0300343static void sdi_uninit_output(struct platform_device *pdev)
Archit Taneja81b87f52012-09-26 16:30:49 +0530344{
Tomi Valkeinen1f68d9c2013-04-19 15:09:34 +0300345 struct omap_dss_device *out = &sdi.output;
Archit Taneja81b87f52012-09-26 16:30:49 +0530346
Tomi Valkeinen5d47dbc2013-04-24 13:32:51 +0300347 omapdss_unregister_output(out);
Archit Taneja81b87f52012-09-26 16:30:49 +0530348}
349
Tomi Valkeinenede92692015-06-04 14:12:16 +0300350int sdi_init_port(struct platform_device *pdev, struct device_node *port)
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200351{
352 struct device_node *ep;
353 u32 datapairs;
354 int r;
355
Rob Herring09bffa62017-03-22 08:26:08 -0500356 ep = of_get_next_child(port, NULL);
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200357 if (!ep)
358 return 0;
359
360 r = of_property_read_u32(ep, "datapairs", &datapairs);
361 if (r) {
362 DSSERR("failed to parse datapairs\n");
363 goto err_datapairs;
364 }
365
366 sdi.datapairs = datapairs;
367
368 of_node_put(ep);
369
370 sdi.pdev = pdev;
371
372 sdi_init_output(pdev);
373
374 sdi.port_initialized = true;
375
376 return 0;
377
378err_datapairs:
379 of_node_put(ep);
380
381 return r;
382}
383
Tomi Valkeinenede92692015-06-04 14:12:16 +0300384void sdi_uninit_port(struct device_node *port)
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200385{
386 if (!sdi.port_initialized)
387 return;
388
389 sdi_uninit_output(sdi.pdev);
390}