import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / mips / galileo-boards / ev96100 / setup.c
1 /*
2  * BRIEF MODULE DESCRIPTION
3  *      Galileo EV96100 setup.
4  *
5  * Copyright 2000 MontaVista Software Inc.
6  * Author: MontaVista Software, Inc.
7  *              ppopov@mvista.com or source@mvista.com
8  *
9  * This file was derived from Carsten Langgaard's
10  * arch/mips/mips-boards/atlas/atlas_setup.c.
11  *
12  * Carsten Langgaard, carstenl@mips.com
13  * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
14  *
15  *  This program is free software; you can redistribute  it and/or modify it
16  *  under  the terms of  the GNU General  Public License as published by the
17  *  Free Software Foundation;  either version 2 of the  License, or (at your
18  *  option) any later version.
19  *
20  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
21  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
22  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
23  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
24  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
26  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
28  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  *  You should have received a copy of the  GNU General Public License along
32  *  with this program; if not, write  to the Free Software Foundation, Inc.,
33  *  675 Mass Ave, Cambridge, MA 02139, USA.
34  */
35 #include <linux/config.h>
36 #include <linux/init.h>
37 #include <linux/sched.h>
38 #include <linux/ioport.h>
39 #include <linux/mc146818rtc.h>
40 #include <linux/string.h>
41 #include <linux/ctype.h>
42 #include <linux/pci.h>
43
44 #include <asm/cpu.h>
45 #include <asm/bootinfo.h>
46 #include <asm/mipsregs.h>
47 #include <asm/irq.h>
48 #include <asm/delay.h>
49 #include <asm/gt64120/gt64120.h>
50 #include <asm/galileo-boards/ev96100int.h>
51
52
53 extern char * __init prom_getcmdline(void);
54
55 extern void mips_reboot_setup(void);
56 extern struct rtc_ops no_rtc_ops;
57 extern struct resource ioport_resource;
58
59 unsigned char mac_0_1[12];
60
61 void __init ev96100_setup(void)
62 {
63         unsigned int config = read_c0_config();
64         unsigned int status = read_c0_status();
65         unsigned int info = read_c0_info();
66         u32 tmp;
67
68         char *argptr;
69
70         clear_c0_status(ST0_FR);
71
72         if (config & 0x8) {
73             printk("Secondary cache is enabled\n");
74         }
75         else {
76             printk("Secondary cache is disabled\n");
77         }
78
79         if (status & (1<<27)) {
80             printk("User-mode cache ops enabled\n");
81         }
82         else {
83             printk("User-mode cache ops disabled\n");
84         }
85
86         printk("CP0 info reg: %x\n", (unsigned)info);
87         if (info & (1<<28)) {
88             printk("burst mode Scache RAMS\n");
89         }
90         else {
91             printk("pipelined Scache RAMS\n");
92         }
93
94         if ((info & (0x3<<26)) >> 26 == 0) {
95             printk("67 percent drive strength\n");
96         }
97         else if ((info & (0x3<<26)) >> 26 == 1) {
98             printk("50 percent drive strength\n");
99         }
100         else if ((info & (0x3<<26)) >> 26 == 2) {
101             printk("100 percent drive strength\n");
102         }
103         else if ((info & (0x3<<26)) >> 26 == 3) {
104             printk("83 percent drive strength\n");
105         }
106
107
108         if ((info & (0x3<<23)) >> 23 == 0) {
109             printk("Write Protocol: R4000 compatible\n");
110         }
111         else if ((info & (0x3<<23)) >> 23 == 1) {
112             printk("Write Protocol: Reserved\n");
113         }
114         else if ((info & (0x3<<23)) >> 23 == 2) {
115             printk("Write Protocol: Pipelined\n");
116         }
117         else if ((info & (0x3<<23)) >> 23 == 3) {
118             printk("Write Protocol: Write re-issue\n");
119         }
120
121         if (info & 0x1) {
122             printk("Atomic Enable is set\n");
123         }
124
125         argptr = prom_getcmdline();
126 #ifdef CONFIG_SERIAL_CONSOLE
127         if (strstr(argptr, "console=") == NULL) {
128                 argptr = prom_getcmdline();
129                 strcat(argptr, " console=ttyS0,115200");
130         }
131 #endif
132
133         rtc_ops = &no_rtc_ops;
134         mips_reboot_setup();
135         set_io_port_base(KSEG1);
136         ioport_resource.start = GT_PCI_IO_BASE;
137         ioport_resource.end   = GT_PCI_IO_BASE + 0x01ffffff;
138
139 #ifdef CONFIG_BLK_DEV_INITRD
140         ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
141 #endif
142
143
144         /*
145          * setup gt controller master bit so we can do config cycles
146          */
147
148         /* Clear cause register bits */
149         GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT |
150                                      GT_INTRCAUSE_TARABORT0_BIT));
151         /* Setup address */
152         GT_WRITE(GT_PCI0_CFGADDR_OFS,
153                  (0      << GT_PCI0_CFGADDR_BUSNUM_SHF)   |
154                  (0      << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
155                  ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF)   |
156                  GT_PCI0_CFGADDR_CONFIGEN_BIT);
157
158         udelay(2);
159         tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
160
161         tmp |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
162                 PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
163         GT_WRITE(GT_PCI0_CFGADDR_OFS,
164                  (0      << GT_PCI0_CFGADDR_BUSNUM_SHF)   |
165                  (0      << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
166                  ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF)   |
167                  GT_PCI0_CFGADDR_CONFIGEN_BIT);
168         udelay(2);
169         GT_WRITE(GT_PCI0_CFGDATA_OFS, tmp);
170
171         /* Setup address */
172         GT_WRITE(GT_PCI0_CFGADDR_OFS,
173                  (0      << GT_PCI0_CFGADDR_BUSNUM_SHF)   |
174                  (0      << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
175                  ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF)   |
176                  GT_PCI0_CFGADDR_CONFIGEN_BIT);
177
178         udelay(2);
179         tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
180 }
181
182 unsigned short get_gt_devid()
183 {
184         u32 gt_devid;
185
186         /* Figure out if this is a gt96100 or gt96100A */
187         GT_WRITE(GT_PCI0_CFGADDR_OFS,
188                  (0      << GT_PCI0_CFGADDR_BUSNUM_SHF)   |
189                  (0      << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
190                  ((PCI_VENDOR_ID / 4) << GT_PCI0_CFGADDR_REGNUM_SHF)   |
191                  GT_PCI0_CFGADDR_CONFIGEN_BIT);
192
193         udelay(4);
194         gt_devid = GT_READ(GT_PCI0_CFGDATA_OFS);
195
196         return gt_devid >> 16;
197 }