35 #include <linux/types.h>
36 #include <linux/pci.h>
37 #include <linux/kernel.h>
56 static void *pci_config_base;
58 #define pci_cfg_addr(bus, devfn, off) (((bus) << 16) | ((devfn) << 8) | (off))
67 cfgaddr = (
u32 *)(pci_config_base +
73 static inline void pci_cfg_write_32bit(
struct pci_bus *
bus,
unsigned int devfn,
78 cfgaddr = (
u32 *)(pci_config_base +
83 static int nlm_pcibios_read(
struct pci_bus *bus,
unsigned int devfn,
88 if ((size == 2) && (where & 1))
90 else if ((size == 4) && (where & 3))
93 data = pci_cfg_read_32bit(bus, devfn, where);
96 *val = (data >> ((where & 3) << 3)) & 0xff;
98 *val = (data >> ((where & 3) << 3)) & 0xffff;
106 static int nlm_pcibios_write(
struct pci_bus *bus,
unsigned int devfn,
107 int where,
int size,
u32 val)
111 if ((size == 2) && (where & 1))
113 else if ((size == 4) && (where & 3))
116 data = pci_cfg_read_32bit(bus, devfn, where);
119 data = (data & ~(0xff << ((where & 3) << 3))) |
120 (val << ((where & 3) << 3));
122 data = (data & ~(0xffff << ((where & 3) << 3))) |
123 (val << ((where & 3) << 3));
127 pci_cfg_write_32bit(bus, devfn, where, data);
133 .read = nlm_pcibios_read,
134 .write = nlm_pcibios_write
137 static struct resource nlm_pci_mem_resource = {
138 .name =
"XLR PCI MEM",
139 .start = 0xd0000000
UL,
144 static struct resource nlm_pci_io_resource = {
145 .name =
"XLR IO MEM",
146 .start = 0x10000000
UL,
154 .mem_resource = &nlm_pci_mem_resource,
155 .mem_offset = 0x00000000
UL,
156 .io_resource = &nlm_pci_io_resource,
157 .io_offset = 0x00000000
UL,
177 static int get_irq_vector(
const struct pci_dev *dev)
181 if (!nlm_chip_is_xls())
188 lnk = xls_get_pcie_link(dev);
198 if (nlm_chip_is_xls_b())
203 if (nlm_chip_is_xls_b())
208 WARN(1,
"Unexpected devfn %d\n", lnk->
devfn);
212 #ifdef CONFIG_PCI_MSI
231 if (!nlm_chip_is_xls())
238 lnk = xls_get_pcie_link(dev);
248 irq = get_irq_vector(dev);
273 static void xlr_pci_ack(
struct irq_data *
d)
277 nlm_read_reg(pcibase, (0x140 >> 2));
281 static void xls_pcie_ack(
struct irq_data *d)
287 nlm_write_reg(pciebase_le, (0x90 >> 2), 0xffffffff);
290 nlm_write_reg(pciebase_le, (0x94 >> 2), 0xffffffff);
293 nlm_write_reg(pciebase_le, (0x190 >> 2), 0xffffffff);
296 nlm_write_reg(pciebase_le, (0x194 >> 2), 0xffffffff);
302 static void xls_pcie_ack_b(
struct irq_data *d)
308 nlm_write_reg(pciebase_le, (0x90 >> 2), 0xffffffff);
311 nlm_write_reg(pciebase_le, (0x94 >> 2), 0xffffffff);
314 nlm_write_reg(pciebase_le, (0x190 >> 2), 0xffffffff);
317 nlm_write_reg(pciebase_le, (0x194 >> 2), 0xffffffff);
324 return get_irq_vector(dev);
336 pci_set_flags(PCI_PROBE_ONLY);
344 nlm_pci_controller.io_map_base =
CKSEG1;
346 pr_info(
"Registering XLR/XLS PCIX/PCIE Controller.\n");
353 if (nlm_chip_is_xls()) {
354 if (nlm_chip_is_xls_b()) {