bcm63xx: add flash type detection
[oweals/openwrt.git] / target / linux / brcm63xx / patches-3.3 / 511-board_V2500V.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -319,6 +319,63 @@ static struct board_info __initdata boar
4         },
5  };
6  
7 +       static struct board_info __initdata board_V2500V_BB = {
8 +        .name                           = "V2500V_BB",
9 +        .expected_cpu_id                = 0x6348,
10 +
11 +        .has_uart0                      = 1,
12 +        .has_enet0                      = 1,
13 +        .has_enet1                      = 1,
14 +        .has_pci                        = 1,
15 +
16 +        .enet0 = {
17 +                .has_phy                = 1,
18 +                .use_internal_phy       = 1,
19 +        },
20 +        .enet1 = {
21 +                .force_speed_100        = 1,
22 +                .force_duplex_full      = 1,
23 +        },
24 +
25 +       .leds = {
26 +               {
27 +                       .name           = "power:green",
28 +                       .gpio           = 0,
29 +                       .active_low     = 1,
30 +                       .default_trigger = "default-on",
31 +               },
32 +               {
33 +                       .name           = "power:red",
34 +                       .gpio           = 1,
35 +                       .active_low     = 1,
36 +               },
37 +               {
38 +                       .name           = "adsl",
39 +                       .gpio           = 2,
40 +                       .active_low     = 1,
41 +               },
42 +               {       .name           = "ppp",
43 +                       .gpio           = 3,
44 +                       .active_low     = 1,
45 +               },
46 +               {
47 +                       .name           = "wireless",
48 +                       .gpio           = 6,
49 +                       .active_low     = 1,
50 +               },
51 +       },
52 +       .buttons = {
53 +               {
54 +                       .desc           = "reset",
55 +                       .gpio           = 31,
56 +                       .active_low     = 1,
57 +                       .type           = EV_KEY,
58 +                       .code           = KEY_RESTART,
59 +                       .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
60 +               },
61 +       },
62 +};
63 +
64  #endif
65  
66  /*
67 @@ -1785,6 +1842,7 @@ static const struct board_info __initdat
68         &board_96348_D4PW,
69         &board_spw500v,
70         &board_96348sv,
71 +       &board_V2500V_BB,
72  #endif
73  
74  #ifdef CONFIG_BCM63XX_CPU_6358
75 @@ -1938,6 +1996,22 @@ void __init board_prom_init(void)
76         val = bcm_mpi_readl(MPI_CSBASE_REG(0));
77         val &= MPI_CSBASE_BASE_MASK;
78         boot_addr = (u8 *)KSEG1ADDR(val);
79 +       printk(KERN_INFO PFX "Boot address 0x%08x\n",(unsigned int)boot_addr);
80 +
81 +       /* BT Voyager 2500V (RTA1046VW PCB) has 8 Meg flash used as two */
82 +       /* banks of 4 Meg. The byte at 0xBF800000 identifies the back to use.*/
83 +       /* Loading firmware from the CFE Prompt always loads to Bank 0 */
84 +       /* Do an early check of CFE and then select bank 0 */
85 +
86 +               if (boot_addr == (u8 *)0xbf800000) {
87 +               u8 *tmp_boot_addr;
88 +               tmp_boot_addr = (u8 *)0xbfc00000; // Address of Bank 0
89 +               memcpy(&nvram, tmp_boot_addr + BCM963XX_NVRAM_OFFSET, sizeof(nvram));
90 +               if (!strcmp(nvram.name, "V2500V_BB")) {
91 +                       printk(KERN_INFO PFX "V2500V: nvram bank 0\n");
92 +                       boot_addr = (u8 *)0xbfc00000; // Bank 0
93 +               }
94 +       }
95  
96         /* dump cfe version */
97         cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
98 --- a/arch/mips/bcm63xx/dev-flash.c
99 +++ b/arch/mips/bcm63xx/dev-flash.c
100 @@ -16,6 +16,7 @@
101  #include <linux/mtd/partitions.h>
102  #include <linux/mtd/physmap.h>
103  
104 +#include <bcm63xx_board.h>
105  #include <bcm63xx_cpu.h>
106  #include <bcm63xx_dev_flash.h>
107  #include <bcm63xx_regs.h>
108 @@ -98,6 +99,13 @@ int __init bcm63xx_flash_register(void)
109                 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
110                 val &= MPI_CSBASE_BASE_MASK;
111  
112 +               /* BT Voyager 2500V has 8 Meg flash in two 4 Meg banks */
113 +               /* Loading from CFE always uses Bank 0 */
114 +               if (!strcmp(board_get_name(), "V2500V_BB")) {
115 +                       pr_info("V2500V: Start in Bank 0\n");
116 +                       val = val + 0x400000; // Select Bank 0 start address
117 +               }
118 +
119                 mtd_resources[0].start = val;
120                 mtd_resources[0].end = 0x1FFFFFFF;
121