of_common.h 709 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __QCOM_OF_H
  6. #define __QCOM_OF_H
  7. #include <linux/of.h>
  8. /**
  9. * of_fdt_get_ddrtype - Return the type of ddr (4/5) on the current device
  10. *
  11. * On match, returns a non-zero positive value which matches the ddr type.
  12. * Otherwise returns -ENOENT.
  13. */
  14. static inline int of_fdt_get_ddrtype(void)
  15. {
  16. int ret;
  17. u32 ddr_type;
  18. struct device_node *mem_node;
  19. mem_node = of_find_node_by_path("/memory");
  20. if (!mem_node)
  21. return -ENOENT;
  22. ret = of_property_read_u32(mem_node, "ddr_device_type", &ddr_type);
  23. of_node_put(mem_node);
  24. if (ret < 0)
  25. return -ENOENT;
  26. return ddr_type;
  27. }
  28. #endif