lcd_simplefb.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. int vl_col = lcd_get_pixel_width();
  17. int vl_row = lcd_get_pixel_height();
  18. #if LCD_BPP == LCD_COLOR16
  19. return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
  20. vl_col * 2, "r5g6b5");
  21. #elif LCD_BPP == LCD_COLOR32
  22. return fdt_setup_simplefb_node(blob, off, gd->fb_base, vl_col, vl_row,
  23. vl_col * 4, "a8r8g8b8");
  24. #else
  25. return -1;
  26. #endif
  27. }
  28. int lcd_dt_simplefb_add_node(void *blob)
  29. {
  30. static const char compat[] = "simple-framebuffer";
  31. static const char disabled[] = "disabled";
  32. int off, ret;
  33. off = fdt_add_subnode(blob, 0, "framebuffer");
  34. if (off < 0)
  35. return -1;
  36. ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
  37. if (ret < 0)
  38. return -1;
  39. ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
  40. if (ret < 0)
  41. return -1;
  42. return lcd_dt_simplefb_configure_node(blob, off);
  43. }
  44. int lcd_dt_simplefb_enable_existing_node(void *blob)
  45. {
  46. int off;
  47. off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
  48. if (off < 0)
  49. return -1;
  50. return lcd_dt_simplefb_configure_node(blob, off);
  51. }