diff options
author | Brian Murphy <brm@murphy.dk> | 2007-08-21 16:34:16 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-10-11 18:46:00 -0400 |
commit | 1f21d2bde0046e959b53756f74d96dfd040a803b (patch) | |
tree | 5ca1a0319982f1e665e57f22bd1dae1d90b07e35 /arch/mips/pci | |
parent | 0caf583398309398ec05fc76bff15c711e9f936d (diff) |
[MIPS] Add back support for LASAT platforms
Signed-off-by: Brian Murphy <brian@murphy.dk>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/pci')
-rw-r--r-- | arch/mips/pci/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/pci/ops-nile4.c | 147 | ||||
-rw-r--r-- | arch/mips/pci/pci-lasat.c | 91 |
3 files changed, 240 insertions, 0 deletions
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile index 4ee6800e67e6..ed0c07622baa 100644 --- a/arch/mips/pci/Makefile +++ b/arch/mips/pci/Makefile | |||
@@ -10,6 +10,7 @@ obj-y += pci.o | |||
10 | obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o | 10 | obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o |
11 | obj-$(CONFIG_PCI_GT64XXX_PCI0) += ops-gt64xxx_pci0.o | 11 | obj-$(CONFIG_PCI_GT64XXX_PCI0) += ops-gt64xxx_pci0.o |
12 | obj-$(CONFIG_MIPS_MSC) += ops-msc.o | 12 | obj-$(CONFIG_MIPS_MSC) += ops-msc.o |
13 | obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o | ||
13 | obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o | 14 | obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o |
14 | obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o | 15 | obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o |
15 | obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o | 16 | obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o |
@@ -19,6 +20,7 @@ obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o | |||
19 | # These are still pretty much in the old state, watch, go blind. | 20 | # These are still pretty much in the old state, watch, go blind. |
20 | # | 21 | # |
21 | obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o | 22 | obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o |
23 | obj-$(CONFIG_LASAT) += pci-lasat.o | ||
22 | obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o | 24 | obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o |
23 | obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o | 25 | obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o |
24 | obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o | 26 | obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o |
diff --git a/arch/mips/pci/ops-nile4.c b/arch/mips/pci/ops-nile4.c new file mode 100644 index 000000000000..b7f0fb0210f4 --- /dev/null +++ b/arch/mips/pci/ops-nile4.c | |||
@@ -0,0 +1,147 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/pci.h> | ||
4 | #include <asm/bootinfo.h> | ||
5 | |||
6 | #include <asm/lasat/lasat.h> | ||
7 | #include <asm/gt64120.h> | ||
8 | #include <asm/nile4.h> | ||
9 | |||
10 | #define PCI_ACCESS_READ 0 | ||
11 | #define PCI_ACCESS_WRITE 1 | ||
12 | |||
13 | #define LO(reg) (reg / 4) | ||
14 | #define HI(reg) (reg / 4 + 1) | ||
15 | |||
16 | volatile unsigned long *const vrc_pciregs = (void *) Vrc5074_BASE; | ||
17 | |||
18 | static DEFINE_SPINLOCK(nile4_pci_lock); | ||
19 | |||
20 | static int nile4_pcibios_config_access(unsigned char access_type, | ||
21 | struct pci_bus *bus, unsigned int devfn, int where, u32 *val) | ||
22 | { | ||
23 | unsigned char busnum = bus->number; | ||
24 | u32 adr, mask, err; | ||
25 | |||
26 | if ((busnum == 0) && (PCI_SLOT(devfn) > 8)) | ||
27 | /* The addressing scheme chosen leaves room for just | ||
28 | * 8 devices on the first busnum (besides the PCI | ||
29 | * controller itself) */ | ||
30 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
31 | |||
32 | if ((busnum == 0) && (devfn == PCI_DEVFN(0, 0))) { | ||
33 | /* Access controller registers directly */ | ||
34 | if (access_type == PCI_ACCESS_WRITE) { | ||
35 | vrc_pciregs[(0x200 + where) >> 2] = *val; | ||
36 | } else { | ||
37 | *val = vrc_pciregs[(0x200 + where) >> 2]; | ||
38 | } | ||
39 | return PCIBIOS_SUCCESSFUL; | ||
40 | } | ||
41 | |||
42 | /* Temporarily map PCI Window 1 to config space */ | ||
43 | mask = vrc_pciregs[LO(NILE4_PCIINIT1)]; | ||
44 | vrc_pciregs[LO(NILE4_PCIINIT1)] = 0x0000001a | (busnum ? 0x200 : 0); | ||
45 | |||
46 | /* Clear PCI Error register. This also clears the Error Type | ||
47 | * bits in the Control register */ | ||
48 | vrc_pciregs[LO(NILE4_PCIERR)] = 0; | ||
49 | vrc_pciregs[HI(NILE4_PCIERR)] = 0; | ||
50 | |||
51 | /* Setup address */ | ||
52 | if (busnum == 0) | ||
53 | adr = | ||
54 | KSEG1ADDR(PCI_WINDOW1) + | ||
55 | ((1 << (PCI_SLOT(devfn) + 15)) | (PCI_FUNC(devfn) << 8) | ||
56 | | (where & ~3)); | ||
57 | else | ||
58 | adr = KSEG1ADDR(PCI_WINDOW1) | (busnum << 16) | (devfn << 8) | | ||
59 | (where & ~3); | ||
60 | |||
61 | if (access_type == PCI_ACCESS_WRITE) | ||
62 | *(u32 *) adr = *val; | ||
63 | else | ||
64 | *val = *(u32 *) adr; | ||
65 | |||
66 | /* Check for master or target abort */ | ||
67 | err = (vrc_pciregs[HI(NILE4_PCICTRL)] >> 5) & 0x7; | ||
68 | |||
69 | /* Restore PCI Window 1 */ | ||
70 | vrc_pciregs[LO(NILE4_PCIINIT1)] = mask; | ||
71 | |||
72 | if (err) | ||
73 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
74 | |||
75 | return PCIBIOS_SUCCESSFUL; | ||
76 | } | ||
77 | |||
78 | static int nile4_pcibios_read(struct pci_bus *bus, unsigned int devfn, | ||
79 | int where, int size, u32 *val) | ||
80 | { | ||
81 | unsigned long flags; | ||
82 | u32 data = 0; | ||
83 | int err; | ||
84 | |||
85 | if ((size == 2) && (where & 1)) | ||
86 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
87 | else if ((size == 4) && (where & 3)) | ||
88 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
89 | |||
90 | spin_lock_irqsave(&nile4_pci_lock, flags); | ||
91 | err = nile4_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where, | ||
92 | &data); | ||
93 | spin_unlock_irqrestore(&nile4_pci_lock, flags); | ||
94 | |||
95 | if (err) | ||
96 | return err; | ||
97 | |||
98 | if (size == 1) | ||
99 | *val = (data >> ((where & 3) << 3)) & 0xff; | ||
100 | else if (size == 2) | ||
101 | *val = (data >> ((where & 3) << 3)) & 0xffff; | ||
102 | else | ||
103 | *val = data; | ||
104 | |||
105 | return PCIBIOS_SUCCESSFUL; | ||
106 | } | ||
107 | |||
108 | static int nile4_pcibios_write(struct pci_bus *bus, unsigned int devfn, | ||
109 | int where, int size, u32 val) | ||
110 | { | ||
111 | unsigned long flags; | ||
112 | u32 data = 0; | ||
113 | int err; | ||
114 | |||
115 | if ((size == 2) && (where & 1)) | ||
116 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
117 | else if ((size == 4) && (where & 3)) | ||
118 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
119 | |||
120 | spin_lock_irqsave(&nile4_pci_lock, flags); | ||
121 | err = nile4_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where, | ||
122 | &data); | ||
123 | spin_unlock_irqrestore(&nile4_pci_lock, flags); | ||
124 | |||
125 | if (err) | ||
126 | return err; | ||
127 | |||
128 | if (size == 1) | ||
129 | data = (data & ~(0xff << ((where & 3) << 3))) | | ||
130 | (val << ((where & 3) << 3)); | ||
131 | else if (size == 2) | ||
132 | data = (data & ~(0xffff << ((where & 3) << 3))) | | ||
133 | (val << ((where & 3) << 3)); | ||
134 | else | ||
135 | data = val; | ||
136 | |||
137 | if (nile4_pcibios_config_access | ||
138 | (PCI_ACCESS_WRITE, bus, devfn, where, &data)) | ||
139 | return -1; | ||
140 | |||
141 | return PCIBIOS_SUCCESSFUL; | ||
142 | } | ||
143 | |||
144 | struct pci_ops nile4_pci_ops = { | ||
145 | .read = nile4_pcibios_read, | ||
146 | .write = nile4_pcibios_write, | ||
147 | }; | ||
diff --git a/arch/mips/pci/pci-lasat.c b/arch/mips/pci/pci-lasat.c new file mode 100644 index 000000000000..5abd5c7119be --- /dev/null +++ b/arch/mips/pci/pci-lasat.c | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2000, 2001, 04 Keith M Wesolowski | ||
7 | */ | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/pci.h> | ||
11 | #include <linux/types.h> | ||
12 | #include <asm/bootinfo.h> | ||
13 | |||
14 | extern struct pci_ops nile4_pci_ops; | ||
15 | extern struct pci_ops gt64xxx_pci0_ops; | ||
16 | static struct resource lasat_pci_mem_resource = { | ||
17 | .name = "LASAT PCI MEM", | ||
18 | .start = 0x18000000, | ||
19 | .end = 0x19ffffff, | ||
20 | .flags = IORESOURCE_MEM, | ||
21 | }; | ||
22 | |||
23 | static struct resource lasat_pci_io_resource = { | ||
24 | .name = "LASAT PCI IO", | ||
25 | .start = 0x1a000000, | ||
26 | .end = 0x1bffffff, | ||
27 | .flags = IORESOURCE_IO, | ||
28 | }; | ||
29 | |||
30 | static struct pci_controller lasat_pci_controller = { | ||
31 | .mem_resource = &lasat_pci_mem_resource, | ||
32 | .io_resource = &lasat_pci_io_resource, | ||
33 | }; | ||
34 | |||
35 | static int __init lasat_pci_setup(void) | ||
36 | { | ||
37 | printk(KERN_DEBUG "PCI: starting\n"); | ||
38 | |||
39 | switch (mips_machtype) { | ||
40 | case MACH_LASAT_100: | ||
41 | lasat_pci_controller.pci_ops = >64xxx_pci0_ops; | ||
42 | break; | ||
43 | case MACH_LASAT_200: | ||
44 | lasat_pci_controller.pci_ops = &nile4_pci_ops; | ||
45 | break; | ||
46 | default: | ||
47 | panic("pcibios_init: mips_machtype incorrect"); | ||
48 | } | ||
49 | |||
50 | register_pci_controller(&lasat_pci_controller); | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | arch_initcall(lasat_pci_setup); | ||
56 | |||
57 | #define LASATINT_ETH1 0 | ||
58 | #define LASATINT_ETH0 1 | ||
59 | #define LASATINT_HDC 2 | ||
60 | #define LASATINT_COMP 3 | ||
61 | #define LASATINT_HDLC 4 | ||
62 | #define LASATINT_PCIA 5 | ||
63 | #define LASATINT_PCIB 6 | ||
64 | #define LASATINT_PCIC 7 | ||
65 | #define LASATINT_PCID 8 | ||
66 | |||
67 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
68 | { | ||
69 | switch (slot) { | ||
70 | case 1: | ||
71 | case 2: | ||
72 | case 3: | ||
73 | return LASATINT_PCIA + (((slot-1) + (pin-1)) % 4); | ||
74 | case 4: | ||
75 | return LASATINT_ETH1; /* Ethernet 1 (LAN 2) */ | ||
76 | case 5: | ||
77 | return LASATINT_ETH0; /* Ethernet 0 (LAN 1) */ | ||
78 | case 6: | ||
79 | return LASATINT_HDC; /* IDE controller */ | ||
80 | default: | ||
81 | return 0xff; /* Illegal */ | ||
82 | } | ||
83 | |||
84 | return -1; | ||
85 | } | ||
86 | |||
87 | /* Do platform specific device initialization at pci_enable_device() time */ | ||
88 | int pcibios_plat_dev_init(struct pci_dev *dev) | ||
89 | { | ||
90 | return 0; | ||
91 | } | ||