2 * Copyright (C) ADMtek Incorporated.
3 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
4 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
5 * Copyright (C) 2007 OpenWrt.org
8 #include <linux/autoconf.h>
9 #include <linux/types.h>
10 #include <linux/pci.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
14 #include <adm5120_info.h>
15 #include <adm5120_defs.h>
17 extern struct pci_ops adm5120_pci_ops
;
19 #define PCI_CMM_IOACC_EN 0x1
20 #define PCI_CMM_MEMACC_EN 0x2
21 #define PCI_CMM_MASTER_EN 0x4
23 (PCI_CMM_IOACC_EN | PCI_CMM_MEMACC_EN | PCI_CMM_MASTER_EN)
25 #define PCI_DEF_CACHE_LINE_SZ 4
28 struct resource pci_io_resource
= {
29 .name
= "ADM5120 PCI I/O",
30 .start
= ADM5120_PCIIO_BASE
,
31 .end
= ADM5120_PCICFG_ADDR
-1,
32 .flags
= IORESOURCE_IO
35 struct resource pci_mem_resource
= {
36 .name
= "ADM5120 PCI MEM",
37 .start
= ADM5120_PCIMEM_BASE
,
38 .end
= ADM5120_PCIIO_BASE
-1,
39 .flags
= IORESOURCE_MEM
42 static struct pci_controller adm5120_controller
= {
43 .pci_ops
= &adm5120_pci_ops
,
44 .io_resource
= &pci_io_resource
,
45 .mem_resource
= &pci_mem_resource
,
48 int __init
pcibios_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
50 if (slot
< 2 || slot
> 4)
55 static void adm5120_pci_fixup(struct pci_dev
*dev
)
57 if (dev
->devfn
== 0) {
58 pci_write_config_word(dev
, PCI_COMMAND
, PCI_CMM_DEF
);
59 pci_write_config_byte(dev
, PCI_CACHE_LINE_SIZE
,
60 PCI_DEF_CACHE_LINE_SZ
);
61 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
, 0);
62 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_1
, 0);
66 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID
, PCI_ANY_ID
, adm5120_pci_fixup
);
69 int pcibios_plat_dev_init(struct pci_dev
*dev
)
74 static int __init
adm5120_pci_setup(void)
78 pci_bios
= adm5120_has_pci();
80 printk("adm5120: system has %sPCI BIOS\n", pci_bios
? "" : "no ");
84 /* Avoid ISA compat ranges. */
85 PCIBIOS_MIN_IO
= 0x00000000;
86 PCIBIOS_MIN_MEM
= 0x00000000;
88 /* Set I/O resource limits. */
89 ioport_resource
.end
= 0x1fffffff;
90 iomem_resource
.end
= 0xffffffff;
92 register_pci_controller(&adm5120_controller
);
96 subsys_initcall(adm5120_pci_setup
);