fdt.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 <asm/global_data.h>
  10. #include <linux/libfdt.h>
  11. #include <fdt_support.h>
  12. #include <fsl_qe.h>
  13. #ifdef CONFIG_QE
  14. DECLARE_GLOBAL_DATA_PTR;
  15. /*
  16. * If a QE firmware has been uploaded, then add the 'firmware' node under
  17. * the 'qe' node.
  18. */
  19. void fdt_fixup_qe_firmware(void *blob)
  20. {
  21. struct qe_firmware_info *qe_fw_info;
  22. int node, ret;
  23. qe_fw_info = qe_get_firmware_info();
  24. if (!qe_fw_info)
  25. return;
  26. node = fdt_path_offset(blob, "/qe");
  27. if (node < 0)
  28. return;
  29. /* We assume the node doesn't exist yet */
  30. node = fdt_add_subnode(blob, node, "firmware");
  31. if (node < 0)
  32. return;
  33. ret = fdt_setprop(blob, node, "extended-modes",
  34. &qe_fw_info->extended_modes, sizeof(u64));
  35. if (ret < 0)
  36. goto error;
  37. ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id);
  38. if (ret < 0)
  39. goto error;
  40. ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps,
  41. sizeof(qe_fw_info->vtraps));
  42. if (ret < 0)
  43. goto error;
  44. return;
  45. error:
  46. fdt_del_node(blob, node);
  47. }
  48. void ft_qe_setup(void *blob)
  49. {
  50. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  51. "bus-frequency", gd->arch.qe_clk, 1);
  52. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  53. "brg-frequency", gd->arch.brg_clk, 1);
  54. do_fixup_by_compat_u32(blob, "fsl,qe",
  55. "clock-frequency", gd->arch.qe_clk, 1);
  56. do_fixup_by_compat_u32(blob, "fsl,qe",
  57. "bus-frequency", gd->arch.qe_clk, 1);
  58. do_fixup_by_compat_u32(blob, "fsl,qe",
  59. "brg-frequency", gd->arch.brg_clk, 1);
  60. do_fixup_by_compat_u32(blob, "fsl,qe-gtm",
  61. "clock-frequency", gd->arch.qe_clk / 2, 1);
  62. fdt_fixup_qe_firmware(blob);
  63. }
  64. #endif