mgcoge, mgsuvd: extract more common code
in ft_blob_update () for both boards was an unneccessary repetition of code, which this patch moves in a common function for this boards. Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
9e299192ca
commit
6250f0f629
@ -495,3 +495,29 @@ void i2c_init_board(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
||||||
|
int fdt_set_node_and_value (void *blob,
|
||||||
|
char *nodename,
|
||||||
|
char *regname,
|
||||||
|
void *var,
|
||||||
|
int size)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int nodeoffset = 0;
|
||||||
|
|
||||||
|
nodeoffset = fdt_path_offset (blob, nodename);
|
||||||
|
if (nodeoffset >= 0) {
|
||||||
|
ret = fdt_setprop (blob, nodeoffset, regname, var,
|
||||||
|
size);
|
||||||
|
if (ret < 0)
|
||||||
|
printf("ft_blob_update(): cannot set %s/%s "
|
||||||
|
"property err:%s\n", nodename, regname,
|
||||||
|
fdt_strerror (ret));
|
||||||
|
} else {
|
||||||
|
printf("ft_blob_update(): cannot find %s node "
|
||||||
|
"err:%s\n", nodename, fdt_strerror (nodeoffset));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -308,30 +308,25 @@ int hush_init_var (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
||||||
|
extern int fdt_set_node_and_value (void *blob,
|
||||||
|
char *nodename,
|
||||||
|
char *regname,
|
||||||
|
void *var,
|
||||||
|
int size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update "memory" property in the blob
|
* update "memory" property in the blob
|
||||||
*/
|
*/
|
||||||
void ft_blob_update (void *blob, bd_t *bd)
|
void ft_blob_update (void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
int ret, nodeoffset = 0;
|
|
||||||
ulong memory_data[2] = {0};
|
ulong memory_data[2] = {0};
|
||||||
ulong flash_data[8] = {0};
|
ulong flash_data[8] = {0};
|
||||||
|
|
||||||
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
||||||
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
||||||
|
fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
|
||||||
|
sizeof (memory_data));
|
||||||
|
|
||||||
nodeoffset = fdt_path_offset (blob, "/memory");
|
|
||||||
if (nodeoffset >= 0) {
|
|
||||||
ret = fdt_setprop (blob, nodeoffset, "reg", memory_data,
|
|
||||||
sizeof (memory_data));
|
|
||||||
if (ret < 0)
|
|
||||||
printf ("ft_blob_update(): cannot set /memory/reg "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf ("ft_blob_update(): cannot find /memory node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
/* update Flash addr, size */
|
/* update Flash addr, size */
|
||||||
flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
|
flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
|
||||||
flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
|
flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
|
||||||
@ -339,32 +334,11 @@ void ft_blob_update (void *blob, bd_t *bd)
|
|||||||
flash_data[5] = cpu_to_be32 (0);
|
flash_data[5] = cpu_to_be32 (0);
|
||||||
flash_data[6] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
|
flash_data[6] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
|
||||||
flash_data[7] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE_1);
|
flash_data[7] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE_1);
|
||||||
nodeoffset = fdt_path_offset (blob, "/localbus");
|
fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
|
||||||
if (nodeoffset >= 0) {
|
sizeof (flash_data));
|
||||||
ret = fdt_setprop (blob, nodeoffset, "ranges", flash_data,
|
/* MAC addr */
|
||||||
sizeof (flash_data));
|
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
|
||||||
if (ret < 0)
|
bd->bi_enetaddr, sizeof (u8) * 6);
|
||||||
printf ("ft_blob_update(): cannot set /localbus/ranges "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf ("ft_blob_update(): cannot find /localbus node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
/* MAC Adresse */
|
|
||||||
nodeoffset = fdt_path_offset (blob, "/soc/cpm/ethernet");
|
|
||||||
if (nodeoffset >= 0) {
|
|
||||||
ret = fdt_setprop (blob, nodeoffset, "mac-address", bd->bi_enetaddr,
|
|
||||||
sizeof (uchar) * 6);
|
|
||||||
if (ret < 0)
|
|
||||||
printf ("ft_blob_update(): cannot set /soc/cpm/ethernet/mac-address "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf ("ft_blob_update(): cannot find /soc/cpm/ethernet node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_board_setup (void *blob, bd_t *bd)
|
void ft_board_setup (void *blob, bd_t *bd)
|
||||||
|
@ -150,73 +150,39 @@ int hush_init_var (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
||||||
|
extern int fdt_set_node_and_value (void *blob,
|
||||||
|
char *nodename,
|
||||||
|
char *regname,
|
||||||
|
void *var,
|
||||||
|
int size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update "memory" property in the blob
|
* update "memory" property in the blob
|
||||||
*/
|
*/
|
||||||
void ft_blob_update (void *blob, bd_t *bd)
|
void ft_blob_update (void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
int ret, nodeoffset = 0;
|
|
||||||
ulong brg_data[1] = {0};
|
ulong brg_data[1] = {0};
|
||||||
ulong memory_data[2] = {0};
|
ulong memory_data[2] = {0};
|
||||||
ulong flash_data[4] = {0};
|
ulong flash_data[4] = {0};
|
||||||
|
|
||||||
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
||||||
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
||||||
|
fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
|
||||||
nodeoffset = fdt_path_offset (blob, "/memory");
|
sizeof (memory_data));
|
||||||
if (nodeoffset >= 0) {
|
|
||||||
ret = fdt_setprop (blob, nodeoffset, "reg", memory_data,
|
|
||||||
sizeof (memory_data));
|
|
||||||
if (ret < 0)
|
|
||||||
printf("ft_blob_update(): cannot set /memory/reg "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf("ft_blob_update(): cannot find /memory node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
|
|
||||||
flash_data[2] = cpu_to_be32 (bd->bi_flashstart);
|
flash_data[2] = cpu_to_be32 (bd->bi_flashstart);
|
||||||
flash_data[3] = cpu_to_be32 (bd->bi_flashsize);
|
flash_data[3] = cpu_to_be32 (bd->bi_flashsize);
|
||||||
nodeoffset = fdt_path_offset (blob, "/localbus");
|
fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
|
||||||
if (nodeoffset >= 0) {
|
sizeof (flash_data));
|
||||||
ret = fdt_setprop (blob, nodeoffset, "ranges", flash_data,
|
|
||||||
sizeof (flash_data));
|
|
||||||
if (ret < 0)
|
|
||||||
printf("ft_blob_update(): cannot set /localbus/ranges "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf("ft_blob_update(): cannot find /localbus node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
/* BRG */
|
/* BRG */
|
||||||
brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
|
brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
|
||||||
nodeoffset = fdt_path_offset (blob, "/soc/cpm");
|
fdt_set_node_and_value (blob, "/soc/cpm", "brg-frequency", brg_data,
|
||||||
if (nodeoffset >= 0) {
|
sizeof (brg_data));
|
||||||
ret = fdt_setprop (blob, nodeoffset, "brg-frequency", brg_data,
|
|
||||||
sizeof (brg_data));
|
/* MAC adr */
|
||||||
if (ret < 0)
|
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
|
||||||
printf("ft_blob_update(): cannot set /soc/cpm/brg-frequency "
|
bd->bi_enetaddr, sizeof (u8) * 6);
|
||||||
"property err:%s\n", fdt_strerror(ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf("ft_blob_update(): cannot find /soc/cpm node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
/* MAC Adresse */
|
|
||||||
nodeoffset = fdt_path_offset (blob, "/soc/cpm/ethernet");
|
|
||||||
if (nodeoffset >= 0) {
|
|
||||||
ret = fdt_setprop (blob, nodeoffset, "mac-address", bd->bi_enetaddr,
|
|
||||||
sizeof (uchar) * 6);
|
|
||||||
if (ret < 0)
|
|
||||||
printf("ft_blob_update(): cannot set /soc/cpm/scc/mac-address "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf("ft_blob_update(): cannot find /soc/cpm/ethernet node "
|
|
||||||
"err:%s\n", fdt_strerror (nodeoffset));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_board_setup(void *blob, bd_t *bd)
|
void ft_board_setup(void *blob, bd_t *bd)
|
||||||
|
Loading…
Reference in New Issue
Block a user