summaryrefslogtreecommitdiff
path: root/board/keymile
diff options
context:
space:
mode:
Diffstat (limited to 'board/keymile')
-rw-r--r--board/keymile/common/common.c35
-rw-r--r--board/keymile/common/common.h10
-rw-r--r--board/keymile/km8xx/km8xx.c42
-rw-r--r--board/keymile/kmeter1/kmeter1.c51
-rw-r--r--board/keymile/mgcoge/mgcoge.c67
5 files changed, 169 insertions, 36 deletions
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index b2bd7fd..2594623 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -203,8 +203,9 @@ static int ivm_check_crc (unsigned char *buf, int block)
crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + \
buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256);
if (crc != crceeprom) {
- printf ("Error CRC Block: %d EEprom: calculated: %lx EEprom: %lx\n",
- block, crc, crceeprom);
+ if (block == 0)
+ printf ("Error CRC Block: %d EEprom: calculated: \
+ %lx EEprom: %lx\n", block, crc, crceeprom);
return -1;
}
return 0;
@@ -287,7 +288,7 @@ int ivm_analyze_eeprom (unsigned char *buf, int len)
GET_STRING("IVM_CustomerProductID", IVM_POS_CUSTOMER_PROD_ID, 32)
if (ivm_check_crc (&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0)
- return -2;
+ return 0;
ivm_analyze_block2 (&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], CONFIG_SYS_IVM_EEPROM_PAGE_LEN);
return 0;
@@ -527,6 +528,34 @@ int fdt_set_node_and_value (void *blob,
}
return ret;
}
+int fdt_get_node_and_value (void *blob,
+ char *nodename,
+ char *propname,
+ void **var)
+{
+ int len;
+ int nodeoffset = 0;
+
+ nodeoffset = fdt_path_offset (blob, nodename);
+ if (nodeoffset >= 0) {
+ *var = (void *)fdt_getprop (blob, nodeoffset, propname, &len);
+ if (len == 0) {
+ /* no value */
+ printf ("%s no value\n", __FUNCTION__);
+ return -1;
+ } else if (len > 0) {
+ return len;
+ } else {
+ printf ("libfdt fdt_getprop(): %s\n",
+ fdt_strerror(len));
+ return -2;
+ }
+ } else {
+ printf("%s: cannot find %s node err:%s\n", __FUNCTION__,
+ nodename, fdt_strerror (nodeoffset));
+ return -3;
+ }
+}
#endif
int ethernet_present (void)
diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h
index d3d6814..a38c727 100644
--- a/board/keymile/common/common.h
+++ b/board/keymile/common/common.h
@@ -17,4 +17,14 @@ int ivm_read_eeprom (void);
#ifdef CONFIG_KEYMILE_HDLC_ENET
int keymile_hdlc_enet_initialize (bd_t *bis);
#endif
+
+int fdt_set_node_and_value (void *blob,
+ char *nodename,
+ char *regname,
+ void *var,
+ int size);
+int fdt_get_node_and_value (void *blob,
+ char *nodename,
+ char *propname,
+ void **var);
#endif /* __KEYMILE_COMMON_H */
diff --git a/board/keymile/km8xx/km8xx.c b/board/keymile/km8xx/km8xx.c
index 7c58179..ec883a4 100644
--- a/board/keymile/km8xx/km8xx.c
+++ b/board/keymile/km8xx/km8xx.c
@@ -159,12 +159,6 @@ int hush_init_var (void)
}
#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
*/
@@ -172,33 +166,53 @@ void ft_blob_update (void *blob, bd_t *bd)
{
ulong brg_data[1] = {0};
ulong memory_data[2] = {0};
- ulong flash_data[4] = {0};
+ ulong *flash_data = NULL;
ulong flash_reg[3] = {0};
- uchar enetaddr[6];
+ flash_info_t *info;
+ int len;
+ int i = 0;
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
sizeof (memory_data));
- flash_data[2] = cpu_to_be32 (bd->bi_flashstart);
- flash_data[3] = cpu_to_be32 (bd->bi_flashsize);
+ len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+ (void *)&flash_data);
+
+ if (flash_data == NULL) {
+ printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+ return;
+ }
+
+ /* update Flash addr, size */
+ while ( i < (len / 4)) {
+ switch (flash_data[i]) {
+ case 0:
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+ flash_data[i + 1] = 0;
+ flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+ flash_data[i + 3] = cpu_to_be32 (info->size);
+ break;
+ default:
+ break;
+ }
+ i += 4;
+ }
fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
- sizeof (flash_data));
+ len);
flash_reg[2] = cpu_to_be32 (bd->bi_flashsize);
fdt_set_node_and_value (blob, "/localbus/flash@0,0", "reg", flash_reg,
sizeof (flash_reg));
-
/* BRG */
brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
fdt_set_node_and_value (blob, "/soc/cpm", "brg-frequency", brg_data,
sizeof (brg_data));
/* MAC adr */
- eth_getenv_enetaddr("ethaddr", enetaddr);
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
- enetaddr, sizeof (u8) * 6);
+ bd->bi_enetaddr, sizeof (u8) * 6);
}
void ft_board_setup(void *blob, bd_t *bd)
diff --git a/board/keymile/kmeter1/kmeter1.c b/board/keymile/kmeter1/kmeter1.c
index 3d1b941..8cac2c4 100644
--- a/board/keymile/kmeter1/kmeter1.c
+++ b/board/keymile/kmeter1/kmeter1.c
@@ -187,9 +187,60 @@ int checkboard (void)
}
#if defined(CONFIG_OF_BOARD_SETUP)
+/*
+ * update "/localbus/ranges" property in the blob
+ */
+void ft_blob_update (void *blob, bd_t *bd)
+{
+ ulong *flash_data = NULL;
+ flash_info_t *info;
+ ulong flash_reg[6] = {0};
+ int len;
+ int size = 0;
+ int i = 0;
+
+ len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+ (void *)&flash_data);
+
+ if (flash_data == NULL) {
+ printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+ return;
+ }
+
+ /* update Flash addr, size */
+ while ( i < (len / 4)) {
+ switch (flash_data[i]) {
+ case 0:
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+ size = info->size;
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+ size += info->size;
+ flash_data[i + 1] = 0;
+ flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+ flash_data[i + 3] = cpu_to_be32 (size);
+ break;
+ default:
+ break;
+ }
+ i += 4;
+ }
+ fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
+ len);
+
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+ flash_reg[2] = cpu_to_be32 (size);
+ flash_reg[4] = flash_reg[2];
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+ flash_reg[5] = cpu_to_be32 (info->size);
+ fdt_set_node_and_value (blob, "/localbus/flash@f0000000,0", "reg", flash_reg,
+ sizeof (flash_reg));
+}
+
+
void ft_board_setup (void *blob, bd_t *bd)
{
ft_cpu_setup (blob, bd);
+ ft_blob_update (blob, bd);
}
#endif
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index 67722e7..d24a4b5 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -312,42 +312,71 @@ int hush_init_var (void)
}
#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
*/
void ft_blob_update (void *blob, bd_t *bd)
{
ulong memory_data[2] = {0};
- ulong flash_data[8] = {0};
+ ulong *flash_data = NULL;
+ ulong flash_reg[6] = {0};
flash_info_t *info;
- uchar enetaddr[6];
+ int len;
+ int size;
+ int i = 0;
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
sizeof (memory_data));
+ len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+ (void *)&flash_data);
+
+ if (flash_data == NULL) {
+ printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+ return;
+ }
+
/* update Flash addr, size */
- info = flash_get_info(CONFIG_SYS_FLASH_BASE);
- flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
- flash_data[3] = cpu_to_be32 (info->size);
- flash_data[4] = cpu_to_be32 (5);
- flash_data[5] = cpu_to_be32 (0);
- info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
- flash_data[6] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
- flash_data[7] = cpu_to_be32 (info->size);
+ while ( i < (len / 4)) {
+ switch (flash_data[i]) {
+ case 0:
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+ flash_data[i + 1] = 0;
+ flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+ flash_data[i + 3] = cpu_to_be32 (info->size);
+ break;
+ case 5:
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+ size = info->size;
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_2);
+ size += info->size;
+ flash_data[i + 1] = 0;
+ flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
+ flash_data[i + 3] = cpu_to_be32 (size);
+ break;
+ default:
+ break;
+ }
+ i += 4;
+ }
fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
- sizeof (flash_data));
+ len);
+
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+ flash_reg[0] = cpu_to_be32 (5);
+ flash_reg[2] = cpu_to_be32 (info->size);
+ flash_reg[3] = flash_reg[0];
+ flash_reg[4] = flash_reg[2];
+ info = flash_get_info(CONFIG_SYS_FLASH_BASE_2);
+ flash_reg[5] = cpu_to_be32 (info->size);
+ fdt_set_node_and_value (blob, "/localbus/flash@5,0", "reg", flash_reg,
+ sizeof (flash_reg));
+
/* MAC addr */
- eth_getenv_enetaddr("ethaddr", enetaddr);
fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
- enetaddr, sizeof (u8) * 6);
+ bd->bi_enetaddr, sizeof (u8) * 6);
}
void ft_board_setup (void *blob, bd_t *bd)