blob: aaa900596792db52eb6fdac89944e1bdd4c11146 [file] [log] [blame]
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +09001/*
2 * linux/arch/mips/pci/pci-tx4927.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
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
10 *
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.
14 */
15#include <linux/init.h>
16#include <linux/pci.h>
17#include <linux/kernel.h>
Atsushi Nemoto455cc252008-07-25 23:01:35 +090018#include <linux/interrupt.h>
Atsushi Nemoto89d63fe2008-07-11 00:33:08 +090019#include <asm/txx9/generic.h>
20#include <asm/txx9/tx4927.h>
21
22int __init tx4927_report_pciclk(void)
23{
24 int pciclk = 0;
25
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;
41 }
42 printk("Internal(%u.%uMHz)",
43 (pciclk + 50000) / 1000000,
44 ((pciclk + 50000) / 100000) % 10);
45 } else {
46 printk("External");
47 pciclk = -1;
48 }
49 printk("\n");
50 return pciclk;
51}
52
53int __init tx4927_pciclk66_setup(void)
54{
55 int pciclk;
56
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;
76 }
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;
84}
Atsushi Nemoto455cc252008-07-25 23:01:35 +090085
86void __init tx4927_setup_pcierr_irq(void)
87{
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");
93}