mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 06:03:36 -04:00
Merge "of: Make of_get_ddrtype module friendly"
This commit is contained in:
commit
f611892041
2 changed files with 24 additions and 26 deletions
|
|
@ -1278,6 +1278,30 @@ static inline int of_get_available_child_count(const struct device_node *np)
|
|||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF) && !defined(MODULE)
|
||||
#define _OF_DECLARE(table, name, compat, fn, fn_type) \
|
||||
static const struct of_device_id __of_table_##name \
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#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 */
|
||||
|
|
@ -40,31 +39,6 @@ extern char __dtb_end[];
|
|||
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