2 * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
3 * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
4 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2006 Michael Buesch
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/tty.h>
31 #include <linux/serial.h>
32 #include <linux/serial_core.h>
33 #include <linux/serial_reg.h>
34 #include <linux/serial_8250.h>
35 #include <asm/bootinfo.h>
37 #include <asm/reboot.h>
40 #include <linux/ssb/ssb.h>
44 extern void bcm47xx_pci_init(void);
45 extern void bcm47xx_time_init(void);
49 static void bcm47xx_machine_restart(char *command
)
51 printk(KERN_ALERT
"Please stand by while rebooting the system...\n");
53 /* CFE has a reboot callback, but that does not work.
54 * Oopses with: Reserved instruction in kernel code.
57 /* Set the watchdog timer to reset immediately */
58 ssb_chipco_watchdog_timer_set(&ssb
.chipco
, 1);
63 static void bcm47xx_machine_halt(void)
65 /* Disable interrupts and watchdog and spin forever */
67 ssb_chipco_watchdog_timer_set(&ssb
.chipco
, 0);
72 static void e_aton(char *str
, char *dest
)
82 dest
[i
++] = (char) simple_strtoul(str
, NULL
, 16);
84 if (!*str
++ || i
== 6)
89 static void bcm47xx_fill_sprom(struct ssb_sprom
*sprom
)
94 static void bcm47xx_fill_sprom_nvram(struct ssb_sprom
*sprom
)
98 memset(sprom
, 0xFF, sizeof(struct ssb_sprom
));
101 if ((s
= nvram_get("il0macaddr")))
102 e_aton(s
, sprom
->r1
.il0mac
);
103 if ((s
= nvram_get("et0macaddr")))
104 e_aton(s
, sprom
->r1
.et0mac
);
105 if ((s
= nvram_get("et1macaddr")))
106 e_aton(s
, sprom
->r1
.et1mac
);
107 if ((s
= nvram_get("et0phyaddr")))
108 sprom
->r1
.et0phyaddr
= simple_strtoul(s
, NULL
, 0);
109 if ((s
= nvram_get("et1phyaddr")))
110 sprom
->r1
.et1phyaddr
= simple_strtoul(s
, NULL
, 0);
111 if ((s
= nvram_get("et0mdcport")))
112 sprom
->r1
.et0mdcport
= !!simple_strtoul(s
, NULL
, 10);
113 if ((s
= nvram_get("et1mdcport")))
114 sprom
->r1
.et1mdcport
= !!simple_strtoul(s
, NULL
, 10);
115 if ((s
= nvram_get("pa0b0")))
116 sprom
->r1
.pa0b0
= simple_strtoul(s
, NULL
, 0);
117 if ((s
= nvram_get("pa0b1")))
118 sprom
->r1
.pa0b1
= simple_strtoul(s
, NULL
, 0);
119 if ((s
= nvram_get("pa0b2")))
120 sprom
->r1
.pa0b2
= simple_strtoul(s
, NULL
, 0);
121 if ((s
= nvram_get("pa1b0")))
122 sprom
->r1
.pa1b0
= simple_strtoul(s
, NULL
, 0);
123 if ((s
= nvram_get("pa1b1")))
124 sprom
->r1
.pa1b1
= simple_strtoul(s
, NULL
, 0);
125 if ((s
= nvram_get("pa1b2")))
126 sprom
->r1
.pa1b2
= simple_strtoul(s
, NULL
, 0);
127 if ((s
= nvram_get("wl0gpio0")))
128 sprom
->r1
.gpio0
= simple_strtoul(s
, NULL
, 0);
129 if ((s
= nvram_get("wl0gpio1")))
130 sprom
->r1
.gpio1
= simple_strtoul(s
, NULL
, 0);
131 if ((s
= nvram_get("wl0gpio2")))
132 sprom
->r1
.gpio2
= simple_strtoul(s
, NULL
, 0);
133 if ((s
= nvram_get("wl0gpio3")))
134 sprom
->r1
.gpio3
= simple_strtoul(s
, NULL
, 0);
135 if ((s
= nvram_get("pa0maxpwr")))
136 sprom
->r1
.maxpwr_bg
= simple_strtoul(s
, NULL
, 0);
137 if ((s
= nvram_get("pa1maxpwr")))
138 sprom
->r1
.maxpwr_a
= simple_strtoul(s
, NULL
, 0);
139 if ((s
= nvram_get("pa0itssit")))
140 sprom
->r1
.itssi_bg
= simple_strtoul(s
, NULL
, 0);
141 if ((s
= nvram_get("pa1itssit")))
142 sprom
->r1
.itssi_a
= simple_strtoul(s
, NULL
, 0);
143 if ((s
= nvram_get("boardflags")))
144 sprom
->r1
.boardflags_lo
= simple_strtoul(s
, NULL
, 0);
147 static int bcm47xx_get_invariants(struct ssb_bus
*bus
, struct ssb_init_invariants
*iv
)
151 iv
->boardinfo
.vendor
= SSB_BOARDVENDOR_BCM
;
152 if ((s
= nvram_get("boardtype")))
153 iv
->boardinfo
.type
= (u16
)simple_strtoul(s
, NULL
, 0);
154 if ((s
= nvram_get("boardrev")))
155 iv
->boardinfo
.rev
= (u16
)simple_strtoul(s
, NULL
, 0);
156 bcm47xx_fill_sprom(&iv
->sprom
);
160 void __init
plat_mem_setup(void)
164 struct ssb_mipscore
*mcore
;
166 err
= ssb_bus_ssbbus_register(&ssb
, SSB_ENUM_BASE
, bcm47xx_get_invariants
);
168 const char *msg
= "Failed to initialize SSB bus (err %d)\n";
169 cfe_printk(msg
, err
); /* Make sure the message gets out of the box. */
172 mcore
= &ssb
.mipscore
;
174 /* FIXME: the nvram init depends on the ssb being fully initializes,
175 * can't use the fill_sprom callback yet! */
176 bcm47xx_fill_sprom_nvram(&ssb
.sprom
);
178 s
= nvram_get("kernel_args");
179 if (s
&& !strncmp(s
, "console=ttyS1", 13)) {
180 struct ssb_serial_port port
;
182 cfe_printk("Swapping serial ports!\n");
183 /* swap serial ports */
184 memcpy(&port
, &mcore
->serial_ports
[0], sizeof(port
));
185 memcpy(&mcore
->serial_ports
[0], &mcore
->serial_ports
[1], sizeof(port
));
186 memcpy(&mcore
->serial_ports
[1], &port
, sizeof(port
));
189 for (i
= 0; i
< mcore
->nr_serial_ports
; i
++) {
190 struct ssb_serial_port
*port
= &(mcore
->serial_ports
[i
]);
193 memset(&s
, 0, sizeof(s
));
195 s
.membase
= port
->regs
;
196 s
.irq
= port
->irq
+ 2;//FIXME?
197 s
.uartclk
= port
->baud_base
;
198 s
.flags
= UPF_BOOT_AUTOCONF
| UPF_SHARE_IRQ
;
199 s
.iotype
= SERIAL_IO_MEM
;
200 s
.regshift
= port
->reg_shift
;
202 early_serial_setup(&s
);
204 cfe_printk("Serial init done.\n");
206 _machine_restart
= bcm47xx_machine_restart
;
207 _machine_halt
= bcm47xx_machine_halt
;
208 pm_power_off
= bcm47xx_machine_halt
;
209 board_time_init
= bcm47xx_time_init
;
This page took 0.065067 seconds and 5 git commands to generate.