added files
[bcm963xx.git] / kernel / linux / arch / mips / pci / fixup-bcm96348.c
1 /*
2 <:copyright-gpl 
3  Copyright 2002 Broadcom Corp. All Rights Reserved. 
4  
5  This program is free software; you can distribute it and/or modify it 
6  under the terms of the GNU General Public License (Version 2) as 
7  published by the Free Software Foundation. 
8  
9  This program is distributed in the hope it will be useful, but WITHOUT 
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
11  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
12  for more details. 
13  
14  You should have received a copy of the GNU General Public License along 
15  with this program; if not, write to the Free Software Foundation, Inc., 
16  59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
17 :>
18 */
19 #include <linux/init.h>
20 #include <linux/types.h>
21 #include <linux/pci.h>
22
23 #include <bcmpci.h>
24 #include <bcm_intr.h>
25 #include <bcm_map_part.h>
26
27 static volatile MpiRegisters * mpi = (MpiRegisters *)(MPI_BASE);
28
29 static char irq_tab_bcm96348[] __initdata = {
30     [0] = INTERRUPT_ID_MPI,
31     [1] = INTERRUPT_ID_MPI,
32 #if defined(CONFIG_USB)
33     [USB_HOST_SLOT] = INTERRUPT_ID_USBH
34 #endif
35 };
36
37 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
38 {
39     return irq_tab_bcm96348[slot];
40 }
41
42 static void bcm96348_fixup(struct pci_dev *dev)
43 {
44     uint32 memaddr;
45     uint32 size;
46
47     memaddr = pci_resource_start(dev, 0);
48     size = pci_resource_len(dev, 0);
49
50     switch (PCI_SLOT(dev->devfn)) {
51         case 0:
52             // UBUS to PCI address range
53             // Memory Window 1. Mask determines which bits are decoded.
54             mpi->l2pmrange1 = ~(size-1);
55             // UBUS to PCI Memory base address. This is akin to the ChipSelect base
56             // register. 
57             mpi->l2pmbase1 = memaddr & BCM_PCI_ADDR_MASK;
58             // UBUS to PCI Remap Address. Replaces the masked address bits in the
59             // range register with this setting. 
60             // Also, enable direct I/O and direct Memory accesses
61             mpi->l2pmremap1 = (memaddr | MEM_WINDOW_EN);
62             break;
63
64         case 1:
65             // Memory Window 2
66             mpi->l2pmrange2 = ~(size-1);
67             // UBUS to PCI Memory base address. 
68             mpi->l2pmbase2 = memaddr & BCM_PCI_ADDR_MASK;
69             // UBUS to PCI Remap Address
70             mpi->l2pmremap2 = (memaddr | MEM_WINDOW_EN);
71             break;
72
73 #if defined(CONFIG_USB)
74         case USB_HOST_SLOT:
75             dev->resource[0].start = USB_HOST_BASE;
76             dev->resource[0].end = USB_HOST_BASE+USB_BAR0_MEM_SIZE-1;
77             break;
78 #endif
79     }
80 }
81
82 struct pci_fixup pcibios_fixups[] = {
83     { PCI_FIXUP_FINAL, PCI_ANY_ID, PCI_ANY_ID, bcm96348_fixup },
84     {0}
85 };