Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Freescale i.MX23/i.MX28 LCDIF driver |
| 4 | * |
| 5 | * Copyright (C) 2011-2013 Marek Vasut <marex@denx.de> |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 6 | */ |
| 7 | #include <common.h> |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 8 | #include <dm.h> |
Igor Opaniuk | 2381632 | 2019-06-04 00:05:57 +0300 | [diff] [blame] | 9 | #include <linux/errno.h> |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 10 | #include <malloc.h> |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 11 | #include <video.h> |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 12 | #include <video_fb.h> |
| 13 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 14 | #include <asm/arch/clock.h> |
Igor Opaniuk | 2381632 | 2019-06-04 00:05:57 +0300 | [diff] [blame] | 15 | #include <asm/arch/imx-regs.h> |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 16 | #include <asm/arch/sys_proto.h> |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 17 | #include <asm/mach-imx/dma.h> |
Igor Opaniuk | 2381632 | 2019-06-04 00:05:57 +0300 | [diff] [blame] | 18 | #include <asm/io.h> |
Marek Vasut | 84f957f | 2013-07-30 23:37:54 +0200 | [diff] [blame] | 19 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 20 | #include "videomodes.h" |
| 21 | |
| 22 | #define PS2KHZ(ps) (1000000000UL / (ps)) |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 23 | #define HZ2PS(hz) (1000000000UL / ((hz) / 1000)) |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 24 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 25 | #define BITS_PP 18 |
| 26 | #define BYTES_PP 4 |
| 27 | |
Marek Vasut | 84f957f | 2013-07-30 23:37:54 +0200 | [diff] [blame] | 28 | struct mxs_dma_desc desc; |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 29 | |
Marek Vasut | 9de4b72 | 2013-07-30 23:37:53 +0200 | [diff] [blame] | 30 | /** |
| 31 | * mxsfb_system_setup() - Fine-tune LCDIF configuration |
| 32 | * |
| 33 | * This function is used to adjust the LCDIF configuration. This is usually |
| 34 | * needed when driving the controller in System-Mode to operate an 8080 or |
| 35 | * 6800 connected SmartLCD. |
| 36 | */ |
| 37 | __weak void mxsfb_system_setup(void) |
| 38 | { |
| 39 | } |
| 40 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 41 | /* |
Marek Vasut | fcea480 | 2017-04-05 13:31:01 +0200 | [diff] [blame] | 42 | * ARIES M28EVK: |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 43 | * setenv videomode |
| 44 | * video=ctfb:x:800,y:480,depth:18,mode:0,pclk:30066, |
| 45 | * le:0,ri:256,up:0,lo:45,hs:1,vs:1,sync:100663296,vmode:0 |
Fabio Estevam | 11f98d1 | 2013-05-10 09:14:11 +0000 | [diff] [blame] | 46 | * |
| 47 | * Freescale mx23evk/mx28evk with a Seiko 4.3'' WVGA panel: |
| 48 | * setenv videomode |
| 49 | * video=ctfb:x:800,y:480,depth:24,mode:0,pclk:29851, |
| 50 | * le:89,ri:164,up:23,lo:10,hs:10,vs:10,sync:0,vmode:0 |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 51 | */ |
| 52 | |
Igor Opaniuk | dcd91a6 | 2019-06-04 00:05:56 +0300 | [diff] [blame] | 53 | static void mxs_lcd_init(u32 fb_addr, struct ctfb_res_modes *mode, int bpp) |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 54 | { |
| 55 | struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE; |
| 56 | uint32_t word_len = 0, bus_width = 0; |
| 57 | uint8_t valid_data = 0; |
| 58 | |
| 59 | /* Kick in the LCDIF clock */ |
Peng Fan | 95ae700 | 2015-10-29 15:54:39 +0800 | [diff] [blame] | 60 | mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock)); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 61 | |
| 62 | /* Restart the LCDIF block */ |
| 63 | mxs_reset_block(®s->hw_lcdif_ctrl_reg); |
| 64 | |
| 65 | switch (bpp) { |
| 66 | case 24: |
| 67 | word_len = LCDIF_CTRL_WORD_LENGTH_24BIT; |
| 68 | bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_24BIT; |
| 69 | valid_data = 0x7; |
| 70 | break; |
| 71 | case 18: |
| 72 | word_len = LCDIF_CTRL_WORD_LENGTH_24BIT; |
| 73 | bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_18BIT; |
| 74 | valid_data = 0x7; |
| 75 | break; |
| 76 | case 16: |
| 77 | word_len = LCDIF_CTRL_WORD_LENGTH_16BIT; |
| 78 | bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_16BIT; |
| 79 | valid_data = 0xf; |
| 80 | break; |
| 81 | case 8: |
| 82 | word_len = LCDIF_CTRL_WORD_LENGTH_8BIT; |
| 83 | bus_width = LCDIF_CTRL_LCD_DATABUS_WIDTH_8BIT; |
| 84 | valid_data = 0xf; |
| 85 | break; |
| 86 | } |
| 87 | |
| 88 | writel(bus_width | word_len | LCDIF_CTRL_DOTCLK_MODE | |
| 89 | LCDIF_CTRL_BYPASS_COUNT | LCDIF_CTRL_LCDIF_MASTER, |
| 90 | ®s->hw_lcdif_ctrl); |
| 91 | |
| 92 | writel(valid_data << LCDIF_CTRL1_BYTE_PACKING_FORMAT_OFFSET, |
| 93 | ®s->hw_lcdif_ctrl1); |
Marek Vasut | 9de4b72 | 2013-07-30 23:37:53 +0200 | [diff] [blame] | 94 | |
| 95 | mxsfb_system_setup(); |
| 96 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 97 | writel((mode->yres << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) | mode->xres, |
| 98 | ®s->hw_lcdif_transfer_count); |
| 99 | |
| 100 | writel(LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL | |
| 101 | LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT | |
| 102 | LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT | |
| 103 | mode->vsync_len, ®s->hw_lcdif_vdctrl0); |
| 104 | writel(mode->upper_margin + mode->lower_margin + |
| 105 | mode->vsync_len + mode->yres, |
| 106 | ®s->hw_lcdif_vdctrl1); |
| 107 | writel((mode->hsync_len << LCDIF_VDCTRL2_HSYNC_PULSE_WIDTH_OFFSET) | |
| 108 | (mode->left_margin + mode->right_margin + |
| 109 | mode->hsync_len + mode->xres), |
| 110 | ®s->hw_lcdif_vdctrl2); |
| 111 | writel(((mode->left_margin + mode->hsync_len) << |
| 112 | LCDIF_VDCTRL3_HORIZONTAL_WAIT_CNT_OFFSET) | |
| 113 | (mode->upper_margin + mode->vsync_len), |
| 114 | ®s->hw_lcdif_vdctrl3); |
| 115 | writel((0 << LCDIF_VDCTRL4_DOTCLK_DLY_SEL_OFFSET) | mode->xres, |
| 116 | ®s->hw_lcdif_vdctrl4); |
| 117 | |
Igor Opaniuk | dcd91a6 | 2019-06-04 00:05:56 +0300 | [diff] [blame] | 118 | writel(fb_addr, ®s->hw_lcdif_cur_buf); |
| 119 | writel(fb_addr, ®s->hw_lcdif_next_buf); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 120 | |
| 121 | /* Flush FIFO first */ |
| 122 | writel(LCDIF_CTRL1_FIFO_CLEAR, ®s->hw_lcdif_ctrl1_set); |
| 123 | |
Marek Vasut | 9de4b72 | 2013-07-30 23:37:53 +0200 | [diff] [blame] | 124 | #ifndef CONFIG_VIDEO_MXS_MODE_SYSTEM |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 125 | /* Sync signals ON */ |
| 126 | setbits_le32(®s->hw_lcdif_vdctrl4, LCDIF_VDCTRL4_SYNC_SIGNALS_ON); |
Marek Vasut | 9de4b72 | 2013-07-30 23:37:53 +0200 | [diff] [blame] | 127 | #endif |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 128 | |
| 129 | /* FIFO cleared */ |
| 130 | writel(LCDIF_CTRL1_FIFO_CLEAR, ®s->hw_lcdif_ctrl1_clr); |
| 131 | |
| 132 | /* RUN! */ |
| 133 | writel(LCDIF_CTRL_RUN, ®s->hw_lcdif_ctrl_set); |
| 134 | } |
| 135 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 136 | static int mxs_probe_common(struct ctfb_res_modes *mode, int bpp, u32 fb) |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 137 | { |
| 138 | /* Start framebuffer */ |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 139 | mxs_lcd_init(fb, mode, bpp); |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 140 | |
| 141 | #ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM |
| 142 | /* |
| 143 | * If the LCD runs in system mode, the LCD refresh has to be triggered |
| 144 | * manually by setting the RUN bit in HW_LCDIF_CTRL register. To avoid |
| 145 | * having to set this bit manually after every single change in the |
| 146 | * framebuffer memory, we set up specially crafted circular DMA, which |
| 147 | * sets the RUN bit, then waits until it gets cleared and repeats this |
| 148 | * infinitelly. This way, we get smooth continuous updates of the LCD. |
| 149 | */ |
| 150 | struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE; |
| 151 | |
| 152 | memset(&desc, 0, sizeof(struct mxs_dma_desc)); |
| 153 | desc.address = (dma_addr_t)&desc; |
| 154 | desc.cmd.data = MXS_DMA_DESC_COMMAND_NO_DMAXFER | MXS_DMA_DESC_CHAIN | |
| 155 | MXS_DMA_DESC_WAIT4END | |
| 156 | (1 << MXS_DMA_DESC_PIO_WORDS_OFFSET); |
| 157 | desc.cmd.pio_words[0] = readl(®s->hw_lcdif_ctrl) | LCDIF_CTRL_RUN; |
| 158 | desc.cmd.next = (uint32_t)&desc.cmd; |
| 159 | |
| 160 | /* Execute the DMA chain. */ |
| 161 | mxs_dma_circ_start(MXS_DMA_CHANNEL_AHB_APBH_LCDIF, &desc); |
| 162 | #endif |
| 163 | |
| 164 | return 0; |
| 165 | } |
| 166 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 167 | static int mxs_remove_common(u32 fb) |
Peng Fan | a3c252d | 2015-10-29 15:54:49 +0800 | [diff] [blame] | 168 | { |
| 169 | struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE; |
| 170 | int timeout = 1000000; |
| 171 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 172 | if (!fb) |
| 173 | return -EINVAL; |
Fabio Estevam | b24cf85 | 2017-02-22 10:40:22 -0300 | [diff] [blame] | 174 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 175 | writel(fb, ®s->hw_lcdif_cur_buf_reg); |
| 176 | writel(fb, ®s->hw_lcdif_next_buf_reg); |
Peng Fan | a3c252d | 2015-10-29 15:54:49 +0800 | [diff] [blame] | 177 | writel(LCDIF_CTRL1_VSYNC_EDGE_IRQ, ®s->hw_lcdif_ctrl1_clr); |
| 178 | while (--timeout) { |
| 179 | if (readl(®s->hw_lcdif_ctrl1_reg) & |
| 180 | LCDIF_CTRL1_VSYNC_EDGE_IRQ) |
| 181 | break; |
| 182 | udelay(1); |
| 183 | } |
| 184 | mxs_reset_block((struct mxs_register_32 *)®s->hw_lcdif_ctrl_reg); |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | #ifndef CONFIG_DM_VIDEO |
| 190 | |
| 191 | static GraphicDevice panel; |
| 192 | |
| 193 | void lcdif_power_down(void) |
| 194 | { |
| 195 | mxs_remove_common(panel.frameAdrs); |
Peng Fan | a3c252d | 2015-10-29 15:54:49 +0800 | [diff] [blame] | 196 | } |
| 197 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 198 | void *video_hw_init(void) |
| 199 | { |
| 200 | int bpp = -1; |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 201 | int ret = 0; |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 202 | char *penv; |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 203 | void *fb = NULL; |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 204 | struct ctfb_res_modes mode; |
| 205 | |
| 206 | puts("Video: "); |
| 207 | |
| 208 | /* Suck display configuration from "videomode" variable */ |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 209 | penv = env_get("videomode"); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 210 | if (!penv) { |
Fabio Estevam | 620ca1c | 2013-06-26 16:08:13 -0300 | [diff] [blame] | 211 | puts("MXSFB: 'videomode' variable not set!\n"); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 212 | return NULL; |
| 213 | } |
| 214 | |
| 215 | bpp = video_get_params(&mode, penv); |
| 216 | |
| 217 | /* fill in Graphic device struct */ |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 218 | sprintf(panel.modeIdent, "%dx%dx%d", mode.xres, mode.yres, bpp); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 219 | |
| 220 | panel.winSizeX = mode.xres; |
| 221 | panel.winSizeY = mode.yres; |
| 222 | panel.plnSizeX = mode.xres; |
| 223 | panel.plnSizeY = mode.yres; |
| 224 | |
| 225 | switch (bpp) { |
| 226 | case 24: |
| 227 | case 18: |
| 228 | panel.gdfBytesPP = 4; |
| 229 | panel.gdfIndex = GDF_32BIT_X888RGB; |
| 230 | break; |
| 231 | case 16: |
| 232 | panel.gdfBytesPP = 2; |
| 233 | panel.gdfIndex = GDF_16BIT_565RGB; |
| 234 | break; |
| 235 | case 8: |
| 236 | panel.gdfBytesPP = 1; |
| 237 | panel.gdfIndex = GDF__8BIT_INDEX; |
| 238 | break; |
| 239 | default: |
| 240 | printf("MXSFB: Invalid BPP specified! (bpp = %i)\n", bpp); |
| 241 | return NULL; |
| 242 | } |
| 243 | |
| 244 | panel.memSize = mode.xres * mode.yres * panel.gdfBytesPP; |
| 245 | |
| 246 | /* Allocate framebuffer */ |
Marek Vasut | e57baf5 | 2013-07-30 23:37:52 +0200 | [diff] [blame] | 247 | fb = memalign(ARCH_DMA_MINALIGN, |
| 248 | roundup(panel.memSize, ARCH_DMA_MINALIGN)); |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 249 | if (!fb) { |
| 250 | printf("MXSFB: Error allocating framebuffer!\n"); |
| 251 | return NULL; |
| 252 | } |
| 253 | |
| 254 | /* Wipe framebuffer */ |
| 255 | memset(fb, 0, panel.memSize); |
| 256 | |
| 257 | panel.frameAdrs = (u32)fb; |
| 258 | |
| 259 | printf("%s\n", panel.modeIdent); |
| 260 | |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 261 | ret = mxs_probe_common(&mode, bpp, (u32)fb); |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 262 | if (ret) |
| 263 | goto dealloc_fb; |
Marek Vasut | 84f957f | 2013-07-30 23:37:54 +0200 | [diff] [blame] | 264 | |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 265 | return (void *)&panel; |
Igor Opaniuk | 9a67205 | 2019-06-04 00:05:58 +0300 | [diff] [blame] | 266 | |
| 267 | dealloc_fb: |
| 268 | free(fb); |
| 269 | |
| 270 | return NULL; |
Marek Vasut | fb8ddc2 | 2013-04-28 09:20:03 +0000 | [diff] [blame] | 271 | } |
Igor Opaniuk | 8c1df09 | 2019-06-04 00:05:59 +0300 | [diff] [blame] | 272 | #else /* ifndef CONFIG_DM_VIDEO */ |
| 273 | |
| 274 | static int mxs_video_probe(struct udevice *dev) |
| 275 | { |
| 276 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
| 277 | struct video_priv *uc_priv = dev_get_uclass_priv(dev); |
| 278 | |
| 279 | struct ctfb_res_modes mode; |
| 280 | struct display_timing timings; |
| 281 | int bpp = -1; |
| 282 | u32 fb_start, fb_end; |
| 283 | int ret; |
| 284 | |
| 285 | debug("%s() plat: base 0x%lx, size 0x%x\n", |
| 286 | __func__, plat->base, plat->size); |
| 287 | |
| 288 | ret = ofnode_decode_display_timing(dev_ofnode(dev), 0, &timings); |
| 289 | if (ret) { |
| 290 | dev_err(dev, "failed to get any display timings\n"); |
| 291 | return -EINVAL; |
| 292 | } |
| 293 | |
| 294 | mode.xres = timings.hactive.typ; |
| 295 | mode.yres = timings.vactive.typ; |
| 296 | mode.left_margin = timings.hback_porch.typ; |
| 297 | mode.right_margin = timings.hfront_porch.typ; |
| 298 | mode.upper_margin = timings.vback_porch.typ; |
| 299 | mode.lower_margin = timings.vfront_porch.typ; |
| 300 | mode.hsync_len = timings.hsync_len.typ; |
| 301 | mode.vsync_len = timings.vsync_len.typ; |
| 302 | mode.pixclock = HZ2PS(timings.pixelclock.typ); |
| 303 | |
| 304 | bpp = BITS_PP; |
| 305 | |
| 306 | ret = mxs_probe_common(&mode, bpp, plat->base); |
| 307 | if (ret) |
| 308 | return ret; |
| 309 | |
| 310 | switch (bpp) { |
| 311 | case 24: |
| 312 | case 18: |
| 313 | uc_priv->bpix = VIDEO_BPP32; |
| 314 | break; |
| 315 | case 16: |
| 316 | uc_priv->bpix = VIDEO_BPP16; |
| 317 | break; |
| 318 | case 8: |
| 319 | uc_priv->bpix = VIDEO_BPP8; |
| 320 | break; |
| 321 | default: |
| 322 | dev_err(dev, "invalid bpp specified (bpp = %i)\n", bpp); |
| 323 | return -EINVAL; |
| 324 | } |
| 325 | |
| 326 | uc_priv->xsize = mode.xres; |
| 327 | uc_priv->ysize = mode.yres; |
| 328 | |
| 329 | /* Enable dcache for the frame buffer */ |
| 330 | fb_start = plat->base & ~(MMU_SECTION_SIZE - 1); |
| 331 | fb_end = plat->base + plat->size; |
| 332 | fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT); |
| 333 | mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start, |
| 334 | DCACHE_WRITEBACK); |
| 335 | video_set_flush_dcache(dev, true); |
| 336 | |
| 337 | return ret; |
| 338 | } |
| 339 | |
| 340 | static int mxs_video_bind(struct udevice *dev) |
| 341 | { |
| 342 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
| 343 | struct display_timing timings; |
| 344 | int ret; |
| 345 | |
| 346 | ret = ofnode_decode_display_timing(dev_ofnode(dev), 0, &timings); |
| 347 | if (ret) { |
| 348 | dev_err(dev, "failed to get any display timings\n"); |
| 349 | return -EINVAL; |
| 350 | } |
| 351 | |
| 352 | plat->size = timings.hactive.typ * timings.vactive.typ * BYTES_PP; |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | static int mxs_video_remove(struct udevice *dev) |
| 358 | { |
| 359 | struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); |
| 360 | |
| 361 | mxs_remove_common(plat->base); |
| 362 | |
| 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | static const struct udevice_id mxs_video_ids[] = { |
| 367 | { .compatible = "fsl,imx23-lcdif" }, |
| 368 | { .compatible = "fsl,imx28-lcdif" }, |
| 369 | { .compatible = "fsl,imx7ulp-lcdif" }, |
| 370 | { /* sentinel */ } |
| 371 | }; |
| 372 | |
| 373 | U_BOOT_DRIVER(mxs_video) = { |
| 374 | .name = "mxs_video", |
| 375 | .id = UCLASS_VIDEO, |
| 376 | .of_match = mxs_video_ids, |
| 377 | .bind = mxs_video_bind, |
| 378 | .probe = mxs_video_probe, |
| 379 | .remove = mxs_video_remove, |
| 380 | .flags = DM_FLAG_PRE_RELOC, |
| 381 | }; |
| 382 | #endif /* ifndef CONFIG_DM_VIDEO */ |