diff options
Diffstat (limited to 'arch/mips/txx9/generic')
-rw-r--r-- | arch/mips/txx9/generic/Makefile | 12 | ||||
-rw-r--r-- | arch/mips/txx9/generic/dbgio.c | 48 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4927.c | 37 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4938.c | 25 | ||||
-rw-r--r-- | arch/mips/txx9/generic/mem_tx4927.c | 141 | ||||
-rw-r--r-- | arch/mips/txx9/generic/mem_tx4938.c | 124 | ||||
-rw-r--r-- | arch/mips/txx9/generic/pci.c | 388 | ||||
-rw-r--r-- | arch/mips/txx9/generic/setup.c | 212 | ||||
-rw-r--r-- | arch/mips/txx9/generic/smsc_fdc37m81x.c | 172 |
9 files changed, 1159 insertions, 0 deletions
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile new file mode 100644 index 000000000000..668fdaad6448 --- /dev/null +++ b/arch/mips/txx9/generic/Makefile | |||
@@ -0,0 +1,12 @@ | |||
1 | # | ||
2 | # Makefile for common code for TXx9 based systems | ||
3 | # | ||
4 | |||
5 | obj-y += setup.o | ||
6 | obj-$(CONFIG_PCI) += pci.o | ||
7 | obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o irq_tx4927.o | ||
8 | obj-$(CONFIG_SOC_TX4938) += mem_tx4938.o irq_tx4938.o | ||
9 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o | ||
10 | obj-$(CONFIG_KGDB) += dbgio.o | ||
11 | |||
12 | EXTRA_CFLAGS += -Werror | ||
diff --git a/arch/mips/txx9/generic/dbgio.c b/arch/mips/txx9/generic/dbgio.c new file mode 100644 index 000000000000..33b9c672a322 --- /dev/null +++ b/arch/mips/txx9/generic/dbgio.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/dbgio.c | ||
3 | * | ||
4 | * kgdb interface for gdb | ||
5 | * | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * source@mvista.com | ||
8 | * | ||
9 | * Copyright 2005 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
24 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
25 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | * | ||
31 | * Support for TX4938 in 2.6 - Hiroshi DOYU <Hiroshi_DOYU@montavista.co.jp> | ||
32 | */ | ||
33 | |||
34 | #include <linux/types> | ||
35 | |||
36 | extern u8 txx9_sio_kdbg_rd(void); | ||
37 | extern int txx9_sio_kdbg_wr( u8 ch ); | ||
38 | |||
39 | u8 getDebugChar(void) | ||
40 | { | ||
41 | return (txx9_sio_kdbg_rd()); | ||
42 | } | ||
43 | |||
44 | int putDebugChar(u8 byte) | ||
45 | { | ||
46 | return (txx9_sio_kdbg_wr(byte)); | ||
47 | } | ||
48 | |||
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c new file mode 100644 index 000000000000..6377bd8a9050 --- /dev/null +++ b/arch/mips/txx9/generic/irq_tx4927.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Common tx4927 irq handler | ||
3 | * | ||
4 | * Author: MontaVista Software, Inc. | ||
5 | * source@mvista.com | ||
6 | * | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
12 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
13 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
14 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
15 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
16 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
17 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
18 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
19 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
20 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License along | ||
23 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <asm/irq_cpu.h> | ||
29 | #include <asm/txx9/tx4927.h> | ||
30 | |||
31 | void __init tx4927_irq_init(void) | ||
32 | { | ||
33 | mips_cpu_irq_init(); | ||
34 | txx9_irq_init(TX4927_IRC_REG); | ||
35 | set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT, | ||
36 | handle_simple_irq); | ||
37 | } | ||
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c new file mode 100644 index 000000000000..5fc86c9c9d2f --- /dev/null +++ b/arch/mips/txx9/generic/irq_tx4938.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/irq.c | ||
3 | * | ||
4 | * Common tx4938 irq handler | ||
5 | * Copyright (C) 2000-2001 Toshiba Corporation | ||
6 | * | ||
7 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the | ||
8 | * terms of the GNU General Public License version 2. This program is | ||
9 | * licensed "as is" without any warranty of any kind, whether express | ||
10 | * or implied. | ||
11 | * | ||
12 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) | ||
13 | */ | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <asm/irq_cpu.h> | ||
17 | #include <asm/txx9/tx4938.h> | ||
18 | |||
19 | void __init tx4938_irq_init(void) | ||
20 | { | ||
21 | mips_cpu_irq_init(); | ||
22 | txx9_irq_init(TX4938_IRC_REG); | ||
23 | set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT, | ||
24 | handle_simple_irq); | ||
25 | } | ||
diff --git a/arch/mips/txx9/generic/mem_tx4927.c b/arch/mips/txx9/generic/mem_tx4927.c new file mode 100644 index 000000000000..12dfc377bf2f --- /dev/null +++ b/arch/mips/txx9/generic/mem_tx4927.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4927/common/tx4927_prom.c | ||
3 | * | ||
4 | * common tx4927 memory interface | ||
5 | * | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * source@mvista.com | ||
8 | * | ||
9 | * Copyright 2001-2002 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
24 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
25 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | */ | ||
31 | |||
32 | #include <linux/init.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/io.h> | ||
35 | |||
36 | static unsigned int __init tx4927_process_sdccr(unsigned long addr) | ||
37 | { | ||
38 | u64 val; | ||
39 | unsigned int sdccr_ce; | ||
40 | unsigned int sdccr_bs; | ||
41 | unsigned int sdccr_rs; | ||
42 | unsigned int sdccr_cs; | ||
43 | unsigned int sdccr_mw; | ||
44 | unsigned int bs = 0; | ||
45 | unsigned int rs = 0; | ||
46 | unsigned int cs = 0; | ||
47 | unsigned int mw = 0; | ||
48 | unsigned int msize = 0; | ||
49 | |||
50 | val = __raw_readq((void __iomem *)addr); | ||
51 | |||
52 | /* MVMCP -- need #defs for these bits masks */ | ||
53 | sdccr_ce = ((val & (1 << 10)) >> 10); | ||
54 | sdccr_bs = ((val & (1 << 8)) >> 8); | ||
55 | sdccr_rs = ((val & (3 << 5)) >> 5); | ||
56 | sdccr_cs = ((val & (3 << 2)) >> 2); | ||
57 | sdccr_mw = ((val & (1 << 0)) >> 0); | ||
58 | |||
59 | if (sdccr_ce) { | ||
60 | switch (sdccr_bs) { | ||
61 | case 0:{ | ||
62 | bs = 2; | ||
63 | break; | ||
64 | } | ||
65 | case 1:{ | ||
66 | bs = 4; | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | switch (sdccr_rs) { | ||
71 | case 0:{ | ||
72 | rs = 2048; | ||
73 | break; | ||
74 | } | ||
75 | case 1:{ | ||
76 | rs = 4096; | ||
77 | break; | ||
78 | } | ||
79 | case 2:{ | ||
80 | rs = 8192; | ||
81 | break; | ||
82 | } | ||
83 | case 3:{ | ||
84 | rs = 0; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | switch (sdccr_cs) { | ||
89 | case 0:{ | ||
90 | cs = 256; | ||
91 | break; | ||
92 | } | ||
93 | case 1:{ | ||
94 | cs = 512; | ||
95 | break; | ||
96 | } | ||
97 | case 2:{ | ||
98 | cs = 1024; | ||
99 | break; | ||
100 | } | ||
101 | case 3:{ | ||
102 | cs = 2048; | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | switch (sdccr_mw) { | ||
107 | case 0:{ | ||
108 | mw = 8; | ||
109 | break; | ||
110 | } /* 8 bytes = 64 bits */ | ||
111 | case 1:{ | ||
112 | mw = 4; | ||
113 | break; | ||
114 | } /* 4 bytes = 32 bits */ | ||
115 | } | ||
116 | } | ||
117 | |||
118 | /* bytes per chip MB per chip num chips */ | ||
119 | msize = (((rs * cs * mw) / (1024 * 1024)) * bs); | ||
120 | |||
121 | return (msize); | ||
122 | } | ||
123 | |||
124 | |||
125 | unsigned int __init tx4927_get_mem_size(void) | ||
126 | { | ||
127 | unsigned int c0; | ||
128 | unsigned int c1; | ||
129 | unsigned int c2; | ||
130 | unsigned int c3; | ||
131 | unsigned int total; | ||
132 | |||
133 | /* MVMCP -- need #defs for these registers */ | ||
134 | c0 = tx4927_process_sdccr(0xff1f8000); | ||
135 | c1 = tx4927_process_sdccr(0xff1f8008); | ||
136 | c2 = tx4927_process_sdccr(0xff1f8010); | ||
137 | c3 = tx4927_process_sdccr(0xff1f8018); | ||
138 | total = c0 + c1 + c2 + c3; | ||
139 | |||
140 | return (total); | ||
141 | } | ||
diff --git a/arch/mips/txx9/generic/mem_tx4938.c b/arch/mips/txx9/generic/mem_tx4938.c new file mode 100644 index 000000000000..20baeaeba4cd --- /dev/null +++ b/arch/mips/txx9/generic/mem_tx4938.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/prom.c | ||
3 | * | ||
4 | * common tx4938 memory interface | ||
5 | * Copyright (C) 2000-2001 Toshiba Corporation | ||
6 | * | ||
7 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the | ||
8 | * terms of the GNU General Public License version 2. This program is | ||
9 | * licensed "as is" without any warranty of any kind, whether express | ||
10 | * or implied. | ||
11 | * | ||
12 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/io.h> | ||
18 | |||
19 | static unsigned int __init | ||
20 | tx4938_process_sdccr(u64 * addr) | ||
21 | { | ||
22 | u64 val; | ||
23 | unsigned int sdccr_ce; | ||
24 | unsigned int sdccr_rs; | ||
25 | unsigned int sdccr_cs; | ||
26 | unsigned int sdccr_mw; | ||
27 | unsigned int rs = 0; | ||
28 | unsigned int cs = 0; | ||
29 | unsigned int mw = 0; | ||
30 | unsigned int bc = 4; | ||
31 | unsigned int msize = 0; | ||
32 | |||
33 | val = ____raw_readq((void __iomem *)addr); | ||
34 | |||
35 | /* MVMCP -- need #defs for these bits masks */ | ||
36 | sdccr_ce = ((val & (1 << 10)) >> 10); | ||
37 | sdccr_rs = ((val & (3 << 5)) >> 5); | ||
38 | sdccr_cs = ((val & (7 << 2)) >> 2); | ||
39 | sdccr_mw = ((val & (1 << 0)) >> 0); | ||
40 | |||
41 | if (sdccr_ce) { | ||
42 | switch (sdccr_rs) { | ||
43 | case 0:{ | ||
44 | rs = 2048; | ||
45 | break; | ||
46 | } | ||
47 | case 1:{ | ||
48 | rs = 4096; | ||
49 | break; | ||
50 | } | ||
51 | case 2:{ | ||
52 | rs = 8192; | ||
53 | break; | ||
54 | } | ||
55 | default:{ | ||
56 | rs = 0; | ||
57 | break; | ||
58 | } | ||
59 | } | ||
60 | switch (sdccr_cs) { | ||
61 | case 0:{ | ||
62 | cs = 256; | ||
63 | break; | ||
64 | } | ||
65 | case 1:{ | ||
66 | cs = 512; | ||
67 | break; | ||
68 | } | ||
69 | case 2:{ | ||
70 | cs = 1024; | ||
71 | break; | ||
72 | } | ||
73 | case 3:{ | ||
74 | cs = 2048; | ||
75 | break; | ||
76 | } | ||
77 | case 4:{ | ||
78 | cs = 4096; | ||
79 | break; | ||
80 | } | ||
81 | default:{ | ||
82 | cs = 0; | ||
83 | break; | ||
84 | } | ||
85 | } | ||
86 | switch (sdccr_mw) { | ||
87 | case 0:{ | ||
88 | mw = 8; | ||
89 | break; | ||
90 | } /* 8 bytes = 64 bits */ | ||
91 | case 1:{ | ||
92 | mw = 4; | ||
93 | break; | ||
94 | } /* 4 bytes = 32 bits */ | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /* bytes per chip MB per chip bank count */ | ||
99 | msize = (((rs * cs * mw) / (1024 * 1024)) * (bc)); | ||
100 | |||
101 | /* MVMCP -- bc hard coded to 4 from table 9.3.1 */ | ||
102 | /* boad supports bc=2 but no way to detect */ | ||
103 | |||
104 | return (msize); | ||
105 | } | ||
106 | |||
107 | unsigned int __init | ||
108 | tx4938_get_mem_size(void) | ||
109 | { | ||
110 | unsigned int c0; | ||
111 | unsigned int c1; | ||
112 | unsigned int c2; | ||
113 | unsigned int c3; | ||
114 | unsigned int total; | ||
115 | |||
116 | /* MVMCP -- need #defs for these registers */ | ||
117 | c0 = tx4938_process_sdccr((u64 *) 0xff1f8000); | ||
118 | c1 = tx4938_process_sdccr((u64 *) 0xff1f8008); | ||
119 | c2 = tx4938_process_sdccr((u64 *) 0xff1f8010); | ||
120 | c3 = tx4938_process_sdccr((u64 *) 0xff1f8018); | ||
121 | total = c0 + c1 + c2 + c3; | ||
122 | |||
123 | return (total); | ||
124 | } | ||
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c new file mode 100644 index 000000000000..0b92d8c13208 --- /dev/null +++ b/arch/mips/txx9/generic/pci.c | |||
@@ -0,0 +1,388 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/txx9/pci.c | ||
3 | * | ||
4 | * Based on linux/arch/mips/txx9/rbtx4927/setup.c, | ||
5 | * linux/arch/mips/txx9/rbtx4938/setup.c, | ||
6 | * and RBTX49xx patch from CELF patch archive. | ||
7 | * | ||
8 | * Copyright 2001-2005 MontaVista Software Inc. | ||
9 | * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org) | ||
10 | * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007 | ||
11 | * | ||
12 | * This file is subject to the terms and conditions of the GNU General Public | ||
13 | * License. See the file "COPYING" in the main directory of this archive | ||
14 | * for more details. | ||
15 | */ | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/jiffies.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <asm/txx9/generic.h> | ||
20 | #include <asm/txx9/pci.h> | ||
21 | #ifdef CONFIG_TOSHIBA_FPCIB0 | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <asm/i8259.h> | ||
24 | #include <asm/txx9/smsc_fdc37m81x.h> | ||
25 | #endif | ||
26 | |||
27 | static int __init | ||
28 | early_read_config_word(struct pci_controller *hose, | ||
29 | int top_bus, int bus, int devfn, int offset, u16 *value) | ||
30 | { | ||
31 | struct pci_dev fake_dev; | ||
32 | struct pci_bus fake_bus; | ||
33 | |||
34 | fake_dev.bus = &fake_bus; | ||
35 | fake_dev.sysdata = hose; | ||
36 | fake_dev.devfn = devfn; | ||
37 | fake_bus.number = bus; | ||
38 | fake_bus.sysdata = hose; | ||
39 | fake_bus.ops = hose->pci_ops; | ||
40 | |||
41 | if (bus != top_bus) | ||
42 | /* Fake a parent bus structure. */ | ||
43 | fake_bus.parent = &fake_bus; | ||
44 | else | ||
45 | fake_bus.parent = NULL; | ||
46 | |||
47 | return pci_read_config_word(&fake_dev, offset, value); | ||
48 | } | ||
49 | |||
50 | int __init txx9_pci66_check(struct pci_controller *hose, int top_bus, | ||
51 | int current_bus) | ||
52 | { | ||
53 | u32 pci_devfn; | ||
54 | unsigned short vid; | ||
55 | int cap66 = -1; | ||
56 | u16 stat; | ||
57 | |||
58 | /* It seems SLC90E66 needs some time after PCI reset... */ | ||
59 | mdelay(80); | ||
60 | |||
61 | printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n"); | ||
62 | |||
63 | for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) { | ||
64 | if (PCI_FUNC(pci_devfn)) | ||
65 | continue; | ||
66 | if (early_read_config_word(hose, top_bus, current_bus, | ||
67 | pci_devfn, PCI_VENDOR_ID, &vid) != | ||
68 | PCIBIOS_SUCCESSFUL) | ||
69 | continue; | ||
70 | if (vid == 0xffff) | ||
71 | continue; | ||
72 | |||
73 | /* check 66MHz capability */ | ||
74 | if (cap66 < 0) | ||
75 | cap66 = 1; | ||
76 | if (cap66) { | ||
77 | early_read_config_word(hose, top_bus, current_bus, | ||
78 | pci_devfn, PCI_STATUS, &stat); | ||
79 | if (!(stat & PCI_STATUS_66MHZ)) { | ||
80 | printk(KERN_DEBUG | ||
81 | "PCI: %02x:%02x not 66MHz capable.\n", | ||
82 | current_bus, pci_devfn); | ||
83 | cap66 = 0; | ||
84 | break; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | return cap66 > 0; | ||
89 | } | ||
90 | |||
91 | static struct resource primary_pci_mem_res[2] = { | ||
92 | { .name = "PCI MEM" }, | ||
93 | { .name = "PCI MMIO" }, | ||
94 | }; | ||
95 | static struct resource primary_pci_io_res = { .name = "PCI IO" }; | ||
96 | struct pci_controller txx9_primary_pcic = { | ||
97 | .mem_resource = &primary_pci_mem_res[0], | ||
98 | .io_resource = &primary_pci_io_res, | ||
99 | }; | ||
100 | |||
101 | #ifdef CONFIG_64BIT | ||
102 | int txx9_pci_mem_high __initdata = 1; | ||
103 | #else | ||
104 | int txx9_pci_mem_high __initdata; | ||
105 | #endif | ||
106 | |||
107 | /* | ||
108 | * allocate pci_controller and resources. | ||
109 | * mem_base, io_base: physical addresss. 0 for auto assignment. | ||
110 | * mem_size and io_size means max size on auto assignment. | ||
111 | * pcic must be &txx9_primary_pcic or NULL. | ||
112 | */ | ||
113 | struct pci_controller *__init | ||
114 | txx9_alloc_pci_controller(struct pci_controller *pcic, | ||
115 | unsigned long mem_base, unsigned long mem_size, | ||
116 | unsigned long io_base, unsigned long io_size) | ||
117 | { | ||
118 | struct pcic { | ||
119 | struct pci_controller c; | ||
120 | struct resource r_mem[2]; | ||
121 | struct resource r_io; | ||
122 | } *new = NULL; | ||
123 | int min_size = 0x10000; | ||
124 | |||
125 | if (!pcic) { | ||
126 | new = kzalloc(sizeof(*new), GFP_KERNEL); | ||
127 | if (!new) | ||
128 | return NULL; | ||
129 | new->r_mem[0].name = "PCI mem"; | ||
130 | new->r_mem[1].name = "PCI mmio"; | ||
131 | new->r_io.name = "PCI io"; | ||
132 | new->c.mem_resource = new->r_mem; | ||
133 | new->c.io_resource = &new->r_io; | ||
134 | pcic = &new->c; | ||
135 | } else | ||
136 | BUG_ON(pcic != &txx9_primary_pcic); | ||
137 | pcic->io_resource->flags = IORESOURCE_IO; | ||
138 | |||
139 | /* | ||
140 | * for auto assignment, first search a (big) region for PCI | ||
141 | * MEM, then search a region for PCI IO. | ||
142 | */ | ||
143 | if (mem_base) { | ||
144 | pcic->mem_resource[0].start = mem_base; | ||
145 | pcic->mem_resource[0].end = mem_base + mem_size - 1; | ||
146 | if (request_resource(&iomem_resource, &pcic->mem_resource[0])) | ||
147 | goto free_and_exit; | ||
148 | } else { | ||
149 | unsigned long min = 0, max = 0x20000000; /* low 512MB */ | ||
150 | if (!mem_size) { | ||
151 | /* default size for auto assignment */ | ||
152 | if (txx9_pci_mem_high) | ||
153 | mem_size = 0x20000000; /* mem:512M(max) */ | ||
154 | else | ||
155 | mem_size = 0x08000000; /* mem:128M(max) */ | ||
156 | } | ||
157 | if (txx9_pci_mem_high) { | ||
158 | min = 0x20000000; | ||
159 | max = 0xe0000000; | ||
160 | } | ||
161 | /* search free region for PCI MEM */ | ||
162 | for (; mem_size >= min_size; mem_size /= 2) { | ||
163 | if (allocate_resource(&iomem_resource, | ||
164 | &pcic->mem_resource[0], | ||
165 | mem_size, min, max, | ||
166 | mem_size, NULL, NULL) == 0) | ||
167 | break; | ||
168 | } | ||
169 | if (mem_size < min_size) | ||
170 | goto free_and_exit; | ||
171 | } | ||
172 | |||
173 | pcic->mem_resource[1].flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
174 | if (io_base) { | ||
175 | pcic->mem_resource[1].start = io_base; | ||
176 | pcic->mem_resource[1].end = io_base + io_size - 1; | ||
177 | if (request_resource(&iomem_resource, &pcic->mem_resource[1])) | ||
178 | goto release_and_exit; | ||
179 | } else { | ||
180 | if (!io_size) | ||
181 | /* default size for auto assignment */ | ||
182 | io_size = 0x01000000; /* io:16M(max) */ | ||
183 | /* search free region for PCI IO in low 512MB */ | ||
184 | for (; io_size >= min_size; io_size /= 2) { | ||
185 | if (allocate_resource(&iomem_resource, | ||
186 | &pcic->mem_resource[1], | ||
187 | io_size, 0, 0x20000000, | ||
188 | io_size, NULL, NULL) == 0) | ||
189 | break; | ||
190 | } | ||
191 | if (io_size < min_size) | ||
192 | goto release_and_exit; | ||
193 | io_base = pcic->mem_resource[1].start; | ||
194 | } | ||
195 | |||
196 | pcic->mem_resource[0].flags = IORESOURCE_MEM; | ||
197 | if (pcic == &txx9_primary_pcic && | ||
198 | mips_io_port_base == (unsigned long)-1) { | ||
199 | /* map ioport 0 to PCI I/O space address 0 */ | ||
200 | set_io_port_base(IO_BASE + pcic->mem_resource[1].start); | ||
201 | pcic->io_resource->start = 0; | ||
202 | pcic->io_offset = 0; /* busaddr == ioaddr */ | ||
203 | pcic->io_map_base = IO_BASE + pcic->mem_resource[1].start; | ||
204 | } else { | ||
205 | /* physaddr to ioaddr */ | ||
206 | pcic->io_resource->start = | ||
207 | io_base - (mips_io_port_base - IO_BASE); | ||
208 | pcic->io_offset = io_base - (mips_io_port_base - IO_BASE); | ||
209 | pcic->io_map_base = mips_io_port_base; | ||
210 | } | ||
211 | pcic->io_resource->end = pcic->io_resource->start + io_size - 1; | ||
212 | |||
213 | pcic->mem_offset = 0; /* busaddr == physaddr */ | ||
214 | |||
215 | printk(KERN_INFO "PCI: IO 0x%08llx-0x%08llx MEM 0x%08llx-0x%08llx\n", | ||
216 | (unsigned long long)pcic->mem_resource[1].start, | ||
217 | (unsigned long long)pcic->mem_resource[1].end, | ||
218 | (unsigned long long)pcic->mem_resource[0].start, | ||
219 | (unsigned long long)pcic->mem_resource[0].end); | ||
220 | |||
221 | /* register_pci_controller() will request MEM resource */ | ||
222 | release_resource(&pcic->mem_resource[0]); | ||
223 | return pcic; | ||
224 | release_and_exit: | ||
225 | release_resource(&pcic->mem_resource[0]); | ||
226 | free_and_exit: | ||
227 | kfree(new); | ||
228 | printk(KERN_ERR "PCI: Failed to allocate resources.\n"); | ||
229 | return NULL; | ||
230 | } | ||
231 | |||
232 | static int __init | ||
233 | txx9_arch_pci_init(void) | ||
234 | { | ||
235 | PCIBIOS_MIN_IO = 0x8000; /* reseve legacy I/O space */ | ||
236 | return 0; | ||
237 | } | ||
238 | arch_initcall(txx9_arch_pci_init); | ||
239 | |||
240 | /* IRQ/IDSEL mapping */ | ||
241 | int txx9_pci_option = | ||
242 | #ifdef CONFIG_PICMG_PCI_BACKPLANE_DEFAULT | ||
243 | TXX9_PCI_OPT_PICMG | | ||
244 | #endif | ||
245 | TXX9_PCI_OPT_CLK_AUTO; | ||
246 | |||
247 | enum txx9_pci_err_action txx9_pci_err_action = TXX9_PCI_ERR_REPORT; | ||
248 | |||
249 | #ifdef CONFIG_TOSHIBA_FPCIB0 | ||
250 | static irqreturn_t i8259_interrupt(int irq, void *dev_id) | ||
251 | { | ||
252 | int isairq; | ||
253 | |||
254 | isairq = i8259_irq(); | ||
255 | if (unlikely(isairq <= I8259A_IRQ_BASE)) | ||
256 | return IRQ_NONE; | ||
257 | generic_handle_irq(isairq); | ||
258 | return IRQ_HANDLED; | ||
259 | } | ||
260 | |||
261 | static int __init | ||
262 | txx9_i8259_irq_setup(int irq) | ||
263 | { | ||
264 | int err; | ||
265 | |||
266 | init_i8259_irqs(); | ||
267 | err = request_irq(irq, &i8259_interrupt, IRQF_DISABLED|IRQF_SHARED, | ||
268 | "cascade(i8259)", (void *)(long)irq); | ||
269 | if (!err) | ||
270 | printk(KERN_INFO "PCI-ISA bridge PIC (irq %d)\n", irq); | ||
271 | return err; | ||
272 | } | ||
273 | |||
274 | static void __init quirk_slc90e66_bridge(struct pci_dev *dev) | ||
275 | { | ||
276 | int irq; /* PCI/ISA Bridge interrupt */ | ||
277 | u8 reg_64; | ||
278 | u32 reg_b0; | ||
279 | u8 reg_e1; | ||
280 | irq = pcibios_map_irq(dev, PCI_SLOT(dev->devfn), 1); /* INTA */ | ||
281 | if (!irq) | ||
282 | return; | ||
283 | txx9_i8259_irq_setup(irq); | ||
284 | pci_read_config_byte(dev, 0x64, ®_64); | ||
285 | pci_read_config_dword(dev, 0xb0, ®_b0); | ||
286 | pci_read_config_byte(dev, 0xe1, ®_e1); | ||
287 | /* serial irq control */ | ||
288 | reg_64 = 0xd0; | ||
289 | /* serial irq pin */ | ||
290 | reg_b0 |= 0x00010000; | ||
291 | /* ide irq on isa14 */ | ||
292 | reg_e1 &= 0xf0; | ||
293 | reg_e1 |= 0x0d; | ||
294 | pci_write_config_byte(dev, 0x64, reg_64); | ||
295 | pci_write_config_dword(dev, 0xb0, reg_b0); | ||
296 | pci_write_config_byte(dev, 0xe1, reg_e1); | ||
297 | |||
298 | smsc_fdc37m81x_init(0x3f0); | ||
299 | smsc_fdc37m81x_config_beg(); | ||
300 | smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM, | ||
301 | SMSC_FDC37M81X_KBD); | ||
302 | smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1); | ||
303 | smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12); | ||
304 | smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE, | ||
305 | 1); | ||
306 | smsc_fdc37m81x_config_end(); | ||
307 | } | ||
308 | |||
309 | static void quirk_slc90e66_ide(struct pci_dev *dev) | ||
310 | { | ||
311 | unsigned char dat; | ||
312 | int regs[2] = {0x41, 0x43}; | ||
313 | int i; | ||
314 | |||
315 | /* SMSC SLC90E66 IDE uses irq 14, 15 (default) */ | ||
316 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 14); | ||
317 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &dat); | ||
318 | printk(KERN_INFO "PCI: %s: IRQ %02x", pci_name(dev), dat); | ||
319 | /* enable SMSC SLC90E66 IDE */ | ||
320 | for (i = 0; i < ARRAY_SIZE(regs); i++) { | ||
321 | pci_read_config_byte(dev, regs[i], &dat); | ||
322 | pci_write_config_byte(dev, regs[i], dat | 0x80); | ||
323 | pci_read_config_byte(dev, regs[i], &dat); | ||
324 | printk(KERN_CONT " IDETIM%d %02x", i, dat); | ||
325 | } | ||
326 | pci_read_config_byte(dev, 0x5c, &dat); | ||
327 | /* | ||
328 | * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!! | ||
329 | * | ||
330 | * This line of code is intended to provide the user with a work | ||
331 | * around solution to the anomalies cited in SMSC's anomaly sheet | ||
332 | * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"". | ||
333 | * | ||
334 | * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!! | ||
335 | */ | ||
336 | dat |= 0x01; | ||
337 | pci_write_config_byte(dev, regs[i], dat); | ||
338 | pci_read_config_byte(dev, 0x5c, &dat); | ||
339 | printk(KERN_CONT " REG5C %02x", dat); | ||
340 | printk(KERN_CONT "\n"); | ||
341 | } | ||
342 | #endif /* CONFIG_TOSHIBA_FPCIB0 */ | ||
343 | |||
344 | static void final_fixup(struct pci_dev *dev) | ||
345 | { | ||
346 | unsigned char bist; | ||
347 | |||
348 | /* Do build-in self test */ | ||
349 | if (pci_read_config_byte(dev, PCI_BIST, &bist) == PCIBIOS_SUCCESSFUL && | ||
350 | (bist & PCI_BIST_CAPABLE)) { | ||
351 | unsigned long timeout; | ||
352 | pci_set_power_state(dev, PCI_D0); | ||
353 | printk(KERN_INFO "PCI: %s BIST...", pci_name(dev)); | ||
354 | pci_write_config_byte(dev, PCI_BIST, PCI_BIST_START); | ||
355 | timeout = jiffies + HZ * 2; /* timeout after 2 sec */ | ||
356 | do { | ||
357 | pci_read_config_byte(dev, PCI_BIST, &bist); | ||
358 | if (time_after(jiffies, timeout)) | ||
359 | break; | ||
360 | } while (bist & PCI_BIST_START); | ||
361 | if (bist & (PCI_BIST_CODE_MASK | PCI_BIST_START)) | ||
362 | printk(KERN_CONT "failed. (0x%x)\n", bist); | ||
363 | else | ||
364 | printk(KERN_CONT "OK.\n"); | ||
365 | } | ||
366 | } | ||
367 | |||
368 | #ifdef CONFIG_TOSHIBA_FPCIB0 | ||
369 | #define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460 | ||
370 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_0, | ||
371 | quirk_slc90e66_bridge); | ||
372 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1, | ||
373 | quirk_slc90e66_ide); | ||
374 | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1, | ||
375 | quirk_slc90e66_ide); | ||
376 | #endif | ||
377 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, final_fixup); | ||
378 | DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, final_fixup); | ||
379 | |||
380 | int pcibios_plat_dev_init(struct pci_dev *dev) | ||
381 | { | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
386 | { | ||
387 | return txx9_board_vec->pci_map_irq(dev, slot, pin); | ||
388 | } | ||
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c new file mode 100644 index 000000000000..5afc5d5cab03 --- /dev/null +++ b/arch/mips/txx9/generic/setup.c | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/txx9/generic/setup.c | ||
3 | * | ||
4 | * Based on linux/arch/mips/txx9/rbtx4938/setup.c, | ||
5 | * and RBTX49xx patch from CELF patch archive. | ||
6 | * | ||
7 | * 2003-2005 (c) MontaVista Software, Inc. | ||
8 | * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007 | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General Public | ||
11 | * License. See the file "COPYING" in the main directory of this archive | ||
12 | * for more details. | ||
13 | */ | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/clk.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <asm/bootinfo.h> | ||
23 | #include <asm/txx9/generic.h> | ||
24 | #ifdef CONFIG_CPU_TX49XX | ||
25 | #include <asm/txx9/tx4938.h> | ||
26 | #endif | ||
27 | |||
28 | /* EBUSC settings of TX4927, etc. */ | ||
29 | struct resource txx9_ce_res[8]; | ||
30 | static char txx9_ce_res_name[8][4]; /* "CEn" */ | ||
31 | |||
32 | /* pcode, internal register */ | ||
33 | char txx9_pcode_str[8]; | ||
34 | static struct resource txx9_reg_res = { | ||
35 | .name = txx9_pcode_str, | ||
36 | .flags = IORESOURCE_MEM, | ||
37 | }; | ||
38 | void __init | ||
39 | txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size) | ||
40 | { | ||
41 | int i; | ||
42 | |||
43 | for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) { | ||
44 | sprintf(txx9_ce_res_name[i], "CE%d", i); | ||
45 | txx9_ce_res[i].flags = IORESOURCE_MEM; | ||
46 | txx9_ce_res[i].name = txx9_ce_res_name[i]; | ||
47 | } | ||
48 | |||
49 | sprintf(txx9_pcode_str, "TX%x", pcode); | ||
50 | if (base) { | ||
51 | txx9_reg_res.start = base & 0xfffffffffULL; | ||
52 | txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1); | ||
53 | request_resource(&iomem_resource, &txx9_reg_res); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | /* clocks */ | ||
58 | unsigned int txx9_master_clock; | ||
59 | unsigned int txx9_cpu_clock; | ||
60 | unsigned int txx9_gbus_clock; | ||
61 | |||
62 | |||
63 | /* Minimum CLK support */ | ||
64 | |||
65 | struct clk *clk_get(struct device *dev, const char *id) | ||
66 | { | ||
67 | if (!strcmp(id, "spi-baseclk")) | ||
68 | return (struct clk *)(txx9_gbus_clock / 2 / 4); | ||
69 | if (!strcmp(id, "imbus_clk")) | ||
70 | return (struct clk *)(txx9_gbus_clock / 2); | ||
71 | return ERR_PTR(-ENOENT); | ||
72 | } | ||
73 | EXPORT_SYMBOL(clk_get); | ||
74 | |||
75 | int clk_enable(struct clk *clk) | ||
76 | { | ||
77 | return 0; | ||
78 | } | ||
79 | EXPORT_SYMBOL(clk_enable); | ||
80 | |||
81 | void clk_disable(struct clk *clk) | ||
82 | { | ||
83 | } | ||
84 | EXPORT_SYMBOL(clk_disable); | ||
85 | |||
86 | unsigned long clk_get_rate(struct clk *clk) | ||
87 | { | ||
88 | return (unsigned long)clk; | ||
89 | } | ||
90 | EXPORT_SYMBOL(clk_get_rate); | ||
91 | |||
92 | void clk_put(struct clk *clk) | ||
93 | { | ||
94 | } | ||
95 | EXPORT_SYMBOL(clk_put); | ||
96 | |||
97 | extern struct txx9_board_vec jmr3927_vec; | ||
98 | extern struct txx9_board_vec rbtx4927_vec; | ||
99 | extern struct txx9_board_vec rbtx4937_vec; | ||
100 | extern struct txx9_board_vec rbtx4938_vec; | ||
101 | |||
102 | struct txx9_board_vec *txx9_board_vec __initdata; | ||
103 | static char txx9_system_type[32]; | ||
104 | |||
105 | void __init prom_init_cmdline(void) | ||
106 | { | ||
107 | int argc = (int)fw_arg0; | ||
108 | char **argv = (char **)fw_arg1; | ||
109 | int i; /* Always ignore the "-c" at argv[0] */ | ||
110 | |||
111 | /* ignore all built-in args if any f/w args given */ | ||
112 | if (argc > 1) | ||
113 | *arcs_cmdline = '\0'; | ||
114 | |||
115 | for (i = 1; i < argc; i++) { | ||
116 | if (i != 1) | ||
117 | strcat(arcs_cmdline, " "); | ||
118 | strcat(arcs_cmdline, argv[i]); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | void __init prom_init(void) | ||
123 | { | ||
124 | #ifdef CONFIG_CPU_TX39XX | ||
125 | txx9_board_vec = &jmr3927_vec; | ||
126 | #endif | ||
127 | #ifdef CONFIG_CPU_TX49XX | ||
128 | switch (TX4938_REV_PCODE()) { | ||
129 | case 0x4927: | ||
130 | txx9_board_vec = &rbtx4927_vec; | ||
131 | break; | ||
132 | case 0x4937: | ||
133 | txx9_board_vec = &rbtx4937_vec; | ||
134 | break; | ||
135 | case 0x4938: | ||
136 | txx9_board_vec = &rbtx4938_vec; | ||
137 | break; | ||
138 | } | ||
139 | #endif | ||
140 | |||
141 | strcpy(txx9_system_type, txx9_board_vec->system); | ||
142 | |||
143 | txx9_board_vec->prom_init(); | ||
144 | } | ||
145 | |||
146 | void __init prom_free_prom_memory(void) | ||
147 | { | ||
148 | } | ||
149 | |||
150 | const char *get_system_type(void) | ||
151 | { | ||
152 | return txx9_system_type; | ||
153 | } | ||
154 | |||
155 | char * __init prom_getcmdline(void) | ||
156 | { | ||
157 | return &(arcs_cmdline[0]); | ||
158 | } | ||
159 | |||
160 | /* wrappers */ | ||
161 | void __init plat_mem_setup(void) | ||
162 | { | ||
163 | txx9_board_vec->mem_setup(); | ||
164 | } | ||
165 | |||
166 | void __init arch_init_irq(void) | ||
167 | { | ||
168 | txx9_board_vec->irq_setup(); | ||
169 | } | ||
170 | |||
171 | void __init plat_time_init(void) | ||
172 | { | ||
173 | txx9_board_vec->time_init(); | ||
174 | } | ||
175 | |||
176 | static int __init _txx9_arch_init(void) | ||
177 | { | ||
178 | if (txx9_board_vec->arch_init) | ||
179 | txx9_board_vec->arch_init(); | ||
180 | return 0; | ||
181 | } | ||
182 | arch_initcall(_txx9_arch_init); | ||
183 | |||
184 | static int __init _txx9_device_init(void) | ||
185 | { | ||
186 | if (txx9_board_vec->device_init) | ||
187 | txx9_board_vec->device_init(); | ||
188 | return 0; | ||
189 | } | ||
190 | device_initcall(_txx9_device_init); | ||
191 | |||
192 | int (*txx9_irq_dispatch)(int pending); | ||
193 | asmlinkage void plat_irq_dispatch(void) | ||
194 | { | ||
195 | int pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
196 | int irq = txx9_irq_dispatch(pending); | ||
197 | |||
198 | if (likely(irq >= 0)) | ||
199 | do_IRQ(irq); | ||
200 | else | ||
201 | spurious_interrupt(); | ||
202 | } | ||
203 | |||
204 | /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */ | ||
205 | #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B | ||
206 | static unsigned long __swizzle_addr_none(unsigned long port) | ||
207 | { | ||
208 | return port; | ||
209 | } | ||
210 | unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none; | ||
211 | EXPORT_SYMBOL(__swizzle_addr_b); | ||
212 | #endif | ||
diff --git a/arch/mips/txx9/generic/smsc_fdc37m81x.c b/arch/mips/txx9/generic/smsc_fdc37m81x.c new file mode 100644 index 000000000000..69e487467fa5 --- /dev/null +++ b/arch/mips/txx9/generic/smsc_fdc37m81x.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * Interface for smsc fdc48m81x Super IO chip | ||
3 | * | ||
4 | * Author: MontaVista Software, Inc. source@mvista.com | ||
5 | * | ||
6 | * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | * | ||
11 | * Copyright 2004 (c) MontaVista Software, Inc. | ||
12 | */ | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <asm/io.h> | ||
16 | #include <asm/txx9/smsc_fdc37m81x.h> | ||
17 | |||
18 | #define DEBUG | ||
19 | |||
20 | /* Common Registers */ | ||
21 | #define SMSC_FDC37M81X_CONFIG_INDEX 0x00 | ||
22 | #define SMSC_FDC37M81X_CONFIG_DATA 0x01 | ||
23 | #define SMSC_FDC37M81X_CONF 0x02 | ||
24 | #define SMSC_FDC37M81X_INDEX 0x03 | ||
25 | #define SMSC_FDC37M81X_DNUM 0x07 | ||
26 | #define SMSC_FDC37M81X_DID 0x20 | ||
27 | #define SMSC_FDC37M81X_DREV 0x21 | ||
28 | #define SMSC_FDC37M81X_PCNT 0x22 | ||
29 | #define SMSC_FDC37M81X_PMGT 0x23 | ||
30 | #define SMSC_FDC37M81X_OSC 0x24 | ||
31 | #define SMSC_FDC37M81X_CONFPA0 0x26 | ||
32 | #define SMSC_FDC37M81X_CONFPA1 0x27 | ||
33 | #define SMSC_FDC37M81X_TEST4 0x2B | ||
34 | #define SMSC_FDC37M81X_TEST5 0x2C | ||
35 | #define SMSC_FDC37M81X_TEST1 0x2D | ||
36 | #define SMSC_FDC37M81X_TEST2 0x2E | ||
37 | #define SMSC_FDC37M81X_TEST3 0x2F | ||
38 | |||
39 | /* Logical device numbers */ | ||
40 | #define SMSC_FDC37M81X_FDD 0x00 | ||
41 | #define SMSC_FDC37M81X_SERIAL1 0x04 | ||
42 | #define SMSC_FDC37M81X_SERIAL2 0x05 | ||
43 | #define SMSC_FDC37M81X_KBD 0x07 | ||
44 | |||
45 | /* Logical device Config Registers */ | ||
46 | #define SMSC_FDC37M81X_ACTIVE 0x30 | ||
47 | #define SMSC_FDC37M81X_BASEADDR0 0x60 | ||
48 | #define SMSC_FDC37M81X_BASEADDR1 0x61 | ||
49 | #define SMSC_FDC37M81X_INT 0x70 | ||
50 | #define SMSC_FDC37M81X_INT2 0x72 | ||
51 | #define SMSC_FDC37M81X_MODE 0xF0 | ||
52 | |||
53 | /* Chip Config Values */ | ||
54 | #define SMSC_FDC37M81X_CONFIG_ENTER 0x55 | ||
55 | #define SMSC_FDC37M81X_CONFIG_EXIT 0xaa | ||
56 | #define SMSC_FDC37M81X_CHIP_ID 0x4d | ||
57 | |||
58 | static unsigned long g_smsc_fdc37m81x_base = 0; | ||
59 | |||
60 | static inline unsigned char smsc_fdc37m81x_rd(unsigned char index) | ||
61 | { | ||
62 | outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
63 | |||
64 | return inb(g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA); | ||
65 | } | ||
66 | |||
67 | static inline void smsc_dc37m81x_wr(unsigned char index, unsigned char data) | ||
68 | { | ||
69 | outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
70 | outb(data, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA); | ||
71 | } | ||
72 | |||
73 | void smsc_fdc37m81x_config_beg(void) | ||
74 | { | ||
75 | if (g_smsc_fdc37m81x_base) { | ||
76 | outb(SMSC_FDC37M81X_CONFIG_ENTER, | ||
77 | g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void smsc_fdc37m81x_config_end(void) | ||
82 | { | ||
83 | if (g_smsc_fdc37m81x_base) | ||
84 | outb(SMSC_FDC37M81X_CONFIG_EXIT, | ||
85 | g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
86 | } | ||
87 | |||
88 | u8 smsc_fdc37m81x_config_get(u8 reg) | ||
89 | { | ||
90 | u8 val = 0; | ||
91 | |||
92 | if (g_smsc_fdc37m81x_base) | ||
93 | val = smsc_fdc37m81x_rd(reg); | ||
94 | |||
95 | return val; | ||
96 | } | ||
97 | |||
98 | void smsc_fdc37m81x_config_set(u8 reg, u8 val) | ||
99 | { | ||
100 | if (g_smsc_fdc37m81x_base) | ||
101 | smsc_dc37m81x_wr(reg, val); | ||
102 | } | ||
103 | |||
104 | unsigned long __init smsc_fdc37m81x_init(unsigned long port) | ||
105 | { | ||
106 | const int field = sizeof(unsigned long) * 2; | ||
107 | u8 chip_id; | ||
108 | |||
109 | if (g_smsc_fdc37m81x_base) | ||
110 | printk("smsc_fdc37m81x_init() stepping on old base=0x%0*lx\n", | ||
111 | field, g_smsc_fdc37m81x_base); | ||
112 | |||
113 | g_smsc_fdc37m81x_base = port; | ||
114 | |||
115 | smsc_fdc37m81x_config_beg(); | ||
116 | |||
117 | chip_id = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DID); | ||
118 | if (chip_id == SMSC_FDC37M81X_CHIP_ID) | ||
119 | smsc_fdc37m81x_config_end(); | ||
120 | else { | ||
121 | printk("smsc_fdc37m81x_init() unknow chip id 0x%02x\n", | ||
122 | chip_id); | ||
123 | g_smsc_fdc37m81x_base = 0; | ||
124 | } | ||
125 | |||
126 | return g_smsc_fdc37m81x_base; | ||
127 | } | ||
128 | |||
129 | #ifdef DEBUG | ||
130 | void smsc_fdc37m81x_config_dump_one(char *key, u8 dev, u8 reg) | ||
131 | { | ||
132 | printk("%s: dev=0x%02x reg=0x%02x val=0x%02x\n", key, dev, reg, | ||
133 | smsc_fdc37m81x_rd(reg)); | ||
134 | } | ||
135 | |||
136 | void smsc_fdc37m81x_config_dump(void) | ||
137 | { | ||
138 | u8 orig; | ||
139 | char *fname = "smsc_fdc37m81x_config_dump()"; | ||
140 | |||
141 | smsc_fdc37m81x_config_beg(); | ||
142 | |||
143 | orig = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DNUM); | ||
144 | |||
145 | printk("%s: common\n", fname); | ||
146 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
147 | SMSC_FDC37M81X_DNUM); | ||
148 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
149 | SMSC_FDC37M81X_DID); | ||
150 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
151 | SMSC_FDC37M81X_DREV); | ||
152 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
153 | SMSC_FDC37M81X_PCNT); | ||
154 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
155 | SMSC_FDC37M81X_PMGT); | ||
156 | |||
157 | printk("%s: keyboard\n", fname); | ||
158 | smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, SMSC_FDC37M81X_KBD); | ||
159 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
160 | SMSC_FDC37M81X_ACTIVE); | ||
161 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
162 | SMSC_FDC37M81X_INT); | ||
163 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
164 | SMSC_FDC37M81X_INT2); | ||
165 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
166 | SMSC_FDC37M81X_LDCR_F0); | ||
167 | |||
168 | smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, orig); | ||
169 | |||
170 | smsc_fdc37m81x_config_end(); | ||
171 | } | ||
172 | #endif | ||