summaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-3.7/304-boardid_fixup.patch
blob: 8163ce23a36ba642d5c2c21bfd0f99cae4e64b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -31,11 +31,16 @@
 #include <bcm63xx_dev_usb_usbd.h>
 #include <board_bcm963xx.h>
 
+#include <uapi/linux/bcm963xx_tag.h>
+
 #define PFX	"board_bcm963xx: "
 
 #define BCM963XX_KEYS_POLL_INTERVAL	20
 #define BCM963XX_KEYS_DEBOUNCE_INTERVAL	(BCM963XX_KEYS_POLL_INTERVAL * 3)
 
+#define CFE_OFFSET_64K			0x10000
+#define CFE_OFFSET_128K			0x20000
+
 static struct board_info board;
 
 /*
@@ -740,6 +745,30 @@ const char *board_get_name(void)
 	return board.name;
 }
 
+static void __init boardid_fixup(u8 *boot_addr)
+{
+	struct bcm_tag *tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_64K);
+	char *board_name = (char *)bcm63xx_nvram_get_name();
+
+	/* check if bcm_tag is at 64k offset */
+	if (strncmp(board_name, tag->board_id, BOARDID_LEN) != 0) {
+		/* else try 128k */
+		tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_128K);
+		if (strncmp(board_name, tag->board_id, BOARDID_LEN) != 0) {
+			/* No tag found */
+			printk(KERN_DEBUG "No bcm_tag found!\n");
+			return;
+		}
+	}
+	/* check if we should override the boardid */
+	if (tag->information1[0] != '+')
+		return;
+
+	strncpy(board_name, &tag->information1[1], BOARDID_LEN);
+
+	printk(KERN_INFO "Overriding boardid with '%s'\n", board_name);
+}
+
 /*
  * early init callback, read nvram data from flash and checksum it
  */
@@ -773,6 +802,11 @@ void __init board_prom_init(void)
 
 	bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
 
+	if (strcmp(cfe_version, "unknown") != 0) {
+		/* cfe present */
+		boardid_fixup(boot_addr);
+	}
+
 	board_name = bcm63xx_nvram_get_name();
 	/* find board by name */
 	for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {