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