mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 22:23:14 -04:00
drivers: of: Add API to find ddr device type
Add API to find the ddr device type from memory node. Change-Id: I1cfc38d46f1ea0abc6fbe8cbb6e37cde72b9fc2e Signed-off-by: Channagoud Kadabi <ckadabi@codeaurora.org> [eberman@codeaurora.org: Move func to header] Signed-off-by: Elliot Berman <eberman@codeaurora.org>
This commit is contained in:
parent
df2f76f8e8
commit
651f44674f
1 changed files with 27 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/types.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/libfdt.h>
|
||||
|
||||
/* Definitions used by the flattened device tree */
|
||||
#define OF_DT_HEADER 0xd00dfeed /* marker */
|
||||
|
|
@ -38,6 +39,32 @@ extern char __dtb_end[];
|
|||
/* Other Prototypes */
|
||||
extern u64 of_flat_dt_translate_address(unsigned long node);
|
||||
extern void of_fdt_limit_memory(int limit);
|
||||
|
||||
/**
|
||||
* 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 memory;
|
||||
int len;
|
||||
int ret;
|
||||
fdt32_t *prop = NULL;
|
||||
|
||||
memory = fdt_path_offset(initial_boot_params, "/memory");
|
||||
if (memory > 0)
|
||||
prop = fdt_getprop_w(initial_boot_params, memory,
|
||||
"ddr_device_type", &len);
|
||||
|
||||
if (!prop || len != sizeof(u32))
|
||||
return -ENOENT;
|
||||
|
||||
ret = fdt32_to_cpu(*prop);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_OF_FLATTREE */
|
||||
|
||||
#ifdef CONFIG_OF_EARLY_FLATTREE
|
||||
|
|
|
|||
Loading…
Reference in a new issue