blob: 8a5a61c9fb7c88043d6868414c92dccf26f62b8c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasutffdd4662013-04-28 09:20:03 +00002/*
3 * Freescale i.MX23/i.MX28 LCDIF driver
4 *
5 * Copyright (C) 2011-2013 Marek Vasut <marex@denx.de>
Marek Vasutffdd4662013-04-28 09:20:03 +00006 */
7#include <common.h>
Giulio Benettif14d0002020-04-08 17:10:13 +02008#include <clk.h>
Igor Opaniukf5abe402019-06-04 00:05:59 +03009#include <dm.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060010#include <env.h>
Simon Glass9bc15642020-02-03 07:36:16 -070011#include <dm/device_compat.h>
Igor Opaniuke2a8b182019-06-04 00:05:57 +030012#include <linux/errno.h>
Marek Vasutffdd4662013-04-28 09:20:03 +000013#include <malloc.h>
Igor Opaniukf5abe402019-06-04 00:05:59 +030014#include <video.h>
Marek Vasutffdd4662013-04-28 09:20:03 +000015#include <video_fb.h>
16
Marek Vasutffdd4662013-04-28 09:20:03 +000017#include <asm/arch/clock.h>
Igor Opaniuke2a8b182019-06-04 00:05:57 +030018#include <asm/arch/imx-regs.h>
Marek Vasutffdd4662013-04-28 09:20:03 +000019#include <asm/arch/sys_proto.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020020#include <asm/mach-imx/dma.h>
Igor Opaniuke2a8b182019-06-04 00:05:57 +030021#include <asm/io.h>
Marek Vasut8f15b5d2013-07-30 23:37:54 +020022
Marek Vasutffdd4662013-04-28 09:20:03 +000023#include "videomodes.h"
24
25#define PS2KHZ(ps) (1000000000UL / (ps))
Igor Opaniukf5abe402019-06-04 00:05:59 +030026#define HZ2PS(hz) (1000000000UL / ((hz) / 1000))
Marek Vasutffdd4662013-04-28 09:20:03 +000027
Igor Opaniukf5abe402019-06-04 00:05:59 +030028#define BITS_PP 18
29#define BYTES_PP 4
30
Marek Vasut8f15b5d2013-07-30 23:37:54 +020031struct mxs_dma_desc desc;
Marek Vasutffdd4662013-04-28 09:20:03 +000032
Marek Vasutcd701a12013-07-30 23:37:53 +020033/**
34 * mxsfb_system_setup() - Fine-tune LCDIF configuration
35 *
36 * This function is used to adjust the LCDIF configuration. This is usually
37 * needed when driving the controller in System-Mode to operate an 8080 or
38 * 6800 connected SmartLCD.
39 */
40__weak void mxsfb_system_setup(void)
41{
42}
43
Marek Vasutffdd4662013-04-28 09:20:03 +000044/*
Marek Vasutec58ab22017-04-05 13:31:01 +020045 * ARIES M28EVK:
Marek Vasutffdd4662013-04-28 09:20:03 +000046 * setenv videomode
47 * video=ctfb:x:800,y:480,depth:18,mode:0,pclk:30066,
48 * le:0,ri:256,up:0,lo:45,hs:1,vs:1,sync:100663296,vmode:0
Fabio Estevama2824192013-05-10 09:14:11 +000049 *
50 * Freescale mx23evk/mx28evk with a Seiko 4.3'' WVGA panel:
51 * setenv videomode
52 * video=ctfb:x:800,y:480,depth:24,mode:0,pclk:29851,
53 * le:89,ri:164,up:23,lo:10,hs:10,vs:10,sync:0,vmode:0
Marek Vasutffdd4662013-04-28 09:20:03 +000054 */
55
Giulio Benettif14d0002020-04-08 17:10:13 +020056static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
Giulio Benettiac6d7f12020-04-08 17:10:15 +020057 struct display_timing *timings, int bpp)
Marek Vasutffdd4662013-04-28 09:20:03 +000058{
59 struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
Giulio Benettie0305242020-04-08 17:10:16 +020060 const enum display_flags flags = timings->flags;
Marek Vasutffdd4662013-04-28 09:20:03 +000061 uint32_t word_len = 0, bus_width = 0;
62 uint8_t valid_data = 0;
Giulio Benettie0305242020-04-08 17:10:16 +020063 uint32_t vdctrl0;
Marek Vasutffdd4662013-04-28 09:20:03 +000064
Giulio Benettif14d0002020-04-08 17:10:13 +020065#if CONFIG_IS_ENABLED(CLK)
66 struct clk per_clk;
67 int ret;
68
69 ret = clk_get_by_name(dev, "per", &per_clk);
70 if (ret) {
71 dev_err(dev, "Failed to get mxs clk: %d\n", ret);
72 return;
73 }
74
Giulio Benettiac6d7f12020-04-08 17:10:15 +020075 ret = clk_set_rate(&per_clk, timings->pixelclock.typ);
Giulio Benettif14d0002020-04-08 17:10:13 +020076 if (ret < 0) {
77 dev_err(dev, "Failed to set mxs clk: %d\n", ret);
78 return;
79 }
80#else
Fabio Estevam092da182019-11-24 17:37:52 -030081 /* Kick in the LCDIF clock */
Giulio Benettiac6d7f12020-04-08 17:10:15 +020082 mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);
Giulio Benettif14d0002020-04-08 17:10:13 +020083#endif
Fabio Estevam092da182019-11-24 17:37:52 -030084
Marek Vasutffdd4662013-04-28 09:20:03 +000085 /* Restart the LCDIF block */
86 mxs_reset_block(&regs->hw_lcdif_ctrl_reg);
87
88 switch (bpp) {
89 case 24:
90 word_len = LCDIF_CTRL_WORD_LENGTH_24BIT;
91 bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_24BIT;
92 valid_data = 0x7;
93 break;
94 case 18:
95 word_len = LCDIF_CTRL_WORD_LENGTH_24BIT;
96 bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_18BIT;
97 valid_data = 0x7;
98 break;
99 case 16:
100 word_len = LCDIF_CTRL_WORD_LENGTH_16BIT;
101 bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_16BIT;
102 valid_data = 0xf;
103 break;
104 case 8:
105 word_len = LCDIF_CTRL_WORD_LENGTH_8BIT;
106 bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_8BIT;
107 valid_data = 0xf;
108 break;
109 }
110
111 writel(bus_width | word_len | LCDIF_CTRL_DOTCLK_MODE |
112 LCDIF_CTRL_BYPASS_COUNT | LCDIF_CTRL_LCDIF_MASTER,
113 &regs->hw_lcdif_ctrl);
114
115 writel(valid_data << LCDIF_CTRL1_BYTE_PACKING_FORMAT_OFFSET,
116 &regs->hw_lcdif_ctrl1);
Marek Vasutcd701a12013-07-30 23:37:53 +0200117
118 mxsfb_system_setup();
119
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200120 writel((timings->vactive.typ << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) |
121 timings->hactive.typ, &regs->hw_lcdif_transfer_count);
Marek Vasutffdd4662013-04-28 09:20:03 +0000122
Giulio Benettie0305242020-04-08 17:10:16 +0200123 vdctrl0 = LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL |
124 LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT |
125 LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |
126 timings->vsync_len.typ;
127
128 if(flags & DISPLAY_FLAGS_HSYNC_HIGH)
129 vdctrl0 |= LCDIF_VDCTRL0_HSYNC_POL;
Giulio Benetti996d96a2020-04-08 17:10:17 +0200130 if(flags & DISPLAY_FLAGS_VSYNC_HIGH)
131 vdctrl0 |= LCDIF_VDCTRL0_VSYNC_POL;
Giulio Benettie9238d62020-04-08 17:10:18 +0200132 if(flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
133 vdctrl0 |= LCDIF_VDCTRL0_DOTCLK_POL;
Giulio Benetti927858e2020-04-08 17:10:19 +0200134 if(flags & DISPLAY_FLAGS_DE_HIGH)
135 vdctrl0 |= LCDIF_VDCTRL0_ENABLE_POL;
136
Giulio Benettie0305242020-04-08 17:10:16 +0200137 writel(vdctrl0, &regs->hw_lcdif_vdctrl0);
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200138 writel(timings->vback_porch.typ + timings->vfront_porch.typ +
139 timings->vsync_len.typ + timings->vactive.typ,
Marek Vasutffdd4662013-04-28 09:20:03 +0000140 &regs->hw_lcdif_vdctrl1);
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200141 writel((timings->hsync_len.typ << LCDIF_VDCTRL2_HSYNC_PULSE_WIDTH_OFFSET) |
142 (timings->hback_porch.typ + timings->hfront_porch.typ +
143 timings->hsync_len.typ + timings->hactive.typ),
Marek Vasutffdd4662013-04-28 09:20:03 +0000144 &regs->hw_lcdif_vdctrl2);
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200145 writel(((timings->hback_porch.typ + timings->hsync_len.typ) <<
Marek Vasutffdd4662013-04-28 09:20:03 +0000146 LCDIF_VDCTRL3_HORIZONTAL_WAIT_CNT_OFFSET) |
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200147 (timings->vback_porch.typ + timings->vsync_len.typ),
Marek Vasutffdd4662013-04-28 09:20:03 +0000148 &regs->hw_lcdif_vdctrl3);
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200149 writel((0 << LCDIF_VDCTRL4_DOTCLK_DLY_SEL_OFFSET) | timings->hactive.typ,
Marek Vasutffdd4662013-04-28 09:20:03 +0000150 &regs->hw_lcdif_vdctrl4);
151
Igor Opaniuk5fd35532019-06-04 00:05:56 +0300152 writel(fb_addr, &regs->hw_lcdif_cur_buf);
153 writel(fb_addr, &regs->hw_lcdif_next_buf);
Marek Vasutffdd4662013-04-28 09:20:03 +0000154
155 /* Flush FIFO first */
156 writel(LCDIF_CTRL1_FIFO_CLEAR, &regs->hw_lcdif_ctrl1_set);
157
Marek Vasutcd701a12013-07-30 23:37:53 +0200158#ifndef CONFIG_VIDEO_MXS_MODE_SYSTEM
Marek Vasutffdd4662013-04-28 09:20:03 +0000159 /* Sync signals ON */
160 setbits_le32(&regs->hw_lcdif_vdctrl4, LCDIF_VDCTRL4_SYNC_SIGNALS_ON);
Marek Vasutcd701a12013-07-30 23:37:53 +0200161#endif
Marek Vasutffdd4662013-04-28 09:20:03 +0000162
163 /* FIFO cleared */
164 writel(LCDIF_CTRL1_FIFO_CLEAR, &regs->hw_lcdif_ctrl1_clr);
165
166 /* RUN! */
167 writel(LCDIF_CTRL_RUN, &regs->hw_lcdif_ctrl_set);
168}
169
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200170static int mxs_probe_common(struct udevice *dev, struct display_timing *timings,
Giulio Benettif14d0002020-04-08 17:10:13 +0200171 int bpp, u32 fb)
Igor Opaniuk36734922019-06-04 00:05:58 +0300172{
173 /* Start framebuffer */
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200174 mxs_lcd_init(dev, fb, timings, bpp);
Igor Opaniuk36734922019-06-04 00:05:58 +0300175
176#ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
177 /*
178 * If the LCD runs in system mode, the LCD refresh has to be triggered
179 * manually by setting the RUN bit in HW_LCDIF_CTRL register. To avoid
180 * having to set this bit manually after every single change in the
181 * framebuffer memory, we set up specially crafted circular DMA, which
182 * sets the RUN bit, then waits until it gets cleared and repeats this
183 * infinitelly. This way, we get smooth continuous updates of the LCD.
184 */
185 struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
186
187 memset(&desc, 0, sizeof(struct mxs_dma_desc));
188 desc.address = (dma_addr_t)&desc;
189 desc.cmd.data = MXS_DMA_DESC_COMMAND_NO_DMAXFER | MXS_DMA_DESC_CHAIN |
190 MXS_DMA_DESC_WAIT4END |
191 (1 << MXS_DMA_DESC_PIO_WORDS_OFFSET);
192 desc.cmd.pio_words[0] = readl(&regs->hw_lcdif_ctrl) | LCDIF_CTRL_RUN;
193 desc.cmd.next = (uint32_t)&desc.cmd;
194
195 /* Execute the DMA chain. */
196 mxs_dma_circ_start(MXS_DMA_CHANNEL_AHB_APBH_LCDIF, &desc);
197#endif
198
199 return 0;
200}
201
Igor Opaniukf5abe402019-06-04 00:05:59 +0300202static int mxs_remove_common(u32 fb)
Peng Fan5f8dbf52015-10-29 15:54:49 +0800203{
204 struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
205 int timeout = 1000000;
206
Igor Opaniukf5abe402019-06-04 00:05:59 +0300207 if (!fb)
208 return -EINVAL;
Fabio Estevamef84cf62017-02-22 10:40:22 -0300209
Igor Opaniukf5abe402019-06-04 00:05:59 +0300210 writel(fb, &regs->hw_lcdif_cur_buf_reg);
211 writel(fb, &regs->hw_lcdif_next_buf_reg);
Peng Fan5f8dbf52015-10-29 15:54:49 +0800212 writel(LCDIF_CTRL1_VSYNC_EDGE_IRQ, &regs->hw_lcdif_ctrl1_clr);
213 while (--timeout) {
214 if (readl(&regs->hw_lcdif_ctrl1_reg) &
215 LCDIF_CTRL1_VSYNC_EDGE_IRQ)
216 break;
217 udelay(1);
218 }
219 mxs_reset_block((struct mxs_register_32 *)&regs->hw_lcdif_ctrl_reg);
Igor Opaniukf5abe402019-06-04 00:05:59 +0300220
221 return 0;
222}
223
224#ifndef CONFIG_DM_VIDEO
225
226static GraphicDevice panel;
227
228void lcdif_power_down(void)
229{
230 mxs_remove_common(panel.frameAdrs);
Peng Fan5f8dbf52015-10-29 15:54:49 +0800231}
232
Marek Vasutffdd4662013-04-28 09:20:03 +0000233void *video_hw_init(void)
234{
235 int bpp = -1;
Igor Opaniuk36734922019-06-04 00:05:58 +0300236 int ret = 0;
Marek Vasutffdd4662013-04-28 09:20:03 +0000237 char *penv;
Igor Opaniuk36734922019-06-04 00:05:58 +0300238 void *fb = NULL;
Marek Vasutffdd4662013-04-28 09:20:03 +0000239 struct ctfb_res_modes mode;
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200240 struct display_timing timings;
Marek Vasutffdd4662013-04-28 09:20:03 +0000241
242 puts("Video: ");
243
244 /* Suck display configuration from "videomode" variable */
Simon Glass64b723f2017-08-03 12:22:12 -0600245 penv = env_get("videomode");
Marek Vasutffdd4662013-04-28 09:20:03 +0000246 if (!penv) {
Fabio Estevam56147832013-06-26 16:08:13 -0300247 puts("MXSFB: 'videomode' variable not set!\n");
Marek Vasutffdd4662013-04-28 09:20:03 +0000248 return NULL;
249 }
250
251 bpp = video_get_params(&mode, penv);
252
253 /* fill in Graphic device struct */
Igor Opaniuk36734922019-06-04 00:05:58 +0300254 sprintf(panel.modeIdent, "%dx%dx%d", mode.xres, mode.yres, bpp);
Marek Vasutffdd4662013-04-28 09:20:03 +0000255
256 panel.winSizeX = mode.xres;
257 panel.winSizeY = mode.yres;
258 panel.plnSizeX = mode.xres;
259 panel.plnSizeY = mode.yres;
260
261 switch (bpp) {
262 case 24:
263 case 18:
264 panel.gdfBytesPP = 4;
265 panel.gdfIndex = GDF_32BIT_X888RGB;
266 break;
267 case 16:
268 panel.gdfBytesPP = 2;
269 panel.gdfIndex = GDF_16BIT_565RGB;
270 break;
271 case 8:
272 panel.gdfBytesPP = 1;
273 panel.gdfIndex = GDF__8BIT_INDEX;
274 break;
275 default:
276 printf("MXSFB: Invalid BPP specified! (bpp = %i)\n", bpp);
277 return NULL;
278 }
279
280 panel.memSize = mode.xres * mode.yres * panel.gdfBytesPP;
281
282 /* Allocate framebuffer */
Marek Vasutce74fac2013-07-30 23:37:52 +0200283 fb = memalign(ARCH_DMA_MINALIGN,
284 roundup(panel.memSize, ARCH_DMA_MINALIGN));
Marek Vasutffdd4662013-04-28 09:20:03 +0000285 if (!fb) {
286 printf("MXSFB: Error allocating framebuffer!\n");
287 return NULL;
288 }
289
290 /* Wipe framebuffer */
291 memset(fb, 0, panel.memSize);
292
293 panel.frameAdrs = (u32)fb;
294
295 printf("%s\n", panel.modeIdent);
296
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200297 video_ctfb_mode_to_display_timing(&mode, &timings);
298
299 ret = mxs_probe_common(NULL, &timings, bpp, (u32)fb);
Igor Opaniuk36734922019-06-04 00:05:58 +0300300 if (ret)
301 goto dealloc_fb;
Marek Vasut8f15b5d2013-07-30 23:37:54 +0200302
Igor Opaniuk36734922019-06-04 00:05:58 +0300303 return (void *)&panel;
Marek Vasut8f15b5d2013-07-30 23:37:54 +0200304
Igor Opaniuk36734922019-06-04 00:05:58 +0300305dealloc_fb:
306 free(fb);
Marek Vasut8f15b5d2013-07-30 23:37:54 +0200307
Igor Opaniuk36734922019-06-04 00:05:58 +0300308 return NULL;
Marek Vasutffdd4662013-04-28 09:20:03 +0000309}
Igor Opaniukf5abe402019-06-04 00:05:59 +0300310#else /* ifndef CONFIG_DM_VIDEO */
311
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300312static int mxs_of_get_timings(struct udevice *dev,
313 struct display_timing *timings,
314 u32 *bpp)
315{
316 int ret = 0;
317 u32 display_phandle;
318 ofnode display_node;
319
320 ret = ofnode_read_u32(dev_ofnode(dev), "display", &display_phandle);
321 if (ret) {
322 dev_err(dev, "required display property isn't provided\n");
323 return -EINVAL;
324 }
325
326 display_node = ofnode_get_by_phandle(display_phandle);
327 if (!ofnode_valid(display_node)) {
328 dev_err(dev, "failed to find display subnode\n");
329 return -EINVAL;
330 }
331
332 ret = ofnode_read_u32(display_node, "bits-per-pixel", bpp);
333 if (ret) {
334 dev_err(dev,
335 "required bits-per-pixel property isn't provided\n");
336 return -EINVAL;
337 }
338
339 ret = ofnode_decode_display_timing(display_node, 0, timings);
340 if (ret) {
341 dev_err(dev, "failed to get any display timings\n");
342 return -EINVAL;
343 }
344
345 return ret;
346}
347
Igor Opaniukf5abe402019-06-04 00:05:59 +0300348static int mxs_video_probe(struct udevice *dev)
349{
350 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
351 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
352
Igor Opaniukf5abe402019-06-04 00:05:59 +0300353 struct display_timing timings;
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300354 u32 bpp = 0;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300355 u32 fb_start, fb_end;
356 int ret;
357
358 debug("%s() plat: base 0x%lx, size 0x%x\n",
359 __func__, plat->base, plat->size);
360
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300361 ret = mxs_of_get_timings(dev, &timings, &bpp);
362 if (ret)
363 return ret;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300364
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200365 ret = mxs_probe_common(dev, &timings, bpp, plat->base);
Igor Opaniukf5abe402019-06-04 00:05:59 +0300366 if (ret)
367 return ret;
368
369 switch (bpp) {
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300370 case 32:
Igor Opaniukf5abe402019-06-04 00:05:59 +0300371 case 24:
372 case 18:
373 uc_priv->bpix = VIDEO_BPP32;
374 break;
375 case 16:
376 uc_priv->bpix = VIDEO_BPP16;
377 break;
378 case 8:
379 uc_priv->bpix = VIDEO_BPP8;
380 break;
381 default:
382 dev_err(dev, "invalid bpp specified (bpp = %i)\n", bpp);
383 return -EINVAL;
384 }
385
Giulio Benettiac6d7f12020-04-08 17:10:15 +0200386 uc_priv->xsize = timings.hactive.typ;
387 uc_priv->ysize = timings.vactive.typ;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300388
389 /* Enable dcache for the frame buffer */
390 fb_start = plat->base & ~(MMU_SECTION_SIZE - 1);
391 fb_end = plat->base + plat->size;
392 fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
393 mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
394 DCACHE_WRITEBACK);
395 video_set_flush_dcache(dev, true);
Sébastien Szymanskieb9b6a82019-10-21 15:33:04 +0200396 gd->fb_base = plat->base;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300397
398 return ret;
399}
400
401static int mxs_video_bind(struct udevice *dev)
402{
403 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
404 struct display_timing timings;
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300405 u32 bpp = 0;
406 u32 bytes_pp = 0;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300407 int ret;
408
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300409 ret = mxs_of_get_timings(dev, &timings, &bpp);
410 if (ret)
411 return ret;
412
413 switch (bpp) {
414 case 32:
415 case 24:
416 case 18:
417 bytes_pp = 4;
418 break;
419 case 16:
420 bytes_pp = 2;
421 break;
422 case 8:
423 bytes_pp = 1;
424 break;
425 default:
426 dev_err(dev, "invalid bpp specified (bpp = %i)\n", bpp);
Igor Opaniukf5abe402019-06-04 00:05:59 +0300427 return -EINVAL;
428 }
429
Igor Opaniuk994f49a2019-06-19 11:47:05 +0300430 plat->size = timings.hactive.typ * timings.vactive.typ * bytes_pp;
Igor Opaniukf5abe402019-06-04 00:05:59 +0300431
432 return 0;
433}
434
435static int mxs_video_remove(struct udevice *dev)
436{
437 struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
438
439 mxs_remove_common(plat->base);
440
441 return 0;
442}
443
444static const struct udevice_id mxs_video_ids[] = {
445 { .compatible = "fsl,imx23-lcdif" },
446 { .compatible = "fsl,imx28-lcdif" },
447 { .compatible = "fsl,imx7ulp-lcdif" },
Giulio Benetti83677312020-04-08 17:10:14 +0200448 { .compatible = "fsl,imxrt-lcdif" },
Igor Opaniukf5abe402019-06-04 00:05:59 +0300449 { /* sentinel */ }
450};
451
452U_BOOT_DRIVER(mxs_video) = {
453 .name = "mxs_video",
454 .id = UCLASS_VIDEO,
455 .of_match = mxs_video_ids,
456 .bind = mxs_video_bind,
457 .probe = mxs_video_probe,
458 .remove = mxs_video_remove,
Anatolij Gustschinf9888f92020-01-25 23:44:56 +0100459 .flags = DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE,
Igor Opaniukf5abe402019-06-04 00:05:59 +0300460};
461#endif /* ifndef CONFIG_DM_VIDEO */