fdt.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <libfdt.h>
  27. #include <fdt_support.h>
  28. #include "qe.h"
  29. DECLARE_GLOBAL_DATA_PTR;
  30. /*
  31. * If a QE firmware has been uploaded, then add the 'firmware' node under
  32. * the 'qe' node.
  33. */
  34. void fdt_fixup_qe_firmware(void *blob)
  35. {
  36. struct qe_firmware_info *qe_fw_info;
  37. int node, ret;
  38. qe_fw_info = qe_get_firmware_info();
  39. if (!qe_fw_info)
  40. return;
  41. node = fdt_path_offset(blob, "/qe");
  42. if (node < 0)
  43. return;
  44. /* We assume the node doesn't exist yet */
  45. node = fdt_add_subnode(blob, node, "firmware");
  46. if (node < 0)
  47. return;
  48. ret = fdt_setprop(blob, node, "extended-modes",
  49. &qe_fw_info->extended_modes, sizeof(u64));
  50. if (ret < 0)
  51. goto error;
  52. ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id);
  53. if (ret < 0)
  54. goto error;
  55. ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps,
  56. sizeof(qe_fw_info->vtraps));
  57. if (ret < 0)
  58. goto error;
  59. return;
  60. error:
  61. fdt_del_node(blob, node);
  62. }
  63. void ft_qe_setup(void *blob)
  64. {
  65. #ifdef CONFIG_QE
  66. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  67. "bus-frequency", gd->qe_clk, 1);
  68. do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  69. "brg-frequency", gd->brg_clk, 1);
  70. do_fixup_by_compat_u32(blob, "fsl,qe",
  71. "clock-frequency", gd->qe_clk, 1);
  72. do_fixup_by_compat_u32(blob, "fsl,qe",
  73. "bus-frequency", gd->qe_clk, 1);
  74. do_fixup_by_compat_u32(blob, "fsl,qe",
  75. "brg-frequency", gd->brg_clk, 1);
  76. fdt_fixup_qe_firmware(blob);
  77. #endif
  78. }