Loading drivers/of/fdt.c +63 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,69 @@ void of_fdt_limit_memory(int limit) } } /** * of_fdt_get_ddrhbb - Return the highest bank bit of ddr on the current device * * On match, returns a non-zero positive value which matches the highest bank * bit. * Otherwise returns -ENOENT. */ int of_fdt_get_ddrhbb(int channel, int rank) { int memory; int len; int ret; /* Single spaces reserved for channel(0-9), rank(0-9) */ char pname[] = "ddr_device_hbb_ch _rank "; fdt32_t *prop = NULL; memory = fdt_path_offset(initial_boot_params, "/memory"); if (memory > 0) { snprintf(pname, sizeof(pname), "ddr_device_hbb_ch%d_rank%d", channel, rank); prop = fdt_getprop_w(initial_boot_params, memory, pname, &len); } if (!prop || len != sizeof(u32)) return -ENOENT; ret = fdt32_to_cpu(*prop); return ret; } /** * of_fdt_get_ddrrank - Return the rank of ddr on the current device * * On match, returns a non-zero positive value which matches the ddr rank. * Otherwise returns -ENOENT. */ int of_fdt_get_ddrrank(int channel) { int memory; int len; int ret; /* Single space reserved for channel(0-9) */ char pname[] = "ddr_device_rank_ch "; fdt32_t *prop = NULL; memory = fdt_path_offset(initial_boot_params, "/memory"); if (memory > 0) { snprintf(pname, sizeof(pname), "ddr_device_rank_ch%d", channel); prop = fdt_getprop_w(initial_boot_params, memory, pname, &len); } if (!prop || len != sizeof(u32)) return -ENOENT; ret = fdt32_to_cpu(*prop); return ret; } /** * of_fdt_get_ddrtype - Return the type of ddr (4/5) on the current device * Loading include/linux/of_fdt.h +2 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ extern char __dtb_end[]; extern u64 of_flat_dt_translate_address(unsigned long node); extern void of_fdt_limit_memory(int limit); extern int of_fdt_get_ddrtype(void); extern int of_fdt_get_ddrrank(int channel); extern int of_fdt_get_ddrhbb(int channel, int rank); #endif /* CONFIG_OF_FLATTREE */ #ifdef CONFIG_OF_EARLY_FLATTREE Loading Loading
drivers/of/fdt.c +63 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,69 @@ void of_fdt_limit_memory(int limit) } } /** * of_fdt_get_ddrhbb - Return the highest bank bit of ddr on the current device * * On match, returns a non-zero positive value which matches the highest bank * bit. * Otherwise returns -ENOENT. */ int of_fdt_get_ddrhbb(int channel, int rank) { int memory; int len; int ret; /* Single spaces reserved for channel(0-9), rank(0-9) */ char pname[] = "ddr_device_hbb_ch _rank "; fdt32_t *prop = NULL; memory = fdt_path_offset(initial_boot_params, "/memory"); if (memory > 0) { snprintf(pname, sizeof(pname), "ddr_device_hbb_ch%d_rank%d", channel, rank); prop = fdt_getprop_w(initial_boot_params, memory, pname, &len); } if (!prop || len != sizeof(u32)) return -ENOENT; ret = fdt32_to_cpu(*prop); return ret; } /** * of_fdt_get_ddrrank - Return the rank of ddr on the current device * * On match, returns a non-zero positive value which matches the ddr rank. * Otherwise returns -ENOENT. */ int of_fdt_get_ddrrank(int channel) { int memory; int len; int ret; /* Single space reserved for channel(0-9) */ char pname[] = "ddr_device_rank_ch "; fdt32_t *prop = NULL; memory = fdt_path_offset(initial_boot_params, "/memory"); if (memory > 0) { snprintf(pname, sizeof(pname), "ddr_device_rank_ch%d", channel); prop = fdt_getprop_w(initial_boot_params, memory, pname, &len); } if (!prop || len != sizeof(u32)) return -ENOENT; ret = fdt32_to_cpu(*prop); return ret; } /** * of_fdt_get_ddrtype - Return the type of ddr (4/5) on the current device * Loading
include/linux/of_fdt.h +2 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ extern char __dtb_end[]; extern u64 of_flat_dt_translate_address(unsigned long node); extern void of_fdt_limit_memory(int limit); extern int of_fdt_get_ddrtype(void); extern int of_fdt_get_ddrrank(int channel); extern int of_fdt_get_ddrhbb(int channel, int rank); #endif /* CONFIG_OF_FLATTREE */ #ifdef CONFIG_OF_EARLY_FLATTREE Loading