fdt.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2008 Freescale Semiconductor, Inc.
  4. *
  5. * (C) Copyright 2000
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. */
  8. #include <common.h>
  9. #include <linux/libfdt.h>
  10. #include <fdt_support.h>
  11. #include <fsl_qe.h>
  12. #ifdef CONFIG_QE
  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. }
  63. #endif