2 * Copyright (c) 2013 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/u-boot-sandbox.h>
15 DECLARE_GLOBAL_DATA_PTR;
18 /* Default LCD size we support */
24 /* This platform data is needed in tests, so declare it here */
25 struct sandbox_sdl_plat {
32 static int sandbox_sdl_probe(struct udevice *dev)
34 struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
35 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
38 ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
40 puts("LCD init failed\n");
43 uc_priv->xsize = plat->xres;
44 uc_priv->ysize = plat->yres;
45 uc_priv->bpix = plat->bpix;
46 uc_priv->rot = plat->rot;
51 static int sandbox_sdl_bind(struct udevice *dev)
53 struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
54 struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
55 const void *blob = gd->fdt_blob;
56 int node = dev->of_offset;
59 plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
60 plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
61 plat->bpix = VIDEO_BPP16;
62 uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
63 debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
68 static const struct udevice_id sandbox_sdl_ids[] = {
69 { .compatible = "sandbox,lcd-sdl" },
73 U_BOOT_DRIVER(sdl_sandbox) = {
74 .name = "sdl_sandbox",
76 .of_match = sandbox_sdl_ids,
77 .bind = sandbox_sdl_bind,
78 .probe = sandbox_sdl_probe,
79 .platdata_auto_alloc_size = sizeof(struct sandbox_sdl_plat),