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/init.h>
46 #include <linux/kernel.h>
47 #include <linux/types.h>
48 #include <linux/ioport.h>
49 #include <linux/interrupt.h>
50 #include <linux/pci.h>
52 #include <linux/platform_device.h>
54 #include <asm/bootinfo.h>
56 #include <asm/processor.h>
57 #include <asm/reboot.h>
59 #include <asm/txx9tmr.h>
60 #ifdef CONFIG_TOSHIBA_FPCIB0
61 #include <asm/tx4927/smsc_fdc37m81x.h>
63 #include <asm/tx4927/toshiba_rbtx4927.h>
65 #include <asm/tx4927/tx4927_pci.h>
67 #ifdef CONFIG_SERIAL_TXX9
68 #include <linux/serial_core.h>
71 #undef TOSHIBA_RBTX4927_SETUP_DEBUG
73 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
74 #define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 )
75 #define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 )
76 #define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 )
77 #define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 )
79 #define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
82 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
83 static const u32 toshiba_rbtx4927_setup_debug_flag =
84 (TOSHIBA_RBTX4927_SETUP_SETUP |
85 | TOSHIBA_RBTX4927_SETUP_PCIBIOS | TOSHIBA_RBTX4927_SETUP_PCI1 |
86 TOSHIBA_RBTX4927_SETUP_PCI2);
89 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
90 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...) \
91 if ( (toshiba_rbtx4927_setup_debug_flag) & (flag) ) \
94 sprintf( tmp, str ); \
95 printk( "%s(%s:%u)::%s", __FUNCTION__, __FILE__, __LINE__, tmp ); \
98 #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag, str...)
101 /* These functions are used for rebooting or halting the machine*/
102 extern void toshiba_rbtx4927_restart(char *command);
103 extern void toshiba_rbtx4927_halt(void);
104 extern void toshiba_rbtx4927_power_off(void);
106 int tx4927_using_backplane = 0;
108 extern void toshiba_rbtx4927_irq_setup(void);
110 char *prom_getcmdline(void);
113 #undef TX4927_SUPPORT_COMMAND_IO
114 #undef TX4927_SUPPORT_PCI_66
115 int tx4927_cpu_clock = 100000000; /* 100MHz */
116 unsigned long mips_pci_io_base;
117 unsigned long mips_pci_io_size;
118 unsigned long mips_pci_mem_base;
119 unsigned long mips_pci_mem_size;
120 /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
121 unsigned long mips_pci_io_pciaddr = 0;
122 unsigned long mips_memory_upper;
123 static int tx4927_ccfg_toeon = 1;
124 static int tx4927_pcic_trdyto = 0; /* default: disabled */
125 unsigned long tx4927_ce_base[8];
126 void tx4927_reset_pci_pcic(void);
127 int tx4927_pci66 = 0; /* 0:auto */
130 char *toshiba_name = "";
133 extern struct pci_controller tx4927_controller;
135 static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
136 int top_bus, int busnr, int devfn)
138 static struct pci_dev dev;
139 static struct pci_bus bus;
141 dev.sysdata = (void *)hose;
144 bus.ops = hose->pci_ops;
151 #define EARLY_PCI_OP(rw, size, type) \
152 static int early_##rw##_config_##size(struct pci_controller *hose, \
153 int top_bus, int bus, int devfn, int offset, type value) \
155 return pci_##rw##_config_##size( \
156 fake_pci_dev(hose, top_bus, bus, devfn), \
160 EARLY_PCI_OP(read, byte, u8 *)
161 EARLY_PCI_OP(read, dword, u32 *)
162 EARLY_PCI_OP(write, byte, u8)
163 EARLY_PCI_OP(write, dword, u32)
165 static int __init tx4927_pcibios_init(void)
170 int devfn_stop = 0xff;
171 int busno = 0; /* One bus on the Toshiba */
172 struct pci_controller *hose = &tx4927_controller;
174 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
177 for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) {
178 early_read_config_dword(hose, busno, busno, pci_devfn,
181 if (id == 0xffffffff) {
185 if (id == 0x94601055) {
189 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
190 char *s = " sb/isa --";
193 TOSHIBA_RBTX4927_SETUP_DPRINTK
194 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
197 early_read_config_byte(hose, busno, busno,
198 pci_devfn, 0x64, &v08_64);
199 early_read_config_dword(hose, busno, busno,
200 pci_devfn, 0xb0, &v32_b0);
201 early_read_config_byte(hose, busno, busno,
202 pci_devfn, 0xe1, &v08_e1);
204 TOSHIBA_RBTX4927_SETUP_DPRINTK
205 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
206 ":%s beg 0x64 = 0x%02x\n", s, v08_64);
207 TOSHIBA_RBTX4927_SETUP_DPRINTK
208 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
209 ":%s beg 0xb0 = 0x%02x\n", s, v32_b0);
210 TOSHIBA_RBTX4927_SETUP_DPRINTK
211 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
212 ":%s beg 0xe1 = 0x%02x\n", s, v08_e1);
214 /* serial irq control */
218 v32_b0 |= 0x00010000;
220 /* ide irq on isa14 */
224 TOSHIBA_RBTX4927_SETUP_DPRINTK
225 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
226 ":%s mid 0x64 = 0x%02x\n", s, v08_64);
227 TOSHIBA_RBTX4927_SETUP_DPRINTK
228 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
229 ":%s mid 0xb0 = 0x%02x\n", s, v32_b0);
230 TOSHIBA_RBTX4927_SETUP_DPRINTK
231 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
232 ":%s mid 0xe1 = 0x%02x\n", s, v08_e1);
234 early_write_config_byte(hose, busno, busno,
235 pci_devfn, 0x64, v08_64);
236 early_write_config_dword(hose, busno, busno,
237 pci_devfn, 0xb0, v32_b0);
238 early_write_config_byte(hose, busno, busno,
239 pci_devfn, 0xe1, v08_e1);
241 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
243 early_read_config_byte(hose, busno, busno,
246 early_read_config_dword(hose, busno, busno,
249 early_read_config_byte(hose, busno, busno,
253 TOSHIBA_RBTX4927_SETUP_DPRINTK
254 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
255 ":%s end 0x64 = 0x%02x\n", s, v08_64);
256 TOSHIBA_RBTX4927_SETUP_DPRINTK
257 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
258 ":%s end 0xb0 = 0x%02x\n", s, v32_b0);
259 TOSHIBA_RBTX4927_SETUP_DPRINTK
260 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
261 ":%s end 0xe1 = 0x%02x\n", s, v08_e1);
265 TOSHIBA_RBTX4927_SETUP_DPRINTK
266 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
270 if (id == 0x91301055) {
276 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
277 char *s = " sb/ide --";
280 TOSHIBA_RBTX4927_SETUP_DPRINTK
281 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
284 early_read_config_byte(hose, busno, busno,
285 pci_devfn, 0x04, &v08_04);
286 early_read_config_byte(hose, busno, busno,
287 pci_devfn, 0x09, &v08_09);
288 early_read_config_byte(hose, busno, busno,
289 pci_devfn, 0x41, &v08_41);
290 early_read_config_byte(hose, busno, busno,
291 pci_devfn, 0x43, &v08_43);
292 early_read_config_byte(hose, busno, busno,
293 pci_devfn, 0x5c, &v08_5c);
295 TOSHIBA_RBTX4927_SETUP_DPRINTK
296 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
297 ":%s beg 0x04 = 0x%02x\n", s, v08_04);
298 TOSHIBA_RBTX4927_SETUP_DPRINTK
299 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
300 ":%s beg 0x09 = 0x%02x\n", s, v08_09);
301 TOSHIBA_RBTX4927_SETUP_DPRINTK
302 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
303 ":%s beg 0x41 = 0x%02x\n", s, v08_41);
304 TOSHIBA_RBTX4927_SETUP_DPRINTK
305 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
306 ":%s beg 0x43 = 0x%02x\n", s, v08_43);
307 TOSHIBA_RBTX4927_SETUP_DPRINTK
308 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
309 ":%s beg 0x5c = 0x%02x\n", s, v08_5c);
311 /* enable ide master/io */
312 v08_04 |= (PCI_COMMAND_MASTER | PCI_COMMAND_IO);
314 /* enable ide native mode */
317 /* enable primary ide */
320 /* enable secondary ide */
324 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
326 * This line of code is intended to provide the user with a work
327 * around solution to the anomalies cited in SMSC's anomaly sheet
328 * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
330 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
334 TOSHIBA_RBTX4927_SETUP_DPRINTK
335 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
336 ":%s mid 0x04 = 0x%02x\n", s, v08_04);
337 TOSHIBA_RBTX4927_SETUP_DPRINTK
338 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
339 ":%s mid 0x09 = 0x%02x\n", s, v08_09);
340 TOSHIBA_RBTX4927_SETUP_DPRINTK
341 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
342 ":%s mid 0x41 = 0x%02x\n", s, v08_41);
343 TOSHIBA_RBTX4927_SETUP_DPRINTK
344 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
345 ":%s mid 0x43 = 0x%02x\n", s, v08_43);
346 TOSHIBA_RBTX4927_SETUP_DPRINTK
347 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
348 ":%s mid 0x5c = 0x%02x\n", s, v08_5c);
350 early_write_config_byte(hose, busno, busno,
351 pci_devfn, 0x5c, v08_5c);
352 early_write_config_byte(hose, busno, busno,
353 pci_devfn, 0x04, v08_04);
354 early_write_config_byte(hose, busno, busno,
355 pci_devfn, 0x09, v08_09);
356 early_write_config_byte(hose, busno, busno,
357 pci_devfn, 0x41, v08_41);
358 early_write_config_byte(hose, busno, busno,
359 pci_devfn, 0x43, v08_43);
361 #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
363 early_read_config_byte(hose, busno, busno,
366 early_read_config_byte(hose, busno, busno,
369 early_read_config_byte(hose, busno, busno,
372 early_read_config_byte(hose, busno, busno,
375 early_read_config_byte(hose, busno, busno,
379 TOSHIBA_RBTX4927_SETUP_DPRINTK
380 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
381 ":%s end 0x04 = 0x%02x\n", s, v08_04);
382 TOSHIBA_RBTX4927_SETUP_DPRINTK
383 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
384 ":%s end 0x09 = 0x%02x\n", s, v08_09);
385 TOSHIBA_RBTX4927_SETUP_DPRINTK
386 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
387 ":%s end 0x41 = 0x%02x\n", s, v08_41);
388 TOSHIBA_RBTX4927_SETUP_DPRINTK
389 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
390 ":%s end 0x43 = 0x%02x\n", s, v08_43);
391 TOSHIBA_RBTX4927_SETUP_DPRINTK
392 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
393 ":%s end 0x5c = 0x%02x\n", s, v08_5c);
397 TOSHIBA_RBTX4927_SETUP_DPRINTK
398 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
404 register_pci_controller(&tx4927_controller);
405 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
411 arch_initcall(tx4927_pcibios_init);
413 extern struct resource pci_io_resource;
414 extern struct resource pci_mem_resource;
416 void __init tx4927_pci_setup(void)
418 static int called = 0;
419 extern unsigned int tx4927_get_mem_size(void);
421 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "-\n");
423 mips_memory_upper = tx4927_get_mem_size() << 20;
424 mips_memory_upper += KSEG0;
425 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
426 "0x%08lx=mips_memory_upper\n",
428 mips_pci_io_base = TX4927_PCIIO;
429 mips_pci_io_size = TX4927_PCIIO_SIZE;
430 mips_pci_mem_base = TX4927_PCIMEM;
431 mips_pci_mem_size = TX4927_PCIMEM_SIZE;
433 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
434 "0x%08lx=mips_pci_io_base\n",
436 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
437 "0x%08lx=mips_pci_io_size\n",
439 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
440 "0x%08lx=mips_pci_mem_base\n",
442 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
443 "0x%08lx=mips_pci_mem_size\n",
445 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
446 "0x%08lx=pci_io_resource.start\n",
447 pci_io_resource.start);
448 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
449 "0x%08lx=pci_io_resource.end\n",
450 pci_io_resource.end);
451 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
452 "0x%08lx=pci_mem_resource.start\n",
453 pci_mem_resource.start);
454 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
455 "0x%08lx=pci_mem_resource.end\n",
456 pci_mem_resource.end);
457 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
458 "0x%08lx=mips_io_port_base",
462 ("%s PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
464 (unsigned short) (tx4927_pcicptr->pciid >> 16),
465 (unsigned short) (tx4927_pcicptr->pciid & 0xffff),
466 (unsigned short) (tx4927_pcicptr->pciccrev & 0xff),
468 ccfg & TX4927_CCFG_PCIXARB)) ? "External" :
472 printk("%s PCIC --%s PCICLK:", toshiba_name,
473 (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66) ? " PCI66" : "");
474 if (tx4927_ccfgptr->pcfg & TX4927_PCFG_PCICLKEN_ALL) {
476 if (mips_machtype == MACH_TOSHIBA_RBTX4937)
477 switch ((unsigned long) tx4927_ccfgptr->
478 ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
479 case TX4937_CCFG_PCIDIVMODE_4:
480 pciclk = tx4927_cpu_clock / 4;
482 case TX4937_CCFG_PCIDIVMODE_4_5:
483 pciclk = tx4927_cpu_clock * 2 / 9;
485 case TX4937_CCFG_PCIDIVMODE_5:
486 pciclk = tx4927_cpu_clock / 5;
488 case TX4937_CCFG_PCIDIVMODE_5_5:
489 pciclk = tx4927_cpu_clock * 2 / 11;
491 case TX4937_CCFG_PCIDIVMODE_8:
492 pciclk = tx4927_cpu_clock / 8;
494 case TX4937_CCFG_PCIDIVMODE_9:
495 pciclk = tx4927_cpu_clock / 9;
497 case TX4937_CCFG_PCIDIVMODE_10:
498 pciclk = tx4927_cpu_clock / 10;
500 case TX4937_CCFG_PCIDIVMODE_11:
501 pciclk = tx4927_cpu_clock / 11;
506 switch ((unsigned long) tx4927_ccfgptr->
507 ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
508 case TX4927_CCFG_PCIDIVMODE_2_5:
509 pciclk = tx4927_cpu_clock * 2 / 5;
511 case TX4927_CCFG_PCIDIVMODE_3:
512 pciclk = tx4927_cpu_clock / 3;
514 case TX4927_CCFG_PCIDIVMODE_5:
515 pciclk = tx4927_cpu_clock / 5;
517 case TX4927_CCFG_PCIDIVMODE_6:
518 pciclk = tx4927_cpu_clock / 6;
522 printk("Internal(%dMHz)", pciclk / 1000000);
525 int pciclk_setting = *tx4927_pci_clk_ptr;
526 switch (pciclk_setting & TX4927_PCI_CLK_MASK) {
527 case TX4927_PCI_CLK_33:
530 case TX4927_PCI_CLK_25:
533 case TX4927_PCI_CLK_66:
536 case TX4927_PCI_CLK_50:
540 printk("External(%dMHz)", pciclk / 1000000);
546 /* GB->PCI mappings */
547 tx4927_pcicptr->g2piomask = (mips_pci_io_size - 1) >> 4;
548 tx4927_pcicptr->g2piogbase = mips_pci_io_base |
550 TX4927_PCIC_G2PIOGBASE_ECHG
552 TX4927_PCIC_G2PIOGBASE_BSDIS
556 tx4927_pcicptr->g2piopbase = 0;
558 tx4927_pcicptr->g2pmmask[0] = (mips_pci_mem_size - 1) >> 4;
559 tx4927_pcicptr->g2pmgbase[0] = mips_pci_mem_base |
561 TX4927_PCIC_G2PMnGBASE_ECHG
563 TX4927_PCIC_G2PMnGBASE_BSDIS
566 tx4927_pcicptr->g2pmpbase[0] = mips_pci_mem_base;
568 tx4927_pcicptr->g2pmmask[1] = 0;
569 tx4927_pcicptr->g2pmgbase[1] = 0;
570 tx4927_pcicptr->g2pmpbase[1] = 0;
571 tx4927_pcicptr->g2pmmask[2] = 0;
572 tx4927_pcicptr->g2pmgbase[2] = 0;
573 tx4927_pcicptr->g2pmpbase[2] = 0;
576 /* PCI->GB mappings (I/O 256B) */
577 tx4927_pcicptr->p2giopbase = 0; /* 256B */
579 /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
580 tx4927_pcicptr->p2gm0plbase = 0;
581 tx4927_pcicptr->p2gm0pubase = 0;
582 tx4927_pcicptr->p2gmgbase[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN |
584 TX4927_PCIC_P2GMnGBASE_TECHG
586 TX4927_PCIC_P2GMnGBASE_TBSDIS
590 /* PCI->GB mappings (MEM 16MB) -not used */
591 tx4927_pcicptr->p2gm1plbase = 0xffffffff;
592 tx4927_pcicptr->p2gm1pubase = 0xffffffff;
593 tx4927_pcicptr->p2gmgbase[1] = 0;
595 /* PCI->GB mappings (MEM 1MB) -not used */
596 tx4927_pcicptr->p2gm2pbase = 0xffffffff;
597 tx4927_pcicptr->p2gmgbase[2] = 0;
600 /* Enable Initiator Memory 0 Space, I/O Space, Config */
601 tx4927_pcicptr->pciccfg &= TX4927_PCIC_PCICCFG_LBWC_MASK;
602 tx4927_pcicptr->pciccfg |=
603 TX4927_PCIC_PCICCFG_IMSE0 | TX4927_PCIC_PCICCFG_IISE |
604 TX4927_PCIC_PCICCFG_ICAE | TX4927_PCIC_PCICCFG_ATR;
607 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
608 tx4927_pcicptr->pcicfg1 = 0;
610 if (tx4927_pcic_trdyto >= 0) {
611 tx4927_pcicptr->g2ptocnt &= ~0xff;
612 tx4927_pcicptr->g2ptocnt |= (tx4927_pcic_trdyto & 0xff);
615 /* Clear All Local Bus Status */
616 tx4927_pcicptr->pcicstatus = TX4927_PCIC_PCICSTATUS_ALL;
617 /* Enable All Local Bus Interrupts */
618 tx4927_pcicptr->pcicmask = TX4927_PCIC_PCICSTATUS_ALL;
619 /* Clear All Initiator Status */
620 tx4927_pcicptr->g2pstatus = TX4927_PCIC_G2PSTATUS_ALL;
621 /* Enable All Initiator Interrupts */
622 tx4927_pcicptr->g2pmask = TX4927_PCIC_G2PSTATUS_ALL;
623 /* Clear All PCI Status Error */
624 tx4927_pcicptr->pcistatus =
625 (tx4927_pcicptr->pcistatus & 0x0000ffff) |
626 (TX4927_PCIC_PCISTATUS_ALL << 16);
627 /* Enable All PCI Status Error Interrupts */
628 tx4927_pcicptr->pcimask = TX4927_PCIC_PCISTATUS_ALL;
630 /* PCIC Int => IRC IRQ16 */
631 tx4927_pcicptr->pcicfg2 =
632 (tx4927_pcicptr->pcicfg2 & 0xffffff00) | TX4927_IR_PCIC;
634 if (!(tx4927_ccfgptr->ccfg & TX4927_CCFG_PCIXARB)) {
637 /* Reset Bus Arbiter */
638 tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_RPBA;
639 /* Enable Bus Arbiter */
640 tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_PBAEN;
643 tx4927_pcicptr->pcistatus = PCI_COMMAND_MASTER |
645 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
647 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
648 ":pci setup complete:\n");
649 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "+\n");
652 #endif /* CONFIG_PCI */
654 static void __noreturn wait_forever(void)
661 void toshiba_rbtx4927_restart(char *command)
663 printk(KERN_NOTICE "System Rebooting...\n");
665 /* enable the s/w reset register */
666 writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE);
668 /* wait for enable to be seen */
669 while ((readb(RBTX4927_SW_RESET_ENABLE) &
670 RBTX4927_SW_RESET_ENABLE_SET) == 0x00);
673 writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO);
675 /* do something passive while waiting for reset */
682 void toshiba_rbtx4927_halt(void)
684 printk(KERN_NOTICE "System Halted\n");
690 void toshiba_rbtx4927_power_off(void)
692 toshiba_rbtx4927_halt();
696 void __init plat_mem_setup(void)
702 printk("CPU is %s\n", toshiba_name);
704 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
707 /* f/w leaves this on at startup */
708 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
709 ":Clearing STO_ERL.\n");
710 clear_c0_status(ST0_ERL);
712 /* enable caches -- HCP5 does this, pmon does not */
713 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
714 ":Enabling TX49_CONF_IC,TX49_CONF_DC.\n");
715 cp0_config = read_c0_config();
716 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
717 write_c0_config(cp0_config);
719 set_io_port_base(KSEG1 + TBTX4927_ISA_IO_OFFSET);
720 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
721 ":mips_io_port_base=0x%08lx\n",
724 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
726 ioport_resource.end = 0xffffffff;
727 iomem_resource.end = 0xffffffff;
729 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
731 _machine_restart = toshiba_rbtx4927_restart;
732 _machine_halt = toshiba_rbtx4927_halt;
733 pm_power_off = toshiba_rbtx4927_power_off;
735 for (i = 0; i < TX4927_NR_TMR; i++)
736 txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL);
742 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
745 * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
746 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
747 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
748 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
749 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
750 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
753 * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
754 * PCIDIVMODE[10] is 0.
755 * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
756 * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
757 * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
758 * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
759 * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
760 * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
763 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
764 "ccfg is %lx, PCIDIVMODE is %x\n",
765 (unsigned long) tx4927_ccfgptr->ccfg,
766 (unsigned long) tx4927_ccfgptr->ccfg &
767 (mips_machtype == MACH_TOSHIBA_RBTX4937 ?
768 TX4937_CCFG_PCIDIVMODE_MASK :
769 TX4927_CCFG_PCIDIVMODE_MASK));
771 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
772 "PCI66 mode is %lx, PCI mode is %lx, pci arb is %lx\n",
773 (unsigned long) tx4927_ccfgptr->
774 ccfg & TX4927_CCFG_PCI66,
775 (unsigned long) tx4927_ccfgptr->
776 ccfg & TX4927_CCFG_PCIMIDE,
777 (unsigned long) tx4927_ccfgptr->
778 ccfg & TX4927_CCFG_PCIXARB);
780 if (mips_machtype == MACH_TOSHIBA_RBTX4937)
781 switch ((unsigned long)tx4927_ccfgptr->
782 ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
783 case TX4937_CCFG_PCIDIVMODE_8:
784 case TX4937_CCFG_PCIDIVMODE_4:
785 tx4927_cpu_clock = 266666666; /* 266MHz */
787 case TX4937_CCFG_PCIDIVMODE_9:
788 case TX4937_CCFG_PCIDIVMODE_4_5:
789 tx4927_cpu_clock = 300000000; /* 300MHz */
792 tx4927_cpu_clock = 333333333; /* 333MHz */
795 switch ((unsigned long)tx4927_ccfgptr->
796 ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
797 case TX4927_CCFG_PCIDIVMODE_2_5:
798 case TX4927_CCFG_PCIDIVMODE_5:
799 tx4927_cpu_clock = 166666666; /* 166MHz */
802 tx4927_cpu_clock = 200000000; /* 200MHz */
806 /* enable Timeout BusError */
807 if (tx4927_ccfg_toeon)
808 tx4927_ccfgptr->ccfg |= TX4927_CCFG_TOE;
811 if (tx4927_using_backplane == 1)
812 printk("backplane board IS installed\n");
814 printk("No Backplane \n");
816 /* this is on ISA bus behind PCI bus, so need PCI up first */
817 #ifdef CONFIG_TOSHIBA_FPCIB0
819 if (tx4927_using_backplane) {
820 TOSHIBA_RBTX4927_SETUP_DPRINTK
821 (TOSHIBA_RBTX4927_SETUP_SETUP,
824 TOSHIBA_RBTX4927_SETUP_DPRINTK
825 (TOSHIBA_RBTX4927_SETUP_SETUP,
826 ":smsc_fdc37m81x_init()\n");
827 smsc_fdc37m81x_init(0x3f0);
829 TOSHIBA_RBTX4927_SETUP_DPRINTK
830 (TOSHIBA_RBTX4927_SETUP_SETUP,
831 ":smsc_fdc37m81x_config_beg()\n");
832 smsc_fdc37m81x_config_beg();
834 TOSHIBA_RBTX4927_SETUP_DPRINTK
835 (TOSHIBA_RBTX4927_SETUP_SETUP,
836 ":smsc_fdc37m81x_config_set(KBD)\n");
837 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM,
839 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1);
840 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12);
841 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE,
844 smsc_fdc37m81x_config_end();
845 TOSHIBA_RBTX4927_SETUP_DPRINTK
846 (TOSHIBA_RBTX4927_SETUP_SETUP,
847 ":smsc_fdc37m81x_config_end()\n");
849 TOSHIBA_RBTX4927_SETUP_DPRINTK
850 (TOSHIBA_RBTX4927_SETUP_SETUP,
851 ":fpcibo=not_found\n");
856 TOSHIBA_RBTX4927_SETUP_DPRINTK
857 (TOSHIBA_RBTX4927_SETUP_SETUP, ":fpcibo=no\n");
861 #endif /* CONFIG_PCI */
863 #ifdef CONFIG_SERIAL_TXX9
865 extern int early_serial_txx9_setup(struct uart_port *port);
866 struct uart_port req;
867 for(i = 0; i < 2; i++) {
868 memset(&req, 0, sizeof(req));
870 req.iotype = UPIO_MEM;
871 req.membase = (char *)(0xff1ff300 + i * 0x100);
872 req.mapbase = 0xff1ff300 + i * 0x100;
873 req.irq = TX4927_IRQ_PIC_BEG + 8 + i;
874 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
875 req.uartclk = 50000000;
876 early_serial_txx9_setup(&req);
879 #ifdef CONFIG_SERIAL_TXX9_CONSOLE
880 argptr = prom_getcmdline();
881 if (strstr(argptr, "console=") == NULL) {
882 strcat(argptr, " console=ttyS0,38400");
887 #ifdef CONFIG_ROOT_NFS
888 argptr = prom_getcmdline();
889 if (strstr(argptr, "root=") == NULL) {
890 strcat(argptr, " root=/dev/nfs rw");
896 argptr = prom_getcmdline();
897 if (strstr(argptr, "ip=") == NULL) {
898 strcat(argptr, " ip=any");
903 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
907 void __init plat_time_init(void)
909 mips_hpt_frequency = tx4927_cpu_clock / 2;
910 if (tx4927_ccfgptr->ccfg & TX4927_CCFG_TINTDIS)
911 txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL,
916 static int __init toshiba_rbtx4927_rtc_init(void)
918 static struct resource __initdata res = {
920 .end = 0x1c010000 + 0x800 - 1,
921 .flags = IORESOURCE_MEM,
923 struct platform_device *dev =
924 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
925 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
927 device_initcall(toshiba_rbtx4927_rtc_init);
929 static int __init rbtx4927_ne_init(void)
931 static struct resource __initdata res[] = {
933 .start = RBTX4927_RTL_8019_BASE,
934 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
935 .flags = IORESOURCE_IO,
937 .start = RBTX4927_RTL_8019_IRQ,
938 .flags = IORESOURCE_IRQ,
941 struct platform_device *dev =
942 platform_device_register_simple("ne", -1,
943 res, ARRAY_SIZE(res));
944 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
946 device_initcall(rbtx4927_ne_init);