2 * Toshiba rbtx4927 specific setup
4 * Author: MontaVista Software, Inc.
7 * Copyright 2001-2002 MontaVista Software Inc.
9 * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org)
10 * Copyright (C) 2000 RidgeRun, Inc.
11 * Author: RidgeRun, Inc.
12 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
14 * Copyright 2001 MontaVista Software Inc.
15 * Author: jsun@mvista.com or jsun@junsun.net
17 * Copyright 2002 MontaVista Software Inc.
18 * Author: Michael Pruznick, michael_pruznick@mvista.com
20 * Copyright (C) 2000-2001 Toshiba Corporation
22 * Copyright (C) 2004 MontaVista Software Inc.
23 * Author: Manish Lachwani, mlachwani@mvista.com
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2 of the License, or (at your
28 * option) any later version.
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
36 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
39 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 * You should have received a copy of the GNU General Public License along
42 * with this program; if not, write to the Free Software Foundation, Inc.,
43 * 675 Mass Ave, Cambridge, MA 02139, USA.
45 #include <linux/config.h>
46 #include <linux/init.h>
47 #include <linux/kernel.h>
48 #include <linux/types.h>
50 #include <linux/swap.h>
51 #include <linux/ioport.h>
52 #include <linux/sched.h>
53 #include <linux/interrupt.h>
54 #include <linux/pci.h>
55 #include <linux/timex.h>
58 #include <asm/bootinfo.h>
62 #include <asm/processor.h>
63 #include <asm/ptrace.h>
64 #include <asm/reboot.h>
66 #include <linux/bootmem.h>
67 #include <linux/blkdev.h>
68 #ifdef CONFIG_RTC_DS1742
69 #include <linux/ds1742rtc.h>
71 #ifdef CONFIG_TOSHIBA_FPCIB0
72 #include <asm/tx4927/smsc_fdc37m81x.h>
74 #include <asm/tx4927/toshiba_rbtx4927.h>
76 #include <asm/tx4927/tx4927_pci.h>
78 #ifdef CONFIG_BLK_DEV_IDEPCI
79 #include <linux/hdreg.h>
80 #include <linux/ide.h>
82 #ifdef CONFIG_SERIAL_TXX9
83 #include <linux/tty.h>
84 #include <linux/serial.h>
85 #include <linux/serial_core.h>
88 #undef TOSHIBA_RBTX4927_SETUP_DEBUG
90 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
91 #define TOSHIBA_RBTX4927_SETUP_NONE 0x00000000
93 #define TOSHIBA_RBTX4927_SETUP_INFO ( 1 << 0 )
94 #define TOSHIBA_RBTX4927_SETUP_WARN ( 1 << 1 )
95 #define TOSHIBA_RBTX4927_SETUP_EROR ( 1 << 2 )
97 #define TOSHIBA_RBTX4927_SETUP_EFWFU ( 1 << 3 )
98 #define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 )
99 #define TOSHIBA_RBTX4927_SETUP_TIME_INIT ( 1 << 5 )
100 #define TOSHIBA_RBTX4927_SETUP_TIMER_SETUP ( 1 << 6 )
101 #define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 )
102 #define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 )
103 #define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 )
104 #define TOSHIBA_RBTX4927_SETUP_PCI66 ( 1 << 10 )
106 #define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
109 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
110 static const u32 toshiba_rbtx4927_setup_debug_flag
=
111 (TOSHIBA_RBTX4927_SETUP_NONE
| TOSHIBA_RBTX4927_SETUP_INFO
|
112 TOSHIBA_RBTX4927_SETUP_WARN
| TOSHIBA_RBTX4927_SETUP_EROR
|
113 TOSHIBA_RBTX4927_SETUP_EFWFU
| TOSHIBA_RBTX4927_SETUP_SETUP
|
114 TOSHIBA_RBTX4927_SETUP_TIME_INIT
| TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
115 | TOSHIBA_RBTX4927_SETUP_PCIBIOS
| TOSHIBA_RBTX4927_SETUP_PCI1
|
116 TOSHIBA_RBTX4927_SETUP_PCI2
| TOSHIBA_RBTX4927_SETUP_PCI66
);
119 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
120 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...) \
121 if ( (toshiba_rbtx4927_setup_debug_flag) & (flag) ) \
124 sprintf( tmp, str ); \
125 printk( "%s(%s:%u)::%s", __FUNCTION__, __FILE__, __LINE__, tmp ); \
128 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...)
131 /* These functions are used for rebooting or halting the machine*/
132 extern void toshiba_rbtx4927_restart(char *command
);
133 extern void toshiba_rbtx4927_halt(void);
134 extern void toshiba_rbtx4927_power_off(void);
136 int tx4927_using_backplane
= 0;
138 extern void gt64120_time_init(void);
139 extern void toshiba_rbtx4927_irq_setup(void);
142 #define CONFIG_TX4927BUG_WORKAROUND
143 #undef TX4927_SUPPORT_COMMAND_IO
144 #undef TX4927_SUPPORT_PCI_66
145 int tx4927_cpu_clock
= 100000000; /* 100MHz */
146 unsigned long mips_pci_io_base
;
147 unsigned long mips_pci_io_size
;
148 unsigned long mips_pci_mem_base
;
149 unsigned long mips_pci_mem_size
;
150 /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
151 unsigned long mips_pci_io_pciaddr
= 0;
152 unsigned long mips_memory_upper
;
153 static int tx4927_ccfg_toeon
= 1;
154 static int tx4927_pcic_trdyto
= 0; /* default: disabled */
155 unsigned long tx4927_ce_base
[8];
156 void tx4927_pci_setup(void);
157 void tx4927_reset_pci_pcic(void);
158 int tx4927_pci66
= 0; /* 0:auto */
161 char *toshiba_name
= "";
164 static void tx4927_pcierr_interrupt(int irq
, void *dev_id
,
165 struct pt_regs
*regs
)
167 #ifdef CONFIG_BLK_DEV_IDEPCI
168 /* ignore MasterAbort for ide probing... */
169 if (irq
== TX4927_IRQ_IRC_PCIERR
&&
170 ((tx4927_pcicptr
->pcistatus
>> 16) & 0xf900) ==
171 PCI_STATUS_REC_MASTER_ABORT
) {
172 tx4927_pcicptr
->pcistatus
=
174 pcistatus
& 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT
180 printk("PCI error interrupt (irq 0x%x).\n", irq
);
182 printk("pcistat:%04x, g2pstatus:%08lx, pcicstatus:%08lx\n",
183 (unsigned short) (tx4927_pcicptr
->pcistatus
>> 16),
184 tx4927_pcicptr
->g2pstatus
, tx4927_pcicptr
->pcicstatus
);
185 printk("ccfg:%08lx, tear:%02lx_%08lx\n",
186 (unsigned long) tx4927_ccfgptr
->ccfg
,
187 (unsigned long) (tx4927_ccfgptr
->tear
>> 32),
188 (unsigned long) tx4927_ccfgptr
->tear
);
192 void __init
toshiba_rbtx4927_pci_irq_init(void)
197 void tx4927_reset_pci_pcic(void)
200 *tx4927_pcireset_ptr
= 1;
202 tx4927_ccfgptr
->clkctr
|= TX4927_CLKCTR_PCIRST
;
204 /* clear PCIC reset */
205 tx4927_ccfgptr
->clkctr
&= ~TX4927_CLKCTR_PCIRST
;
206 *tx4927_pcireset_ptr
= 0;
208 #endif /* CONFIG_PCI */
211 void print_pci_status(void)
213 printk("PCI STATUS %lx\n", tx4927_pcicptr
->pcistatus
);
214 printk("PCIC STATUS %lx\n", tx4927_pcicptr
->pcicstatus
);
217 extern struct pci_controller tx4927_controller
;
219 static struct pci_dev
*fake_pci_dev(struct pci_controller
*hose
,
220 int top_bus
, int busnr
, int devfn
)
222 static struct pci_dev dev
;
223 static struct pci_bus bus
;
225 dev
.sysdata
= (void *)hose
;
228 bus
.ops
= hose
->pci_ops
;
235 #define EARLY_PCI_OP(rw, size, type) \
236 static int early_##rw##_config_##size(struct pci_controller *hose, \
237 int top_bus, int bus, int devfn, int offset, type value) \
239 return pci_##rw##_config_##size( \
240 fake_pci_dev(hose, top_bus, bus, devfn), \
244 EARLY_PCI_OP(read
, byte
, u8
*)
245 EARLY_PCI_OP(read
, word
, u16
*)
246 EARLY_PCI_OP(read
, dword
, u32
*)
247 EARLY_PCI_OP(write
, byte
, u8
)
248 EARLY_PCI_OP(write
, word
, u16
)
249 EARLY_PCI_OP(write
, dword
, u32
)
251 static int __init
tx4927_pcibios_init(void)
256 int devfn_stop
= 0xff;
257 int busno
= 0; /* One bus on the Toshiba */
258 struct pci_controller
*hose
= &tx4927_controller
;
260 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
263 for (pci_devfn
= devfn_start
; pci_devfn
< devfn_stop
; pci_devfn
++) {
264 early_read_config_dword(hose
, busno
, busno
, pci_devfn
,
267 if (id
== 0xffffffff) {
271 if (id
== 0x94601055) {
275 char *s
= " sb/isa --";
277 TOSHIBA_RBTX4927_SETUP_DPRINTK
278 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s beg\n",
281 early_read_config_byte(hose
, busno
, busno
,
282 pci_devfn
, 0x64, &v08_64
);
283 early_read_config_dword(hose
, busno
, busno
,
284 pci_devfn
, 0xb0, &v32_b0
);
285 early_read_config_byte(hose
, busno
, busno
,
286 pci_devfn
, 0xe1, &v08_e1
);
288 TOSHIBA_RBTX4927_SETUP_DPRINTK
289 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
290 ":%s beg 0x64 = 0x%02x\n", s
, v08_64
);
291 TOSHIBA_RBTX4927_SETUP_DPRINTK
292 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
293 ":%s beg 0xb0 = 0x%02x\n", s
, v32_b0
);
294 TOSHIBA_RBTX4927_SETUP_DPRINTK
295 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
296 ":%s beg 0xe1 = 0x%02x\n", s
, v08_e1
);
298 /* serial irq control */
302 v32_b0
|= 0x00010000;
304 /* ide irq on isa14 */
308 TOSHIBA_RBTX4927_SETUP_DPRINTK
309 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
310 ":%s mid 0x64 = 0x%02x\n", s
, v08_64
);
311 TOSHIBA_RBTX4927_SETUP_DPRINTK
312 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
313 ":%s mid 0xb0 = 0x%02x\n", s
, v32_b0
);
314 TOSHIBA_RBTX4927_SETUP_DPRINTK
315 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
316 ":%s mid 0xe1 = 0x%02x\n", s
, v08_e1
);
318 early_write_config_byte(hose
, busno
, busno
,
319 pci_devfn
, 0x64, v08_64
);
320 early_write_config_dword(hose
, busno
, busno
,
321 pci_devfn
, 0xb0, v32_b0
);
322 early_write_config_byte(hose
, busno
, busno
,
323 pci_devfn
, 0xe1, v08_e1
);
325 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
327 early_read_config_byte(hose
, busno
, busno
,
330 early_read_config_dword(hose
, busno
, busno
,
333 early_read_config_byte(hose
, busno
, busno
,
337 TOSHIBA_RBTX4927_SETUP_DPRINTK
338 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
339 ":%s end 0x64 = 0x%02x\n", s
, v08_64
);
340 TOSHIBA_RBTX4927_SETUP_DPRINTK
341 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
342 ":%s end 0xb0 = 0x%02x\n", s
, v32_b0
);
343 TOSHIBA_RBTX4927_SETUP_DPRINTK
344 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
345 ":%s end 0xe1 = 0x%02x\n", s
, v08_e1
);
349 TOSHIBA_RBTX4927_SETUP_DPRINTK
350 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s end\n",
354 if (id
== 0x91301055) {
360 char *s
= " sb/ide --";
362 TOSHIBA_RBTX4927_SETUP_DPRINTK
363 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s beg\n",
366 early_read_config_byte(hose
, busno
, busno
,
367 pci_devfn
, 0x04, &v08_04
);
368 early_read_config_byte(hose
, busno
, busno
,
369 pci_devfn
, 0x09, &v08_09
);
370 early_read_config_byte(hose
, busno
, busno
,
371 pci_devfn
, 0x41, &v08_41
);
372 early_read_config_byte(hose
, busno
, busno
,
373 pci_devfn
, 0x43, &v08_43
);
374 early_read_config_byte(hose
, busno
, busno
,
375 pci_devfn
, 0x5c, &v08_5c
);
377 TOSHIBA_RBTX4927_SETUP_DPRINTK
378 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
379 ":%s beg 0x04 = 0x%02x\n", s
, v08_04
);
380 TOSHIBA_RBTX4927_SETUP_DPRINTK
381 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
382 ":%s beg 0x09 = 0x%02x\n", s
, v08_09
);
383 TOSHIBA_RBTX4927_SETUP_DPRINTK
384 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
385 ":%s beg 0x41 = 0x%02x\n", s
, v08_41
);
386 TOSHIBA_RBTX4927_SETUP_DPRINTK
387 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
388 ":%s beg 0x43 = 0x%02x\n", s
, v08_43
);
389 TOSHIBA_RBTX4927_SETUP_DPRINTK
390 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
391 ":%s beg 0x5c = 0x%02x\n", s
, v08_5c
);
393 /* enable ide master/io */
394 v08_04
|= (PCI_COMMAND_MASTER
| PCI_COMMAND_IO
);
396 /* enable ide native mode */
399 /* enable primary ide */
402 /* enable secondary ide */
406 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
408 * This line of code is intended to provide the user with a work
409 * around solution to the anomalies cited in SMSC's anomaly sheet
410 * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
412 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
416 TOSHIBA_RBTX4927_SETUP_DPRINTK
417 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
418 ":%s mid 0x04 = 0x%02x\n", s
, v08_04
);
419 TOSHIBA_RBTX4927_SETUP_DPRINTK
420 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
421 ":%s mid 0x09 = 0x%02x\n", s
, v08_09
);
422 TOSHIBA_RBTX4927_SETUP_DPRINTK
423 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
424 ":%s mid 0x41 = 0x%02x\n", s
, v08_41
);
425 TOSHIBA_RBTX4927_SETUP_DPRINTK
426 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
427 ":%s mid 0x43 = 0x%02x\n", s
, v08_43
);
428 TOSHIBA_RBTX4927_SETUP_DPRINTK
429 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
430 ":%s mid 0x5c = 0x%02x\n", s
, v08_5c
);
432 early_write_config_byte(hose
, busno
, busno
,
433 pci_devfn
, 0x5c, v08_5c
);
434 early_write_config_byte(hose
, busno
, busno
,
435 pci_devfn
, 0x04, v08_04
);
436 early_write_config_byte(hose
, busno
, busno
,
437 pci_devfn
, 0x09, v08_09
);
438 early_write_config_byte(hose
, busno
, busno
,
439 pci_devfn
, 0x41, v08_41
);
440 early_write_config_byte(hose
, busno
, busno
,
441 pci_devfn
, 0x43, v08_43
);
443 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
445 early_read_config_byte(hose
, busno
, busno
,
448 early_read_config_byte(hose
, busno
, busno
,
451 early_read_config_byte(hose
, busno
, busno
,
454 early_read_config_byte(hose
, busno
, busno
,
457 early_read_config_byte(hose
, busno
, busno
,
461 TOSHIBA_RBTX4927_SETUP_DPRINTK
462 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
463 ":%s end 0x04 = 0x%02x\n", s
, v08_04
);
464 TOSHIBA_RBTX4927_SETUP_DPRINTK
465 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
466 ":%s end 0x09 = 0x%02x\n", s
, v08_09
);
467 TOSHIBA_RBTX4927_SETUP_DPRINTK
468 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
469 ":%s end 0x41 = 0x%02x\n", s
, v08_41
);
470 TOSHIBA_RBTX4927_SETUP_DPRINTK
471 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
472 ":%s end 0x43 = 0x%02x\n", s
, v08_43
);
473 TOSHIBA_RBTX4927_SETUP_DPRINTK
474 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
475 ":%s end 0x5c = 0x%02x\n", s
, v08_5c
);
479 TOSHIBA_RBTX4927_SETUP_DPRINTK
480 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s end\n",
486 register_pci_controller(&tx4927_controller
);
487 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
493 arch_initcall(tx4927_pcibios_init
);
495 extern struct resource pci_io_resource
;
496 extern struct resource pci_mem_resource
;
498 void tx4927_pci_setup(void)
500 static int called
= 0;
501 extern unsigned int tx4927_get_mem_size(void);
503 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
, "-\n");
505 mips_memory_upper
= tx4927_get_mem_size() << 20;
506 mips_memory_upper
+= KSEG0
;
507 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
508 "0x%08lx=mips_memory_upper\n",
510 mips_pci_io_base
= TX4927_PCIIO
;
511 mips_pci_io_size
= TX4927_PCIIO_SIZE
;
512 mips_pci_mem_base
= TX4927_PCIMEM
;
513 mips_pci_mem_size
= TX4927_PCIMEM_SIZE
;
515 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
516 "0x%08lx=mips_pci_io_base\n",
518 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
519 "0x%08lx=mips_pci_io_size\n",
521 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
522 "0x%08lx=mips_pci_mem_base\n",
524 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
525 "0x%08lx=mips_pci_mem_size\n",
527 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
528 "0x%08lx=pci_io_resource.start\n",
529 pci_io_resource
.start
);
530 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
531 "0x%08lx=pci_io_resource.end\n",
532 pci_io_resource
.end
);
533 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
534 "0x%08lx=pci_mem_resource.start\n",
535 pci_mem_resource
.start
);
536 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
537 "0x%08lx=pci_mem_resource.end\n",
538 pci_mem_resource
.end
);
539 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
540 "0x%08lx=mips_io_port_base",
544 ("%s PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
546 (unsigned short) (tx4927_pcicptr
->pciid
>> 16),
547 (unsigned short) (tx4927_pcicptr
->pciid
& 0xffff),
548 (unsigned short) (tx4927_pcicptr
->pciccrev
& 0xff),
550 ccfg
& TX4927_CCFG_PCIXARB
)) ? "External" :
554 printk("%s PCIC --%s PCICLK:",toshiba_name
,
555 (tx4927_ccfgptr
->ccfg
& TX4927_CCFG_PCI66
) ? " PCI66" : "");
556 if (tx4927_ccfgptr
->pcfg
& TX4927_PCFG_PCICLKEN_ALL
) {
558 if (mips_machtype
== MACH_TOSHIBA_RBTX4937
)
559 switch ((unsigned long) tx4927_ccfgptr
->
560 ccfg
& TX4937_CCFG_PCIDIVMODE_MASK
) {
561 case TX4937_CCFG_PCIDIVMODE_4
:
562 pciclk
= tx4927_cpu_clock
/ 4;
564 case TX4937_CCFG_PCIDIVMODE_4_5
:
565 pciclk
= tx4927_cpu_clock
* 2 / 9;
567 case TX4937_CCFG_PCIDIVMODE_5
:
568 pciclk
= tx4927_cpu_clock
/ 5;
570 case TX4937_CCFG_PCIDIVMODE_5_5
:
571 pciclk
= tx4927_cpu_clock
* 2 / 11;
573 case TX4937_CCFG_PCIDIVMODE_8
:
574 pciclk
= tx4927_cpu_clock
/ 8;
576 case TX4937_CCFG_PCIDIVMODE_9
:
577 pciclk
= tx4927_cpu_clock
/ 9;
579 case TX4937_CCFG_PCIDIVMODE_10
:
580 pciclk
= tx4927_cpu_clock
/ 10;
582 case TX4937_CCFG_PCIDIVMODE_11
:
583 pciclk
= tx4927_cpu_clock
/ 11;
588 switch ((unsigned long) tx4927_ccfgptr
->
589 ccfg
& TX4927_CCFG_PCIDIVMODE_MASK
) {
590 case TX4927_CCFG_PCIDIVMODE_2_5
:
591 pciclk
= tx4927_cpu_clock
* 2 / 5;
593 case TX4927_CCFG_PCIDIVMODE_3
:
594 pciclk
= tx4927_cpu_clock
/ 3;
596 case TX4927_CCFG_PCIDIVMODE_5
:
597 pciclk
= tx4927_cpu_clock
/ 5;
599 case TX4927_CCFG_PCIDIVMODE_6
:
600 pciclk
= tx4927_cpu_clock
/ 6;
604 printk("Internal(%dMHz)", pciclk
/ 1000000);
607 int pciclk_setting
= *tx4927_pci_clk_ptr
;
608 switch (pciclk_setting
& TX4927_PCI_CLK_MASK
) {
609 case TX4927_PCI_CLK_33
:
612 case TX4927_PCI_CLK_25
:
615 case TX4927_PCI_CLK_66
:
618 case TX4927_PCI_CLK_50
:
622 printk("External(%dMHz)", pciclk
/ 1000000);
628 /* GB->PCI mappings */
629 tx4927_pcicptr
->g2piomask
= (mips_pci_io_size
- 1) >> 4;
630 tx4927_pcicptr
->g2piogbase
= mips_pci_io_base
|
632 TX4927_PCIC_G2PIOGBASE_ECHG
634 TX4927_PCIC_G2PIOGBASE_BSDIS
638 tx4927_pcicptr
->g2piopbase
= 0;
640 tx4927_pcicptr
->g2pmmask
[0] = (mips_pci_mem_size
- 1) >> 4;
641 tx4927_pcicptr
->g2pmgbase
[0] = mips_pci_mem_base
|
643 TX4927_PCIC_G2PMnGBASE_ECHG
645 TX4927_PCIC_G2PMnGBASE_BSDIS
648 tx4927_pcicptr
->g2pmpbase
[0] = mips_pci_mem_base
;
650 tx4927_pcicptr
->g2pmmask
[1] = 0;
651 tx4927_pcicptr
->g2pmgbase
[1] = 0;
652 tx4927_pcicptr
->g2pmpbase
[1] = 0;
653 tx4927_pcicptr
->g2pmmask
[2] = 0;
654 tx4927_pcicptr
->g2pmgbase
[2] = 0;
655 tx4927_pcicptr
->g2pmpbase
[2] = 0;
658 /* PCI->GB mappings (I/O 256B) */
659 tx4927_pcicptr
->p2giopbase
= 0; /* 256B */
661 /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
662 tx4927_pcicptr
->p2gm0plbase
= 0;
663 tx4927_pcicptr
->p2gm0pubase
= 0;
664 tx4927_pcicptr
->p2gmgbase
[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN
|
666 TX4927_PCIC_P2GMnGBASE_TECHG
668 TX4927_PCIC_P2GMnGBASE_TBSDIS
672 /* PCI->GB mappings (MEM 16MB) -not used */
673 tx4927_pcicptr
->p2gm1plbase
= 0xffffffff;
674 #ifdef CONFIG_TX4927BUG_WORKAROUND
676 * TX4927-PCIC-BUG: P2GM1PUBASE must be 0
677 * if P2GM0PUBASE was 0.
679 tx4927_pcicptr
->p2gm1pubase
= 0;
681 tx4927_pcicptr
->p2gm1pubase
= 0xffffffff;
683 tx4927_pcicptr
->p2gmgbase
[1] = 0;
685 /* PCI->GB mappings (MEM 1MB) -not used */
686 tx4927_pcicptr
->p2gm2pbase
= 0xffffffff;
687 tx4927_pcicptr
->p2gmgbase
[2] = 0;
690 /* Enable Initiator Memory 0 Space, I/O Space, Config */
691 tx4927_pcicptr
->pciccfg
&= TX4927_PCIC_PCICCFG_LBWC_MASK
;
692 tx4927_pcicptr
->pciccfg
|=
693 TX4927_PCIC_PCICCFG_IMSE0
| TX4927_PCIC_PCICCFG_IISE
|
694 TX4927_PCIC_PCICCFG_ICAE
| TX4927_PCIC_PCICCFG_ATR
;
697 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
698 tx4927_pcicptr
->pcicfg1
= 0;
700 if (tx4927_pcic_trdyto
>= 0) {
701 tx4927_pcicptr
->g2ptocnt
&= ~0xff;
702 tx4927_pcicptr
->g2ptocnt
|= (tx4927_pcic_trdyto
& 0xff);
705 /* Clear All Local Bus Status */
706 tx4927_pcicptr
->pcicstatus
= TX4927_PCIC_PCICSTATUS_ALL
;
707 /* Enable All Local Bus Interrupts */
708 tx4927_pcicptr
->pcicmask
= TX4927_PCIC_PCICSTATUS_ALL
;
709 /* Clear All Initiator Status */
710 tx4927_pcicptr
->g2pstatus
= TX4927_PCIC_G2PSTATUS_ALL
;
711 /* Enable All Initiator Interrupts */
712 tx4927_pcicptr
->g2pmask
= TX4927_PCIC_G2PSTATUS_ALL
;
713 /* Clear All PCI Status Error */
714 tx4927_pcicptr
->pcistatus
=
715 (tx4927_pcicptr
->pcistatus
& 0x0000ffff) |
716 (TX4927_PCIC_PCISTATUS_ALL
<< 16);
717 /* Enable All PCI Status Error Interrupts */
718 tx4927_pcicptr
->pcimask
= TX4927_PCIC_PCISTATUS_ALL
;
720 /* PCIC Int => IRC IRQ16 */
721 tx4927_pcicptr
->pcicfg2
=
722 (tx4927_pcicptr
->pcicfg2
& 0xffffff00) | TX4927_IR_PCIC
;
724 if (!(tx4927_ccfgptr
->ccfg
& TX4927_CCFG_PCIXARB
)) {
727 /* Reset Bus Arbiter */
728 tx4927_pcicptr
->pbacfg
= TX4927_PCIC_PBACFG_RPBA
;
729 /* Enable Bus Arbiter */
730 tx4927_pcicptr
->pbacfg
= TX4927_PCIC_PBACFG_PBAEN
;
733 tx4927_pcicptr
->pcistatus
= PCI_COMMAND_MASTER
|
735 PCI_COMMAND_PARITY
| PCI_COMMAND_SERR
;
737 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
738 ":pci setup complete:\n");
739 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
, "+\n");
742 #endif /* CONFIG_PCI */
744 void toshiba_rbtx4927_restart(char *command
)
746 printk(KERN_NOTICE
"System Rebooting...\n");
748 /* enable the s/w reset register */
749 reg_wr08(RBTX4927_SW_RESET_ENABLE
, RBTX4927_SW_RESET_ENABLE_SET
);
751 /* wait for enable to be seen */
752 while ((reg_rd08(RBTX4927_SW_RESET_ENABLE
) &
753 RBTX4927_SW_RESET_ENABLE_SET
) == 0x00);
756 reg_wr08(RBTX4927_SW_RESET_DO
, RBTX4927_SW_RESET_DO_SET
);
758 /* do something passive while waiting for reset */
767 void toshiba_rbtx4927_halt(void)
769 printk(KERN_NOTICE
"System Halted\n");
777 void toshiba_rbtx4927_power_off(void)
779 toshiba_rbtx4927_halt();
783 void __init
toshiba_rbtx4927_setup(void)
788 printk("CPU is %s\n", toshiba_name
);
790 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
793 /* f/w leaves this on at startup */
794 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
795 ":Clearing STO_ERL.\n");
796 clear_c0_status(ST0_ERL
);
798 /* enable caches -- HCP5 does this, pmon does not */
799 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
800 ":Enabling TX49_CONF_IC,TX49_CONF_DC.\n");
801 cp0_config
= read_c0_config();
802 cp0_config
= cp0_config
& ~(TX49_CONF_IC
| TX49_CONF_DC
);
803 write_c0_config(cp0_config
);
805 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
807 extern void dump_cp0(char *);
808 dump_cp0("toshiba_rbtx4927_early_fw_fixup");
812 /* setup irq stuff */
813 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
814 ":Setting up tx4927 pic.\n");
815 TX4927_WR(0xff1ff604, 0x00000400); /* irq trigger */
816 TX4927_WR(0xff1ff608, 0x00000000); /* irq trigger */
818 /* setup serial stuff */
819 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
820 ":Setting up tx4927 sio.\n");
821 TX4927_WR(0xff1ff314, 0x00000000); /* h/w flow control off */
822 TX4927_WR(0xff1ff414, 0x00000000); /* h/w flow control off */
824 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
827 set_io_port_base(KSEG1
+ TBTX4927_ISA_IO_OFFSET
);
828 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
829 ":mips_io_port_base=0x%08lx\n",
832 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
834 ioport_resource
.end
= 0xffffffff;
835 iomem_resource
.end
= 0xffffffff;
837 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
839 _machine_restart
= toshiba_rbtx4927_restart
;
840 _machine_halt
= toshiba_rbtx4927_halt
;
841 pm_power_off
= toshiba_rbtx4927_power_off
;
847 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
850 * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
851 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
852 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
853 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
854 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
855 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
858 * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
859 * PCIDIVMODE[10] is 0.
860 * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
861 * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
862 * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
863 * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
864 * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
865 * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
868 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1
,
869 "ccfg is %lx, PCIDIVMODE is %x\n",
870 (unsigned long) tx4927_ccfgptr
->ccfg
,
871 (unsigned long) tx4927_ccfgptr
->ccfg
&
872 (mips_machtype
== MACH_TOSHIBA_RBTX4937
?
873 TX4937_CCFG_PCIDIVMODE_MASK
:
874 TX4927_CCFG_PCIDIVMODE_MASK
));
876 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1
,
877 "PCI66 mode is %lx, PCI mode is %lx, pci arb is %lx\n",
878 (unsigned long) tx4927_ccfgptr
->
879 ccfg
& TX4927_CCFG_PCI66
,
880 (unsigned long) tx4927_ccfgptr
->
881 ccfg
& TX4927_CCFG_PCIMIDE
,
882 (unsigned long) tx4927_ccfgptr
->
883 ccfg
& TX4927_CCFG_PCIXARB
);
885 if (mips_machtype
== MACH_TOSHIBA_RBTX4937
)
886 switch ((unsigned long)tx4927_ccfgptr
->
887 ccfg
& TX4937_CCFG_PCIDIVMODE_MASK
) {
888 case TX4937_CCFG_PCIDIVMODE_8
:
889 case TX4937_CCFG_PCIDIVMODE_4
:
890 tx4927_cpu_clock
= 266666666; /* 266MHz */
892 case TX4937_CCFG_PCIDIVMODE_9
:
893 case TX4937_CCFG_PCIDIVMODE_4_5
:
894 tx4927_cpu_clock
= 300000000; /* 300MHz */
897 tx4927_cpu_clock
= 333333333; /* 333MHz */
900 switch ((unsigned long)tx4927_ccfgptr
->
901 ccfg
& TX4927_CCFG_PCIDIVMODE_MASK
) {
902 case TX4927_CCFG_PCIDIVMODE_2_5
:
903 case TX4927_CCFG_PCIDIVMODE_5
:
904 tx4927_cpu_clock
= 166666666; /* 166MHz */
907 tx4927_cpu_clock
= 200000000; /* 200MHz */
911 /* enable Timeout BusError */
912 if (tx4927_ccfg_toeon
)
913 tx4927_ccfgptr
->ccfg
|= TX4927_CCFG_TOE
;
916 #ifdef CONFIG_TX4927BUG_WORKAROUND
918 * TX4927-BUG: INF 01-01-18/ BUG 01-01-22
919 * G-bus timeout error detection is incorrect
921 if (tx4927_ccfg_toeon
)
922 tx4927_sdramcptr
->tr
|= 0x02000000; /* RCD:3tck */
926 if (tx4927_using_backplane
== 1)
927 printk("backplane board IS installed\n");
929 printk("No Backplane \n");
931 /* this is on ISA bus behind PCI bus, so need PCI up first */
932 #ifdef CONFIG_TOSHIBA_FPCIB0
934 if (tx4927_using_backplane
) {
935 TOSHIBA_RBTX4927_SETUP_DPRINTK
936 (TOSHIBA_RBTX4927_SETUP_SETUP
,
939 TOSHIBA_RBTX4927_SETUP_DPRINTK
940 (TOSHIBA_RBTX4927_SETUP_SETUP
,
941 ":smsc_fdc37m81x_init()\n");
942 smsc_fdc37m81x_init(0x3f0);
944 TOSHIBA_RBTX4927_SETUP_DPRINTK
945 (TOSHIBA_RBTX4927_SETUP_SETUP
,
946 ":smsc_fdc37m81x_config_beg()\n");
947 smsc_fdc37m81x_config_beg();
949 TOSHIBA_RBTX4927_SETUP_DPRINTK
950 (TOSHIBA_RBTX4927_SETUP_SETUP
,
951 ":smsc_fdc37m81x_config_set(KBD)\n");
952 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM
,
954 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT
, 1);
955 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2
, 12);
956 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE
,
959 smsc_fdc37m81x_config_end();
960 TOSHIBA_RBTX4927_SETUP_DPRINTK
961 (TOSHIBA_RBTX4927_SETUP_SETUP
,
962 ":smsc_fdc37m81x_config_end()\n");
964 TOSHIBA_RBTX4927_SETUP_DPRINTK
965 (TOSHIBA_RBTX4927_SETUP_SETUP
,
966 ":fpcibo=not_found\n");
971 TOSHIBA_RBTX4927_SETUP_DPRINTK
972 (TOSHIBA_RBTX4927_SETUP_SETUP
, ":fpcibo=no\n");
976 #endif /* CONFIG_PCI */
978 #ifdef CONFIG_SERIAL_TXX9
980 extern int early_serial_txx9_setup(struct uart_port
*port
);
982 struct uart_port req
;
983 for(i
= 0; i
< 2; i
++) {
984 memset(&req
, 0, sizeof(req
));
986 req
.iotype
= UPIO_MEM
;
987 req
.membase
= (char *)(0xff1ff300 + i
* 0x100);
988 req
.mapbase
= 0xff1ff300 + i
* 0x100;
990 req
.flags
|= UPF_BUGGY_UART
/*HAVE_CTS_LINE*/;
991 req
.uartclk
= 50000000;
992 early_serial_txx9_setup(&req
);
995 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
996 argptr
= prom_getcmdline();
997 if (strstr(argptr
, "console=") == NULL
) {
998 strcat(argptr
, " console=ttyS0,38400");
1003 #ifdef CONFIG_ROOT_NFS
1004 argptr
= prom_getcmdline();
1005 if (strstr(argptr
, "root=") == NULL
) {
1006 strcat(argptr
, " root=/dev/nfs rw");
1011 #ifdef CONFIG_IP_PNP
1012 argptr
= prom_getcmdline();
1013 if (strstr(argptr
, "ip=") == NULL
) {
1014 strcat(argptr
, " ip=any");
1019 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
1023 #ifdef CONFIG_RTC_DS1742
1024 extern unsigned long rtc_ds1742_get_time(void);
1025 extern int rtc_ds1742_set_time(unsigned long);
1026 extern void rtc_ds1742_wait(void);
1030 toshiba_rbtx4927_time_init(void)
1035 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
, "-\n");
1037 #ifdef CONFIG_RTC_DS1742
1039 rtc_get_time
= rtc_ds1742_get_time
;
1040 rtc_set_time
= rtc_ds1742_set_time
;
1042 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1043 ":rtc_ds1742_init()-\n");
1044 rtc_ds1742_init(0xbc010000);
1045 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1046 ":rtc_ds1742_init()+\n");
1048 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1049 ":Calibrate mips_hpt_frequency-\n");
1053 c1
= read_c0_count();
1055 /* wait for the seconds to change again */
1058 /* get the count again */
1059 c2
= read_c0_count();
1061 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1062 ":Calibrate mips_hpt_frequency+\n");
1063 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1065 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1068 /* this diff is as close as we are going to get to counter ticks per sec */
1069 mips_hpt_frequency
= abs(c2
- c1
);
1070 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1071 ":f1=%12u\n", mips_hpt_frequency
);
1073 /* round to 1/10th of a MHz */
1074 mips_hpt_frequency
/= (100 * 1000);
1075 mips_hpt_frequency
*= (100 * 1000);
1076 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1077 ":f2=%12u\n", mips_hpt_frequency
);
1079 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_INFO
,
1080 ":mips_hpt_frequency=%uHz (%uMHz)\n",
1082 mips_hpt_frequency
/ 1000000);
1084 mips_hpt_frequency
= 100000000;
1087 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
, "+\n");
1091 void __init
toshiba_rbtx4927_timer_setup(struct irqaction
*irq
)
1093 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
,
1095 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
,