added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / mips / pci / pci-tx4927.c
blobaaa900596792db52eb6fdac89944e1bdd4c11146
1 /*
2 * linux/arch/mips/pci/pci-tx4927.c
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
7 * Copyright 2001, 2003-2005 MontaVista Software Inc.
8 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
15 #include <linux/init.h>
16 #include <linux/pci.h>
17 #include <linux/kernel.h>
18 #include <linux/interrupt.h>
19 #include <asm/txx9/generic.h>
20 #include <asm/txx9/tx4927.h>
22 int __init tx4927_report_pciclk(void)
24 int pciclk = 0;
26 printk(KERN_INFO "PCIC --%s PCICLK:",
27 (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66) ?
28 " PCI66" : "");
29 if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
30 u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
31 switch ((unsigned long)ccfg &
32 TX4927_CCFG_PCIDIVMODE_MASK) {
33 case TX4927_CCFG_PCIDIVMODE_2_5:
34 pciclk = txx9_cpu_clock * 2 / 5; break;
35 case TX4927_CCFG_PCIDIVMODE_3:
36 pciclk = txx9_cpu_clock / 3; break;
37 case TX4927_CCFG_PCIDIVMODE_5:
38 pciclk = txx9_cpu_clock / 5; break;
39 case TX4927_CCFG_PCIDIVMODE_6:
40 pciclk = txx9_cpu_clock / 6; break;
42 printk("Internal(%u.%uMHz)",
43 (pciclk + 50000) / 1000000,
44 ((pciclk + 50000) / 100000) % 10);
45 } else {
46 printk("External");
47 pciclk = -1;
49 printk("\n");
50 return pciclk;
53 int __init tx4927_pciclk66_setup(void)
55 int pciclk;
57 /* Assert M66EN */
58 tx4927_ccfg_set(TX4927_CCFG_PCI66);
59 /* Double PCICLK (if possible) */
60 if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
61 unsigned int pcidivmode = 0;
62 u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
63 pcidivmode = (unsigned long)ccfg &
64 TX4927_CCFG_PCIDIVMODE_MASK;
65 switch (pcidivmode) {
66 case TX4927_CCFG_PCIDIVMODE_5:
67 case TX4927_CCFG_PCIDIVMODE_2_5:
68 pcidivmode = TX4927_CCFG_PCIDIVMODE_2_5;
69 pciclk = txx9_cpu_clock * 2 / 5;
70 break;
71 case TX4927_CCFG_PCIDIVMODE_6:
72 case TX4927_CCFG_PCIDIVMODE_3:
73 default:
74 pcidivmode = TX4927_CCFG_PCIDIVMODE_3;
75 pciclk = txx9_cpu_clock / 3;
77 tx4927_ccfg_change(TX4927_CCFG_PCIDIVMODE_MASK,
78 pcidivmode);
79 printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
80 (unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg));
81 } else
82 pciclk = -1;
83 return pciclk;
86 void __init tx4927_setup_pcierr_irq(void)
88 if (request_irq(TXX9_IRQ_BASE + TX4927_IR_PCIERR,
89 tx4927_pcierr_interrupt,
90 IRQF_DISABLED, "PCI error",
91 (void *)TX4927_PCIC_REG))
92 printk(KERN_WARNING "Failed to request irq for PCIERR\n");