update brcm-2.4 to 2.4.35.4, integrate new broadcom system code, update broadcom...
[openwrt.git] / target / linux / brcm-2.4 / files / arch / mips / bcm947xx / setup.c
1 /*
2 * Generic setup routines for Broadcom MIPS boards
3 *
4 * Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 *
27 * Copyright 2005, Broadcom Corporation
28 * All Rights Reserved.
29 *
30 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
31 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
32 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
33 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
34 *
35 */
36
37 #include <linux/config.h>
38 #include <linux/init.h>
39 #include <linux/kernel.h>
40 #include <linux/module.h>
41 #include <linux/serialP.h>
42 #include <linux/ide.h>
43 #include <asm/bootinfo.h>
44 #include <asm/cpu.h>
45 #include <asm/time.h>
46 #include <asm/reboot.h>
47
48 #include <typedefs.h>
49 #include <osl.h>
50 #include <sbutils.h>
51 #include <bcmnvram.h>
52 #include <sbhndmips.h>
53 #include <hndmips.h>
54 #include <trxhdr.h>
55
56 /* Virtual IRQ base, after last hw IRQ */
57 #define SBMIPS_VIRTIRQ_BASE 6
58
59 /* # IRQs, hw and sw IRQs */
60 #define SBMIPS_NUMIRQS 8
61
62 /* Global SB handle */
63 sb_t *bcm947xx_sbh = NULL;
64 spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
65
66 /* Convenience */
67 #define sbh bcm947xx_sbh
68 #define sbh_lock bcm947xx_sbh_lock
69
70 extern void bcm947xx_time_init(void);
71 extern void bcm947xx_timer_setup(struct irqaction *irq);
72
73 #ifdef CONFIG_REMOTE_DEBUG
74 extern void set_debug_traps(void);
75 extern void rs_kgdb_hook(struct serial_state *);
76 extern void breakpoint(void);
77 #endif
78
79 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
80 extern struct ide_ops std_ide_ops;
81 #endif
82
83 /* Kernel command line */
84 char arcs_cmdline[CL_SIZE] __initdata = CONFIG_CMDLINE;
85 extern void sb_serial_init(sb_t *sbh, void (*add)(void *regs, uint irq, uint baud_base, uint reg_shift));
86
87 void
88 bcm947xx_machine_restart(char *command)
89 {
90 printk("Please stand by while rebooting the system...\n");
91
92 /* Set the watchdog timer to reset immediately */
93 __cli();
94 sb_watchdog(sbh, 1);
95 while (1);
96 }
97
98 void
99 bcm947xx_machine_halt(void)
100 {
101 printk("System halted\n");
102
103 /* Disable interrupts and watchdog and spin forever */
104 __cli();
105 sb_watchdog(sbh, 0);
106 while (1);
107 }
108
109 #ifdef CONFIG_SERIAL
110
111 static int ser_line = 0;
112
113 typedef struct {
114 void *regs;
115 uint irq;
116 uint baud_base;
117 uint reg_shift;
118 } serial_port;
119
120 static serial_port ports[4];
121 static int num_ports = 0;
122
123 static void
124 serial_add(void *regs, uint irq, uint baud_base, uint reg_shift)
125 {
126 ports[num_ports].regs = regs;
127 ports[num_ports].irq = irq;
128 ports[num_ports].baud_base = baud_base;
129 ports[num_ports].reg_shift = reg_shift;
130 num_ports++;
131 }
132
133 static void
134 do_serial_add(serial_port *port)
135 {
136 void *regs;
137 uint irq;
138 uint baud_base;
139 uint reg_shift;
140 struct serial_struct s;
141
142 regs = port->regs;
143 irq = port->irq;
144 baud_base = port->baud_base;
145 reg_shift = port->reg_shift;
146
147 memset(&s, 0, sizeof(s));
148
149 s.line = ser_line++;
150 s.iomem_base = regs;
151 s.irq = irq + 2;
152 s.baud_base = baud_base / 16;
153 s.flags = ASYNC_BOOT_AUTOCONF;
154 s.io_type = SERIAL_IO_MEM;
155 s.iomem_reg_shift = reg_shift;
156
157 if (early_serial_setup(&s) != 0) {
158 printk(KERN_ERR "Serial setup failed!\n");
159 }
160 }
161
162 #endif /* CONFIG_SERIAL */
163
164 void __init
165 brcm_setup(void)
166 {
167 char *s;
168 int i;
169 char *value;
170
171 /* Get global SB handle */
172 sbh = sb_kattach(SB_OSH);
173
174 /* Initialize clocks and interrupts */
175 sb_mips_init(sbh, SBMIPS_VIRTIRQ_BASE);
176
177 if (BCM330X(current_cpu_data.processor_id) &&
178 (read_c0_diag() & BRCM_PFC_AVAIL)) {
179 /*
180 * Now that the sbh is inited set the proper PFC value
181 */
182 printk("Setting the PFC to its default value\n");
183 enable_pfc(PFC_AUTO);
184 }
185
186
187 #ifdef CONFIG_SERIAL
188 sb_serial_init(sbh, serial_add);
189
190 /* reverse serial ports if nvram variable starts with console=ttyS1 */
191 /* Initialize UARTs */
192 s = nvram_get("kernel_args");
193 if (!s) s = "";
194 if (!strncmp(s, "console=ttyS1", 13)) {
195 for (i = num_ports; i; i--)
196 do_serial_add(&ports[i - 1]);
197 } else {
198 for (i = 0; i < num_ports; i++)
199 do_serial_add(&ports[i]);
200 }
201 #endif
202
203 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
204 ide_ops = &std_ide_ops;
205 #endif
206
207 /* Override default command line arguments */
208 value = nvram_get("kernel_cmdline");
209 if (value && strlen(value) && strncmp(value, "empty", 5))
210 strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));
211
212
213 /* Generic setup */
214 _machine_restart = bcm947xx_machine_restart;
215 _machine_halt = bcm947xx_machine_halt;
216 _machine_power_off = bcm947xx_machine_halt;
217
218 board_time_init = bcm947xx_time_init;
219 board_timer_setup = bcm947xx_timer_setup;
220 }
221
222 const char *
223 get_system_type(void)
224 {
225 static char s[32];
226
227 if (bcm947xx_sbh) {
228 sprintf(s, "Broadcom BCM%X chip rev %d", sb_chip(bcm947xx_sbh),
229 sb_chiprev(bcm947xx_sbh));
230 return s;
231 }
232 else
233 return "Broadcom BCM947XX";
234 }
235
236 void __init
237 bus_error_init(void)
238 {
239 }
240
This page took 0.049183 seconds and 5 git commands to generate.