aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/drivers/pci/pci.c')
-rw-r--r--arch/sh/drivers/pci/pci.c105
1 files changed, 88 insertions, 17 deletions
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 3d546ba329cf..d439336d2e18 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -1,21 +1,45 @@
1/* arch/sh/kernel/pci.c 1/*
2 * $Id: pci.c,v 1.1 2003/08/24 19:15:45 lethal Exp $ 2 * arch/sh/drivers/pci/pci.c
3 * 3 *
4 * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org> 4 * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
5 * 5 * Copyright (c) 2004 - 2006 Paul Mundt <lethal@linux-sh.org>
6 * 6 *
7 * These functions are collected here to reduce duplication of common 7 * These functions are collected here to reduce duplication of common
8 * code amongst the many platform-specific PCI support code files. 8 * code amongst the many platform-specific PCI support code files.
9 * 9 *
10 * These routines require the following board-specific routines: 10 * These routines require the following board-specific routines:
11 * void pcibios_fixup_irqs(); 11 * void pcibios_fixup_irqs();
12 * 12 *
13 * See include/asm-sh/pci.h for more information. 13 * See include/asm-sh/pci.h for more information.
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
14 */ 18 */
15
16#include <linux/kernel.h> 19#include <linux/kernel.h>
17#include <linux/pci.h> 20#include <linux/pci.h>
18#include <linux/init.h> 21#include <linux/init.h>
22#include <asm/io.h>
23
24static inline u8 bridge_swizzle(u8 pin, u8 slot)
25{
26 return (((pin - 1) + slot) % 4) + 1;
27}
28
29static u8 __init simple_swizzle(struct pci_dev *dev, u8 *pinp)
30{
31 u8 pin = *pinp;
32
33 while (dev->bus->parent) {
34 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
35 /* Move up the chain of bridges. */
36 dev = dev->bus->self;
37 }
38 *pinp = pin;
39
40 /* The slot is the slot of the last bridge. */
41 return PCI_SLOT(dev->devfn);
42}
19 43
20static int __init pcibios_init(void) 44static int __init pcibios_init(void)
21{ 45{
@@ -26,26 +50,32 @@ static int __init pcibios_init(void)
26#ifdef CONFIG_PCI_AUTO 50#ifdef CONFIG_PCI_AUTO
27 /* assign resources */ 51 /* assign resources */
28 busno = 0; 52 busno = 0;
29 for (p = board_pci_channels; p->pci_ops != NULL; p++) { 53 for (p = board_pci_channels; p->pci_ops != NULL; p++)
30 busno = pciauto_assign_resources(busno, p) + 1; 54 busno = pciauto_assign_resources(busno, p) + 1;
31 }
32#endif 55#endif
33 56
34 /* scan the buses */ 57 /* scan the buses */
35 busno = 0; 58 busno = 0;
36 for (p= board_pci_channels; p->pci_ops != NULL; p++) { 59 for (p = board_pci_channels; p->pci_ops != NULL; p++) {
37 bus = pci_scan_bus(busno, p->pci_ops, p); 60 bus = pci_scan_bus(busno, p->pci_ops, p);
38 busno = bus->subordinate+1; 61 busno = bus->subordinate + 1;
39 } 62 }
40 63
41 /* board-specific fixups */ 64 pci_fixup_irqs(simple_swizzle, pcibios_map_platform_irq);
42 pcibios_fixup_irqs();
43 65
44 return 0; 66 return 0;
45} 67}
46
47subsys_initcall(pcibios_init); 68subsys_initcall(pcibios_init);
48 69
70/*
71 * Called after each bus is probed, but before its children
72 * are examined.
73 */
74void __init pcibios_fixup_bus(struct pci_bus *bus)
75{
76 pci_read_bridge_bases(bus);
77}
78
49void 79void
50pcibios_update_resource(struct pci_dev *dev, struct resource *root, 80pcibios_update_resource(struct pci_dev *dev, struct resource *root,
51 struct resource *res, int resource) 81 struct resource *res, int resource)
@@ -61,13 +91,17 @@ pcibios_update_resource(struct pci_dev *dev, struct resource *root,
61 new |= PCI_ROM_ADDRESS_ENABLE; 91 new |= PCI_ROM_ADDRESS_ENABLE;
62 reg = dev->rom_base_reg; 92 reg = dev->rom_base_reg;
63 } else { 93 } else {
64 /* Somebody might have asked allocation of a non-standard resource */ 94 /*
95 * Somebody might have asked allocation of a non-standard
96 * resource
97 */
65 return; 98 return;
66 } 99 }
67 100
68 pci_write_config_dword(dev, reg, new); 101 pci_write_config_dword(dev, reg, new);
69 pci_read_config_dword(dev, reg, &check); 102 pci_read_config_dword(dev, reg, &check);
70 if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) { 103 if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ?
104 PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
71 printk(KERN_ERR "PCI: Error while updating region " 105 printk(KERN_ERR "PCI: Error while updating region "
72 "%s/%d (%08x != %08x)\n", pci_name(dev), resource, 106 "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
73 new, check); 107 new, check);
@@ -145,7 +179,8 @@ void pcibios_set_master(struct pci_dev *dev)
145 lat = pcibios_max_latency; 179 lat = pcibios_max_latency;
146 else 180 else
147 return; 181 return;
148 printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat); 182 printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n",
183 pci_name(dev), lat);
149 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); 184 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
150} 185}
151 186
@@ -153,3 +188,39 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
153{ 188{
154 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 189 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
155} 190}
191
192void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
193{
194 unsigned long start = pci_resource_start(dev, bar);
195 unsigned long len = pci_resource_len(dev, bar);
196 unsigned long flags = pci_resource_flags(dev, bar);
197
198 if (unlikely(!len || !start))
199 return NULL;
200 if (maxlen && len > maxlen)
201 len = maxlen;
202
203 /*
204 * Presently the IORESOURCE_MEM case is a bit special, most
205 * SH7751 style PCI controllers have PCI memory at a fixed
206 * location in the address space where no remapping is desired
207 * (typically at 0xfd000000, but is_pci_memaddr() will know
208 * best). With the IORESOURCE_MEM case more care has to be taken
209 * to inhibit page table mapping for legacy cores, but this is
210 * punted off to __ioremap().
211 * -- PFM.
212 */
213 if (flags & IORESOURCE_IO)
214 return ioport_map(start, len);
215 if (flags & IORESOURCE_MEM)
216 return ioremap(start, len);
217
218 return NULL;
219}
220EXPORT_SYMBOL(pci_iomap);
221
222void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
223{
224 iounmap(addr);
225}
226EXPORT_SYMBOL(pci_iounmap);