brcm63xx: CPVA502+ board fixes
[openwrt.git] / target / linux / brcm63xx / patches-3.14 / 304-boardid_fixup.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -23,6 +23,7 @@
4  #include "board_common.h"
5  
6  #include <uapi/linux/bcm933xx_hcs.h>
7 +#include <uapi/linux/bcm963xx_tag.h>
8  
9  #define PFX    "board_bcm963xx: "
10  
11 @@ -339,6 +340,9 @@ static struct board_info __initdata boar
12                 .force_duplex_full      = 1,
13         },
14  
15 +#define CFE_OFFSET_64K                 0x10000
16 +#define CFE_OFFSET_128K                        0x20000
17 +
18  
19         .has_ohci0 = 1,
20         .has_pccard = 1,
21 @@ -722,6 +726,30 @@ static const struct board_info __initcon
22  #endif
23  };
24  
25 +static void __init boardid_fixup(u8 *boot_addr)
26 +{
27 +       struct bcm_tag *tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_64K);
28 +       char *board_name = (char *)bcm63xx_nvram_get_name();
29 +
30 +       /* check if bcm_tag is at 64k offset */
31 +       if (strncmp(board_name, tag->board_id, BOARDID_LEN) != 0) {
32 +               /* else try 128k */
33 +               tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_128K);
34 +               if (strncmp(board_name, tag->board_id, BOARDID_LEN) != 0) {
35 +                       /* No tag found */
36 +                       printk(KERN_DEBUG "No bcm_tag found!\n");
37 +                       return;
38 +               }
39 +       }
40 +       /* check if we should override the boardid */
41 +       if (tag->information1[0] != '+')
42 +               return;
43 +
44 +       strncpy(board_name, &tag->information1[1], BOARDID_LEN);
45 +
46 +       printk(KERN_INFO "Overriding boardid with '%s'\n", board_name);
47 +}
48 +
49  /*
50   * early init callback, read nvram data from flash and checksum it
51   */
52 @@ -760,6 +788,10 @@ void __init board_prom_init(void)
53                 hcs = (struct bcm_hcs *)boot_addr;
54                 board_name = hcs->filename;
55         } else {
56 +               if (strcmp(cfe_version, "unknown") != 0) {
57 +                       /* cfe present */
58 +                       boardid_fixup(boot_addr);
59 +               }
60                 board_name = bcm63xx_nvram_get_name();
61         }
62         /* find board by name */