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>
56 #include <asm/bootinfo.h>
60 #include <asm/processor.h>
61 #include <asm/ptrace.h>
62 #include <asm/reboot.h>
64 #include <linux/bootmem.h>
65 #include <linux/blkdev.h>
66 #ifdef CONFIG_RTC_DS1742
67 #include <linux/ds1742rtc.h>
69 #ifdef CONFIG_TOSHIBA_FPCIB0
70 #include <asm/tx4927/smsc_fdc37m81x.h>
72 #include <asm/tx4927/toshiba_rbtx4927.h>
74 #include <asm/tx4927/tx4927_pci.h>
76 #ifdef CONFIG_BLK_DEV_IDEPCI
77 #include <linux/hdreg.h>
78 #include <linux/ide.h>
80 #ifdef CONFIG_SERIAL_TXX9
81 #include <linux/tty.h>
82 #include <linux/serial.h>
83 #include <linux/serial_core.h>
86 #undef TOSHIBA_RBTX4927_SETUP_DEBUG
88 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
89 #define TOSHIBA_RBTX4927_SETUP_NONE 0x00000000
91 #define TOSHIBA_RBTX4927_SETUP_INFO ( 1 << 0 )
92 #define TOSHIBA_RBTX4927_SETUP_WARN ( 1 << 1 )
93 #define TOSHIBA_RBTX4927_SETUP_EROR ( 1 << 2 )
95 #define TOSHIBA_RBTX4927_SETUP_EFWFU ( 1 << 3 )
96 #define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 )
97 #define TOSHIBA_RBTX4927_SETUP_TIME_INIT ( 1 << 5 )
98 #define TOSHIBA_RBTX4927_SETUP_TIMER_SETUP ( 1 << 6 )
99 #define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 )
100 #define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 )
101 #define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 )
102 #define TOSHIBA_RBTX4927_SETUP_PCI66 ( 1 << 10 )
104 #define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
107 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
108 static const u32 toshiba_rbtx4927_setup_debug_flag
=
109 (TOSHIBA_RBTX4927_SETUP_NONE
| TOSHIBA_RBTX4927_SETUP_INFO
|
110 TOSHIBA_RBTX4927_SETUP_WARN
| TOSHIBA_RBTX4927_SETUP_EROR
|
111 TOSHIBA_RBTX4927_SETUP_EFWFU
| TOSHIBA_RBTX4927_SETUP_SETUP
|
112 TOSHIBA_RBTX4927_SETUP_TIME_INIT
| TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
113 | TOSHIBA_RBTX4927_SETUP_PCIBIOS
| TOSHIBA_RBTX4927_SETUP_PCI1
|
114 TOSHIBA_RBTX4927_SETUP_PCI2
| TOSHIBA_RBTX4927_SETUP_PCI66
);
117 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
118 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...) \
119 if ( (toshiba_rbtx4927_setup_debug_flag) & (flag) ) \
122 sprintf( tmp, str ); \
123 printk( "%s(%s:%u)::%s", __FUNCTION__, __FILE__, __LINE__, tmp ); \
126 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...)
129 /* These functions are used for rebooting or halting the machine*/
130 extern void toshiba_rbtx4927_restart(char *command
);
131 extern void toshiba_rbtx4927_halt(void);
132 extern void toshiba_rbtx4927_power_off(void);
134 int tx4927_using_backplane
= 0;
136 extern void gt64120_time_init(void);
137 extern void toshiba_rbtx4927_irq_setup(void);
140 #define CONFIG_TX4927BUG_WORKAROUND
141 #undef TX4927_SUPPORT_COMMAND_IO
142 #undef TX4927_SUPPORT_PCI_66
143 int tx4927_cpu_clock
= 100000000; /* 100MHz */
144 unsigned long mips_pci_io_base
;
145 unsigned long mips_pci_io_size
;
146 unsigned long mips_pci_mem_base
;
147 unsigned long mips_pci_mem_size
;
148 /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
149 unsigned long mips_pci_io_pciaddr
= 0;
150 unsigned long mips_memory_upper
;
151 static int tx4927_ccfg_toeon
= 1;
152 static int tx4927_pcic_trdyto
= 0; /* default: disabled */
153 unsigned long tx4927_ce_base
[8];
154 void tx4927_pci_setup(void);
155 void tx4927_reset_pci_pcic(void);
156 int tx4927_pci66
= 0; /* 0:auto */
159 char *toshiba_name
= "";
162 static void tx4927_pcierr_interrupt(int irq
, void *dev_id
,
163 struct pt_regs
*regs
)
165 #ifdef CONFIG_BLK_DEV_IDEPCI
166 /* ignore MasterAbort for ide probing... */
167 if (irq
== TX4927_IRQ_IRC_PCIERR
&&
168 ((tx4927_pcicptr
->pcistatus
>> 16) & 0xf900) ==
169 PCI_STATUS_REC_MASTER_ABORT
) {
170 tx4927_pcicptr
->pcistatus
=
172 pcistatus
& 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT
178 printk("PCI error interrupt (irq 0x%x).\n", irq
);
180 printk("pcistat:%04x, g2pstatus:%08lx, pcicstatus:%08lx\n",
181 (unsigned short) (tx4927_pcicptr
->pcistatus
>> 16),
182 tx4927_pcicptr
->g2pstatus
, tx4927_pcicptr
->pcicstatus
);
183 printk("ccfg:%08lx, tear:%02lx_%08lx\n",
184 (unsigned long) tx4927_ccfgptr
->ccfg
,
185 (unsigned long) (tx4927_ccfgptr
->tear
>> 32),
186 (unsigned long) tx4927_ccfgptr
->tear
);
190 void __init
toshiba_rbtx4927_pci_irq_init(void)
195 void tx4927_reset_pci_pcic(void)
198 *tx4927_pcireset_ptr
= 1;
200 tx4927_ccfgptr
->clkctr
|= TX4927_CLKCTR_PCIRST
;
202 /* clear PCIC reset */
203 tx4927_ccfgptr
->clkctr
&= ~TX4927_CLKCTR_PCIRST
;
204 *tx4927_pcireset_ptr
= 0;
206 #endif /* CONFIG_PCI */
209 void print_pci_status(void)
211 printk("PCI STATUS %lx\n", tx4927_pcicptr
->pcistatus
);
212 printk("PCIC STATUS %lx\n", tx4927_pcicptr
->pcicstatus
);
215 extern struct pci_controller tx4927_controller
;
217 static struct pci_dev
*fake_pci_dev(struct pci_controller
*hose
,
218 int top_bus
, int busnr
, int devfn
)
220 static struct pci_dev dev
;
221 static struct pci_bus bus
;
223 dev
.sysdata
= (void *)hose
;
226 bus
.ops
= hose
->pci_ops
;
233 #define EARLY_PCI_OP(rw, size, type) \
234 static int early_##rw##_config_##size(struct pci_controller *hose, \
235 int top_bus, int bus, int devfn, int offset, type value) \
237 return pci_##rw##_config_##size( \
238 fake_pci_dev(hose, top_bus, bus, devfn), \
242 EARLY_PCI_OP(read
, byte
, u8
*)
243 EARLY_PCI_OP(read
, word
, u16
*)
244 EARLY_PCI_OP(read
, dword
, u32
*)
245 EARLY_PCI_OP(write
, byte
, u8
)
246 EARLY_PCI_OP(write
, word
, u16
)
247 EARLY_PCI_OP(write
, dword
, u32
)
249 static int __init
tx4927_pcibios_init(void)
254 int devfn_stop
= 0xff;
255 int busno
= 0; /* One bus on the Toshiba */
256 struct pci_controller
*hose
= &tx4927_controller
;
258 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
261 for (pci_devfn
= devfn_start
; pci_devfn
< devfn_stop
; pci_devfn
++) {
262 early_read_config_dword(hose
, busno
, busno
, pci_devfn
,
265 if (id
== 0xffffffff) {
269 if (id
== 0x94601055) {
273 char *s
= " sb/isa --";
275 TOSHIBA_RBTX4927_SETUP_DPRINTK
276 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s beg\n",
279 early_read_config_byte(hose
, busno
, busno
,
280 pci_devfn
, 0x64, &v08_64
);
281 early_read_config_dword(hose
, busno
, busno
,
282 pci_devfn
, 0xb0, &v32_b0
);
283 early_read_config_byte(hose
, busno
, busno
,
284 pci_devfn
, 0xe1, &v08_e1
);
286 TOSHIBA_RBTX4927_SETUP_DPRINTK
287 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
288 ":%s beg 0x64 = 0x%02x\n", s
, v08_64
);
289 TOSHIBA_RBTX4927_SETUP_DPRINTK
290 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
291 ":%s beg 0xb0 = 0x%02x\n", s
, v32_b0
);
292 TOSHIBA_RBTX4927_SETUP_DPRINTK
293 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
294 ":%s beg 0xe1 = 0x%02x\n", s
, v08_e1
);
296 /* serial irq control */
300 v32_b0
|= 0x00010000;
302 /* ide irq on isa14 */
306 TOSHIBA_RBTX4927_SETUP_DPRINTK
307 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
308 ":%s mid 0x64 = 0x%02x\n", s
, v08_64
);
309 TOSHIBA_RBTX4927_SETUP_DPRINTK
310 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
311 ":%s mid 0xb0 = 0x%02x\n", s
, v32_b0
);
312 TOSHIBA_RBTX4927_SETUP_DPRINTK
313 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
314 ":%s mid 0xe1 = 0x%02x\n", s
, v08_e1
);
316 early_write_config_byte(hose
, busno
, busno
,
317 pci_devfn
, 0x64, v08_64
);
318 early_write_config_dword(hose
, busno
, busno
,
319 pci_devfn
, 0xb0, v32_b0
);
320 early_write_config_byte(hose
, busno
, busno
,
321 pci_devfn
, 0xe1, v08_e1
);
323 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
325 early_read_config_byte(hose
, busno
, busno
,
328 early_read_config_dword(hose
, busno
, busno
,
331 early_read_config_byte(hose
, busno
, busno
,
335 TOSHIBA_RBTX4927_SETUP_DPRINTK
336 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
337 ":%s end 0x64 = 0x%02x\n", s
, v08_64
);
338 TOSHIBA_RBTX4927_SETUP_DPRINTK
339 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
340 ":%s end 0xb0 = 0x%02x\n", s
, v32_b0
);
341 TOSHIBA_RBTX4927_SETUP_DPRINTK
342 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
343 ":%s end 0xe1 = 0x%02x\n", s
, v08_e1
);
347 TOSHIBA_RBTX4927_SETUP_DPRINTK
348 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s end\n",
352 if (id
== 0x91301055) {
358 char *s
= " sb/ide --";
360 TOSHIBA_RBTX4927_SETUP_DPRINTK
361 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s beg\n",
364 early_read_config_byte(hose
, busno
, busno
,
365 pci_devfn
, 0x04, &v08_04
);
366 early_read_config_byte(hose
, busno
, busno
,
367 pci_devfn
, 0x09, &v08_09
);
368 early_read_config_byte(hose
, busno
, busno
,
369 pci_devfn
, 0x41, &v08_41
);
370 early_read_config_byte(hose
, busno
, busno
,
371 pci_devfn
, 0x43, &v08_43
);
372 early_read_config_byte(hose
, busno
, busno
,
373 pci_devfn
, 0x5c, &v08_5c
);
375 TOSHIBA_RBTX4927_SETUP_DPRINTK
376 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
377 ":%s beg 0x04 = 0x%02x\n", s
, v08_04
);
378 TOSHIBA_RBTX4927_SETUP_DPRINTK
379 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
380 ":%s beg 0x09 = 0x%02x\n", s
, v08_09
);
381 TOSHIBA_RBTX4927_SETUP_DPRINTK
382 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
383 ":%s beg 0x41 = 0x%02x\n", s
, v08_41
);
384 TOSHIBA_RBTX4927_SETUP_DPRINTK
385 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
386 ":%s beg 0x43 = 0x%02x\n", s
, v08_43
);
387 TOSHIBA_RBTX4927_SETUP_DPRINTK
388 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
389 ":%s beg 0x5c = 0x%02x\n", s
, v08_5c
);
391 /* enable ide master/io */
392 v08_04
|= (PCI_COMMAND_MASTER
| PCI_COMMAND_IO
);
394 /* enable ide native mode */
397 /* enable primary ide */
400 /* enable secondary ide */
404 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
406 * This line of code is intended to provide the user with a work
407 * around solution to the anomalies cited in SMSC's anomaly sheet
408 * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
410 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
414 TOSHIBA_RBTX4927_SETUP_DPRINTK
415 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
416 ":%s mid 0x04 = 0x%02x\n", s
, v08_04
);
417 TOSHIBA_RBTX4927_SETUP_DPRINTK
418 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
419 ":%s mid 0x09 = 0x%02x\n", s
, v08_09
);
420 TOSHIBA_RBTX4927_SETUP_DPRINTK
421 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
422 ":%s mid 0x41 = 0x%02x\n", s
, v08_41
);
423 TOSHIBA_RBTX4927_SETUP_DPRINTK
424 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
425 ":%s mid 0x43 = 0x%02x\n", s
, v08_43
);
426 TOSHIBA_RBTX4927_SETUP_DPRINTK
427 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
428 ":%s mid 0x5c = 0x%02x\n", s
, v08_5c
);
430 early_write_config_byte(hose
, busno
, busno
,
431 pci_devfn
, 0x5c, v08_5c
);
432 early_write_config_byte(hose
, busno
, busno
,
433 pci_devfn
, 0x04, v08_04
);
434 early_write_config_byte(hose
, busno
, busno
,
435 pci_devfn
, 0x09, v08_09
);
436 early_write_config_byte(hose
, busno
, busno
,
437 pci_devfn
, 0x41, v08_41
);
438 early_write_config_byte(hose
, busno
, busno
,
439 pci_devfn
, 0x43, v08_43
);
441 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
443 early_read_config_byte(hose
, busno
, busno
,
446 early_read_config_byte(hose
, busno
, busno
,
449 early_read_config_byte(hose
, busno
, busno
,
452 early_read_config_byte(hose
, busno
, busno
,
455 early_read_config_byte(hose
, busno
, busno
,
459 TOSHIBA_RBTX4927_SETUP_DPRINTK
460 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
461 ":%s end 0x04 = 0x%02x\n", s
, v08_04
);
462 TOSHIBA_RBTX4927_SETUP_DPRINTK
463 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
464 ":%s end 0x09 = 0x%02x\n", s
, v08_09
);
465 TOSHIBA_RBTX4927_SETUP_DPRINTK
466 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
467 ":%s end 0x41 = 0x%02x\n", s
, v08_41
);
468 TOSHIBA_RBTX4927_SETUP_DPRINTK
469 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
470 ":%s end 0x43 = 0x%02x\n", s
, v08_43
);
471 TOSHIBA_RBTX4927_SETUP_DPRINTK
472 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
473 ":%s end 0x5c = 0x%02x\n", s
, v08_5c
);
477 TOSHIBA_RBTX4927_SETUP_DPRINTK
478 (TOSHIBA_RBTX4927_SETUP_PCIBIOS
, ":%s end\n",
484 register_pci_controller(&tx4927_controller
);
485 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS
,
491 arch_initcall(tx4927_pcibios_init
);
493 extern struct resource pci_io_resource
;
494 extern struct resource pci_mem_resource
;
496 void tx4927_pci_setup(void)
498 static int called
= 0;
499 extern unsigned int tx4927_get_mem_size(void);
501 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
, "-\n");
503 mips_memory_upper
= tx4927_get_mem_size() << 20;
504 mips_memory_upper
+= KSEG0
;
505 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
506 "0x%08lx=mips_memory_upper\n",
508 mips_pci_io_base
= TX4927_PCIIO
;
509 mips_pci_io_size
= TX4927_PCIIO_SIZE
;
510 mips_pci_mem_base
= TX4927_PCIMEM
;
511 mips_pci_mem_size
= TX4927_PCIMEM_SIZE
;
513 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
514 "0x%08lx=mips_pci_io_base\n",
516 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
517 "0x%08lx=mips_pci_io_size\n",
519 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
520 "0x%08lx=mips_pci_mem_base\n",
522 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
523 "0x%08lx=mips_pci_mem_size\n",
525 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
526 "0x%08lx=pci_io_resource.start\n",
527 pci_io_resource
.start
);
528 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
529 "0x%08lx=pci_io_resource.end\n",
530 pci_io_resource
.end
);
531 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
532 "0x%08lx=pci_mem_resource.start\n",
533 pci_mem_resource
.start
);
534 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
535 "0x%08lx=pci_mem_resource.end\n",
536 pci_mem_resource
.end
);
537 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
538 "0x%08lx=mips_io_port_base",
541 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
542 "setup pci_io_resource to 0x%08lx 0x%08lx\n",
543 pci_io_resource
.start
,
544 pci_io_resource
.end
);
545 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
546 "setup pci_mem_resource to 0x%08lx 0x%08lx\n",
547 pci_mem_resource
.start
,
548 pci_mem_resource
.end
);
552 ("TX4927 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
553 (unsigned short) (tx4927_pcicptr
->pciid
>> 16),
554 (unsigned short) (tx4927_pcicptr
->pciid
& 0xffff),
555 (unsigned short) (tx4927_pcicptr
->pciccrev
& 0xff),
557 ccfg
& TX4927_CCFG_PCIXARB
)) ? "External" :
561 printk("%s PCIC --%s PCICLK:",toshiba_name
,
562 (tx4927_ccfgptr
->ccfg
& TX4927_CCFG_PCI66
) ? " PCI66" : "");
563 if (tx4927_ccfgptr
->pcfg
& TX4927_PCFG_PCICLKEN_ALL
) {
565 switch ((unsigned long) tx4927_ccfgptr
->
566 ccfg
& TX4927_CCFG_PCIDIVMODE_MASK
) {
567 case TX4927_CCFG_PCIDIVMODE_2_5
:
568 pciclk
= tx4927_cpu_clock
* 2 / 5;
570 case TX4927_CCFG_PCIDIVMODE_3
:
571 pciclk
= tx4927_cpu_clock
/ 3;
573 case TX4927_CCFG_PCIDIVMODE_5
:
574 pciclk
= tx4927_cpu_clock
/ 5;
576 case TX4927_CCFG_PCIDIVMODE_6
:
577 pciclk
= tx4927_cpu_clock
/ 6;
580 printk("Internal(%dMHz)", pciclk
/ 1000000);
583 int pciclk_setting
= *tx4927_pci_clk_ptr
;
584 switch (pciclk_setting
& TX4927_PCI_CLK_MASK
) {
585 case TX4927_PCI_CLK_33
:
588 case TX4927_PCI_CLK_25
:
591 case TX4927_PCI_CLK_66
:
594 case TX4927_PCI_CLK_50
:
598 printk("External(%dMHz)", pciclk
/ 1000000);
604 /* GB->PCI mappings */
605 tx4927_pcicptr
->g2piomask
= (mips_pci_io_size
- 1) >> 4;
606 tx4927_pcicptr
->g2piogbase
= mips_pci_io_base
|
608 TX4927_PCIC_G2PIOGBASE_ECHG
610 TX4927_PCIC_G2PIOGBASE_BSDIS
614 tx4927_pcicptr
->g2piopbase
= 0;
616 tx4927_pcicptr
->g2pmmask
[0] = (mips_pci_mem_size
- 1) >> 4;
617 tx4927_pcicptr
->g2pmgbase
[0] = mips_pci_mem_base
|
619 TX4927_PCIC_G2PMnGBASE_ECHG
621 TX4927_PCIC_G2PMnGBASE_BSDIS
624 tx4927_pcicptr
->g2pmpbase
[0] = mips_pci_mem_base
;
626 tx4927_pcicptr
->g2pmmask
[1] = 0;
627 tx4927_pcicptr
->g2pmgbase
[1] = 0;
628 tx4927_pcicptr
->g2pmpbase
[1] = 0;
629 tx4927_pcicptr
->g2pmmask
[2] = 0;
630 tx4927_pcicptr
->g2pmgbase
[2] = 0;
631 tx4927_pcicptr
->g2pmpbase
[2] = 0;
634 /* PCI->GB mappings (I/O 256B) */
635 tx4927_pcicptr
->p2giopbase
= 0; /* 256B */
637 /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
638 tx4927_pcicptr
->p2gm0plbase
= 0;
639 tx4927_pcicptr
->p2gm0pubase
= 0;
640 tx4927_pcicptr
->p2gmgbase
[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN
|
642 TX4927_PCIC_P2GMnGBASE_TECHG
644 TX4927_PCIC_P2GMnGBASE_TBSDIS
648 /* PCI->GB mappings (MEM 16MB) -not used */
649 tx4927_pcicptr
->p2gm1plbase
= 0xffffffff;
650 #ifdef CONFIG_TX4927BUG_WORKAROUND
652 * TX4927-PCIC-BUG: P2GM1PUBASE must be 0
653 * if P2GM0PUBASE was 0.
655 tx4927_pcicptr
->p2gm1pubase
= 0;
657 tx4927_pcicptr
->p2gm1pubase
= 0xffffffff;
659 tx4927_pcicptr
->p2gmgbase
[1] = 0;
661 /* PCI->GB mappings (MEM 1MB) -not used */
662 tx4927_pcicptr
->p2gm2pbase
= 0xffffffff;
663 tx4927_pcicptr
->p2gmgbase
[2] = 0;
666 /* Enable Initiator Memory 0 Space, I/O Space, Config */
667 tx4927_pcicptr
->pciccfg
&= TX4927_PCIC_PCICCFG_LBWC_MASK
;
668 tx4927_pcicptr
->pciccfg
|=
669 TX4927_PCIC_PCICCFG_IMSE0
| TX4927_PCIC_PCICCFG_IISE
|
670 TX4927_PCIC_PCICCFG_ICAE
| TX4927_PCIC_PCICCFG_ATR
;
673 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
674 tx4927_pcicptr
->pcicfg1
= 0;
676 if (tx4927_pcic_trdyto
>= 0) {
677 tx4927_pcicptr
->g2ptocnt
&= ~0xff;
678 tx4927_pcicptr
->g2ptocnt
|= (tx4927_pcic_trdyto
& 0xff);
681 /* Clear All Local Bus Status */
682 tx4927_pcicptr
->pcicstatus
= TX4927_PCIC_PCICSTATUS_ALL
;
683 /* Enable All Local Bus Interrupts */
684 tx4927_pcicptr
->pcicmask
= TX4927_PCIC_PCICSTATUS_ALL
;
685 /* Clear All Initiator Status */
686 tx4927_pcicptr
->g2pstatus
= TX4927_PCIC_G2PSTATUS_ALL
;
687 /* Enable All Initiator Interrupts */
688 tx4927_pcicptr
->g2pmask
= TX4927_PCIC_G2PSTATUS_ALL
;
689 /* Clear All PCI Status Error */
690 tx4927_pcicptr
->pcistatus
=
691 (tx4927_pcicptr
->pcistatus
& 0x0000ffff) |
692 (TX4927_PCIC_PCISTATUS_ALL
<< 16);
693 /* Enable All PCI Status Error Interrupts */
694 tx4927_pcicptr
->pcimask
= TX4927_PCIC_PCISTATUS_ALL
;
696 /* PCIC Int => IRC IRQ16 */
697 tx4927_pcicptr
->pcicfg2
=
698 (tx4927_pcicptr
->pcicfg2
& 0xffffff00) | TX4927_IR_PCIC
;
700 if (!(tx4927_ccfgptr
->ccfg
& TX4927_CCFG_PCIXARB
)) {
703 /* Reset Bus Arbiter */
704 tx4927_pcicptr
->pbacfg
= TX4927_PCIC_PBACFG_RPBA
;
705 /* Enable Bus Arbiter */
706 tx4927_pcicptr
->pbacfg
= TX4927_PCIC_PBACFG_PBAEN
;
709 tx4927_pcicptr
->pcistatus
= PCI_COMMAND_MASTER
|
711 PCI_COMMAND_PARITY
| PCI_COMMAND_SERR
;
713 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
,
714 ":pci setup complete:\n");
715 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2
, "+\n");
718 #endif /* CONFIG_PCI */
720 void toshiba_rbtx4927_restart(char *command
)
722 printk(KERN_NOTICE
"System Rebooting...\n");
724 /* enable the s/w reset register */
725 reg_wr08(RBTX4927_SW_RESET_ENABLE
, RBTX4927_SW_RESET_ENABLE_SET
);
727 /* wait for enable to be seen */
728 while ((reg_rd08(RBTX4927_SW_RESET_ENABLE
) &
729 RBTX4927_SW_RESET_ENABLE_SET
) == 0x00);
732 reg_wr08(RBTX4927_SW_RESET_DO
, RBTX4927_SW_RESET_DO_SET
);
734 /* do something passive while waiting for reset */
743 void toshiba_rbtx4927_halt(void)
745 printk(KERN_NOTICE
"System Halted\n");
753 void toshiba_rbtx4927_power_off(void)
755 toshiba_rbtx4927_halt();
759 void __init
toshiba_rbtx4927_setup(void)
764 printk("CPU is %s\n", toshiba_name
);
766 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
769 /* f/w leaves this on at startup */
770 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
771 ":Clearing STO_ERL.\n");
772 clear_c0_status(ST0_ERL
);
774 /* enable caches -- HCP5 does this, pmon does not */
775 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
776 ":Enabling TX49_CONF_IC,TX49_CONF_DC.\n");
777 cp0_config
= read_c0_config();
778 cp0_config
= cp0_config
& ~(TX49_CONF_IC
| TX49_CONF_DC
);
779 write_c0_config(cp0_config
);
781 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
783 extern void dump_cp0(char *);
784 dump_cp0("toshiba_rbtx4927_early_fw_fixup");
788 /* setup irq stuff */
789 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
790 ":Setting up tx4927 pic.\n");
791 TX4927_WR(0xff1ff604, 0x00000400); /* irq trigger */
792 TX4927_WR(0xff1ff608, 0x00000000); /* irq trigger */
794 /* setup serial stuff */
795 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
796 ":Setting up tx4927 sio.\n");
797 TX4927_WR(0xff1ff314, 0x00000000); /* h/w flow control off */
798 TX4927_WR(0xff1ff414, 0x00000000); /* h/w flow control off */
800 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
803 set_io_port_base(KSEG1
+ TBTX4927_ISA_IO_OFFSET
);
804 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
805 ":mips_io_port_base=0x%08lx\n",
808 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
810 ioport_resource
.end
= 0xffffffff;
811 iomem_resource
.end
= 0xffffffff;
813 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
815 _machine_restart
= toshiba_rbtx4927_restart
;
816 _machine_halt
= toshiba_rbtx4927_halt
;
817 _machine_power_off
= toshiba_rbtx4927_power_off
;
823 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
824 * PCIDIVMODE[12:11]'s initial value are given by S9[4:3] (ON:0, OFF:1).
825 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
826 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
827 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
828 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
829 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
831 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1
,
832 "ccfg is %lx, DIV is %x\n",
833 (unsigned long) tx4927_ccfgptr
->
834 ccfg
, TX4927_CCFG_PCIDIVMODE_MASK
);
836 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1
,
837 "PCI66 mode is %lx, PCI mode is %lx, pci arb is %lx\n",
838 (unsigned long) tx4927_ccfgptr
->
839 ccfg
& TX4927_CCFG_PCI66
,
840 (unsigned long) tx4927_ccfgptr
->
841 ccfg
& TX4927_CCFG_PCIMIDE
,
842 (unsigned long) tx4927_ccfgptr
->
843 ccfg
& TX4927_CCFG_PCIXARB
);
845 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1
,
846 "PCIDIVMODE is %lx\n",
847 (unsigned long) tx4927_ccfgptr
->
848 ccfg
& TX4927_CCFG_PCIDIVMODE_MASK
);
850 switch ((unsigned long) tx4927_ccfgptr
->
851 ccfg
& TX4927_CCFG_PCIDIVMODE_MASK
) {
852 case TX4927_CCFG_PCIDIVMODE_2_5
:
853 case TX4927_CCFG_PCIDIVMODE_5
:
854 tx4927_cpu_clock
= 166000000; /* 166MHz */
857 tx4927_cpu_clock
= 200000000; /* 200MHz */
861 /* enable Timeout BusError */
862 if (tx4927_ccfg_toeon
)
863 tx4927_ccfgptr
->ccfg
|= TX4927_CCFG_TOE
;
866 #ifdef CONFIG_TX4927BUG_WORKAROUND
868 * TX4927-BUG: INF 01-01-18/ BUG 01-01-22
869 * G-bus timeout error detection is incorrect
871 if (tx4927_ccfg_toeon
)
872 tx4927_sdramcptr
->tr
|= 0x02000000; /* RCD:3tck */
876 if (tx4927_using_backplane
== 1)
877 printk("backplane board IS installed\n");
879 printk("No Backplane \n");
881 /* this is on ISA bus behind PCI bus, so need PCI up first */
882 #ifdef CONFIG_TOSHIBA_FPCIB0
884 if (tx4927_using_backplane
) {
885 TOSHIBA_RBTX4927_SETUP_DPRINTK
886 (TOSHIBA_RBTX4927_SETUP_SETUP
,
889 TOSHIBA_RBTX4927_SETUP_DPRINTK
890 (TOSHIBA_RBTX4927_SETUP_SETUP
,
891 ":smsc_fdc37m81x_init()\n");
892 smsc_fdc37m81x_init(0x3f0);
894 TOSHIBA_RBTX4927_SETUP_DPRINTK
895 (TOSHIBA_RBTX4927_SETUP_SETUP
,
896 ":smsc_fdc37m81x_config_beg()\n");
897 smsc_fdc37m81x_config_beg();
899 TOSHIBA_RBTX4927_SETUP_DPRINTK
900 (TOSHIBA_RBTX4927_SETUP_SETUP
,
901 ":smsc_fdc37m81x_config_set(KBD)\n");
902 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM
,
904 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT
, 1);
905 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2
, 12);
906 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE
,
909 smsc_fdc37m81x_config_end();
910 TOSHIBA_RBTX4927_SETUP_DPRINTK
911 (TOSHIBA_RBTX4927_SETUP_SETUP
,
912 ":smsc_fdc37m81x_config_end()\n");
914 TOSHIBA_RBTX4927_SETUP_DPRINTK
915 (TOSHIBA_RBTX4927_SETUP_SETUP
,
916 ":fpcibo=not_found\n");
921 TOSHIBA_RBTX4927_SETUP_DPRINTK
922 (TOSHIBA_RBTX4927_SETUP_SETUP
, ":fpcibo=no\n");
926 #endif /* CONFIG_PCI */
928 #ifdef CONFIG_SERIAL_TXX9
930 extern int early_serial_txx9_setup(struct uart_port
*port
);
932 struct uart_port req
;
933 for(i
= 0; i
< 2; i
++) {
934 memset(&req
, 0, sizeof(req
));
936 req
.iotype
= UPIO_MEM
;
937 req
.membase
= (char *)(0xff1ff300 + i
* 0x100);
938 req
.mapbase
= 0xff1ff300 + i
* 0x100;
940 req
.flags
|= UPF_BUGGY_UART
/*HAVE_CTS_LINE*/;
941 req
.uartclk
= 50000000;
942 early_serial_txx9_setup(&req
);
945 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
946 argptr
= prom_getcmdline();
947 if (strstr(argptr
, "console=") == NULL
) {
948 strcat(argptr
, " console=ttyS0,38400");
953 #ifdef CONFIG_ROOT_NFS
954 argptr
= prom_getcmdline();
955 if (strstr(argptr
, "root=") == NULL
) {
956 strcat(argptr
, " root=/dev/nfs rw");
962 argptr
= prom_getcmdline();
963 if (strstr(argptr
, "ip=") == NULL
) {
964 strcat(argptr
, " ip=any");
969 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP
,
973 #ifdef CONFIG_RTC_DS1742
974 extern unsigned long rtc_ds1742_get_time(void);
975 extern int rtc_ds1742_set_time(unsigned long);
976 extern void rtc_ds1742_wait(void);
980 toshiba_rbtx4927_time_init(void)
985 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
, "-\n");
987 #ifdef CONFIG_RTC_DS1742
989 rtc_get_time
= rtc_ds1742_get_time
;
990 rtc_set_time
= rtc_ds1742_set_time
;
992 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
993 ":rtc_ds1742_init()-\n");
994 rtc_ds1742_init(0xbc010000);
995 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
996 ":rtc_ds1742_init()+\n");
998 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
999 ":Calibrate mips_hpt_frequency-\n");
1003 c1
= read_c0_count();
1005 /* wait for the seconds to change again */
1008 /* get the count again */
1009 c2
= read_c0_count();
1011 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1012 ":Calibrate mips_hpt_frequency+\n");
1013 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1015 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1018 /* this diff is as close as we are going to get to counter ticks per sec */
1019 mips_hpt_frequency
= abs(c2
- c1
);
1020 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1021 ":f1=%12u\n", mips_hpt_frequency
);
1023 /* round to 1/10th of a MHz */
1024 mips_hpt_frequency
/= (100 * 1000);
1025 mips_hpt_frequency
*= (100 * 1000);
1026 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
,
1027 ":f2=%12u\n", mips_hpt_frequency
);
1029 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_INFO
,
1030 ":mips_hpt_frequency=%uHz (%uMHz)\n",
1032 mips_hpt_frequency
/ 1000000);
1034 mips_hpt_frequency
= 100000000;
1037 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT
, "+\n");
1041 void __init
toshiba_rbtx4927_timer_setup(struct irqaction
*irq
)
1043 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
,
1045 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
,