3 * BRIEF MODULE DESCRIPTION
5 * Author: source@mvista.com
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 #include <linux/types.h>
21 #include <linux/pci.h>
22 #include <linux/kernel.h>
23 #include <linux/init.h>
29 static struct resource pci_io_resource
= {
30 .start
= PNX8550_PCIIO
+ 0x1000, /* reserve regacy I/O space */
31 .end
= PNX8550_PCIIO
+ PNX8550_PCIIO_SIZE
,
32 .name
= "pci IO space",
33 .flags
= IORESOURCE_IO
36 static struct resource pci_mem_resource
= {
37 .start
= PNX8550_PCIMEM
,
38 .end
= PNX8550_PCIMEM
+ PNX8550_PCIMEM_SIZE
- 1,
39 .name
= "pci memory space",
40 .flags
= IORESOURCE_MEM
43 extern struct pci_ops pnx8550_pci_ops
;
45 static struct pci_controller pnx8550_controller
= {
46 .pci_ops
= &pnx8550_pci_ops
,
47 .io_map_base
= PNX8550_PORT_BASE
,
48 .io_resource
= &pci_io_resource
,
49 .mem_resource
= &pci_mem_resource
,
52 /* Return the total size of DRAM-memory, (RANK0 + RANK1) */
53 static inline unsigned long get_system_mem_size(void)
55 /* Read IP2031_RANK0_ADDR_LO */
56 unsigned long dram_r0_lo
= inl(PCI_BASE
| 0x65010);
57 /* Read IP2031_RANK1_ADDR_HI */
58 unsigned long dram_r1_hi
= inl(PCI_BASE
| 0x65018);
60 return dram_r1_hi
- dram_r0_lo
+ 1;
63 static int __init
pnx8550_pci_setup(void)
66 int mem_size
= get_system_mem_size() >> 20;
68 /* Clear the Global 2 Register, PCI Inta Output Enable Registers
69 Bit 1:Enable DAC Powerdown
70 -> 0:DACs are enabled and are working normally
72 Bit 0:Enable of PCI inta output
73 -> 0 = Disable PCI inta output
74 1 = Enable PCI inta output
76 PNX8550_GLB2_ENAB_INTA_O
= 0;
78 /* Calc the PCI mem size code */
80 pci_mem_code
= SIZE_128M
;
81 else if (mem_size
>= 64)
82 pci_mem_code
= SIZE_64M
;
83 else if (mem_size
>= 32)
84 pci_mem_code
= SIZE_32M
;
86 pci_mem_code
= SIZE_16M
;
88 /* Set PCI_XIO registers */
89 outl(pci_mem_resource
.start
, PCI_BASE
| PCI_BASE1_LO
);
90 outl(pci_mem_resource
.end
+ 1, PCI_BASE
| PCI_BASE1_HI
);
91 outl(pci_io_resource
.start
, PCI_BASE
| PCI_BASE2_LO
);
92 outl(pci_io_resource
.end
, PCI_BASE
| PCI_BASE2_HI
);
94 /* Send memory transaction via PCI_BASE2 */
95 outl(0x00000001, PCI_BASE
| PCI_IO
);
97 /* Unlock the setup register */
98 outl(0xca, PCI_BASE
| PCI_UNLOCKREG
);
101 * BAR0 of PNX8550 (pci base 10) must be zero in order for ide
102 * to work, and in order for bus_to_baddr to work without any
105 outl(0x00000000, PCI_BASE
| PCI_BASE10
);
108 *These two bars are set by default or the boot code.
109 * However, it's safer to set them here so we're not boot
112 outl(0x1be00000, PCI_BASE
| PCI_BASE14
); /* PNX MMIO */
113 outl(PNX8550_NAND_BASE_ADDR
, PCI_BASE
| PCI_BASE18
); /* XIO */
118 PCI_SETUP_BASE18_SIZE(SIZE_32M
) |
119 PCI_SETUP_BASE18_EN
|
120 PCI_SETUP_BASE14_EN
|
121 PCI_SETUP_BASE10_PREF
|
122 PCI_SETUP_BASE10_SIZE(pci_mem_code
) |
123 PCI_SETUP_CFGMANAGE_EN
|
126 PCI_SETUP
); /* PCI_SETUP */
127 outl(0x00000000, PCI_BASE
| PCI_CTRL
); /* PCI_CONTROL */
129 register_pci_controller(&pnx8550_controller
);
134 arch_initcall(pnx8550_pci_setup
);