fdt.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <libfdt.h>
  11. #include <fdt_support.h>
  12. #include "qe.h"
  13. DECLARE_GLOBAL_DATA_PTR;
  14. /*
  15. * If a QE firmware has been uploaded, then add the 'firmware' node under
  16. * the 'qe' node.
  17. */
  18. void fdt_fixup_qe_firmware(void *blob)
  19. {
  20. struct qe_firmware_info *qe_fw_info;
  21. int node, ret;
  22. qe_fw_info = qe_get_firmware_info();
  23. if (!qe_fw_info)
  24. return;
  25. node = fdt_path_offset(blob, "/qe");
  26. if (node < 0)
  27. return;
  28. /* We assume the node doesn't exist yet */
  29. node = fdt_add_subnode(blob, node, "firmware");
  30. if (node < 0)
  31. return;
  32. ret = fdt_setprop(blob, node, "extended-modes",
  33. &qe_fw_info->extended_modes, sizeof(u64));
  34. if (ret < 0)
  35. goto error;
  36. ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id);
  37. if (ret < 0)
  38. goto error;
  39. ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps,
  40. sizeof(qe_fw_info->vtraps));
  41. if (ret < 0)
  42. goto error;
  43. return;
  44. error:
  45. fdt_del_node(blob, node);
  46. }
  47. void ft_qe_setup(void *blob)
  48. {
  49. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  50. "bus-frequency", gd->arch.qe_clk, 1);
  51. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  52. "brg-frequency", gd->arch.brg_clk, 1);
  53. do_fixup_by_compat_u32(blob, "fsl,qe",
  54. "clock-frequency", gd->arch.qe_clk, 1);
  55. do_fixup_by_compat_u32(blob, "fsl,qe",
  56. "bus-frequency", gd->arch.qe_clk, 1);
  57. do_fixup_by_compat_u32(blob, "fsl,qe",
  58. "brg-frequency", gd->arch.brg_clk, 1);
  59. do_fixup_by_compat_u32(blob, "fsl,qe-gtm",
  60. "clock-frequency", gd->arch.qe_clk / 2, 1);
  61. fdt_fixup_qe_firmware(blob);
  62. }