From bfc0455bbf3f74daf583471c6c3ff8beb99681cf Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Lanka Date: Wed, 6 Oct 2021 11:44:18 -0700 Subject: [PATCH] of: Add snapshot of of_common.h file Add snapshot of of_common.h file from msm-5.10 commit 1ffab74be981 ("Merge "msm: kgsl: Verify secure access before importing buffers"") file for client drivers using of_fdt_get_ddrtype API. Change-Id: I80b88cb13eab0ab6ad32c98e077e48fe997fe299 Signed-off-by: Vamsi Krishna Lanka --- include/soc/qcom/of_common.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/soc/qcom/of_common.h diff --git a/include/soc/qcom/of_common.h b/include/soc/qcom/of_common.h new file mode 100644 index 000000000000..6b1284350852 --- /dev/null +++ b/include/soc/qcom/of_common.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2021, The Linux Foundation. All rights reserved. + */ + +#ifndef __QCOM_OF_H +#define __QCOM_OF_H + +#include + +/** + * of_fdt_get_ddrtype - Return the type of ddr (4/5) on the current device + * + * On match, returns a non-zero positive value which matches the ddr type. + * Otherwise returns -ENOENT. + */ +static inline int of_fdt_get_ddrtype(void) +{ + int ret; + u32 ddr_type; + struct device_node *mem_node; + + mem_node = of_find_node_by_path("/memory"); + if (!mem_node) + return -ENOENT; + + ret = of_property_read_u32(mem_node, "ddr_device_type", &ddr_type); + of_node_put(mem_node); + if (ret < 0) + return -ENOENT; + + return ddr_type; +} + +#endif