lcd_simplefb.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Simplefb device tree support
  3. *
  4. * (C) Copyright 2015
  5. * Stephen Warren <swarren@wwwdotorg.org>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <lcd.h>
  11. #include <fdt_support.h>
  12. #include <libfdt.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. static int lcd_dt_simplefb_configure_node(void *blob, int off)
  15. {
  16. #if LCD_BPP == LCD_COLOR16
  17. int vl_col = lcd_get_pixel_width();
  18. int vl_row = lcd_get_pixel_height();
  19. return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
  20. vl_col * 2, "r5g6b5");
  21. #else
  22. return -1;
  23. #endif
  24. }
  25. int lcd_dt_simplefb_add_node(void *blob)
  26. {
  27. static const char compat[] = "simple-framebuffer";
  28. static const char disabled[] = "disabled";
  29. int off, ret;
  30. off = fdt_add_subnode(blob, 0, "framebuffer");
  31. if (off < 0)
  32. return -1;
  33. ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
  34. if (ret < 0)
  35. return -1;
  36. ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
  37. if (ret < 0)
  38. return -1;
  39. return lcd_dt_simplefb_configure_node(blob, off);
  40. }
  41. int lcd_dt_simplefb_enable_existing_node(void *blob)
  42. {
  43. int off;
  44. off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
  45. if (off < 0)
  46. return -1;
  47. return lcd_dt_simplefb_configure_node(blob, off);
  48. }