8 #include <linux/kernel.h>
10 #include <linux/pci.h>
12 #include <linux/time.h>
23 #include <dma-coherence.h>
25 #define USE_OCTEON_INTERNAL_ARBITER
32 #define OCTEON_PCI_IOSPACE_BASE 0x80011a0400000000ull
33 #define OCTEON_PCI_IOSPACE_SIZE (1ull<<32)
36 #define OCTEON_PCI_MEMSPACE_OFFSET (0x00011b0000000000ull)
81 panic(
"octeon_pcibios_map_irq not set.");
150 pci_read_config_dword(dev, pos +
PCI_ERR_CAP, &dconfig);
157 pci_write_config_dword(dev, pos +
PCI_ERR_CAP, dconfig);
209 return "AAAAADABAAAAAAAAAAAAAAAAAAAAAAAA";
213 return "AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
238 const char *interrupts;
244 dev_num = dev->
devfn >> 3;
245 if (dev_num <
strlen(interrupts))
246 irq_num = ((interrupts[dev_num] -
'A' + pin - 1) & 3) +
273 #if PCI_CONFIG_SPACE_DELAY
284 *val = cvmx_read64_uint8(
pci_addr.u64);
294 static int octeon_write_config(
struct pci_bus *bus,
unsigned int devfn,
295 int reg,
int size,
u32 val)
310 #if PCI_CONFIG_SPACE_DELAY
321 cvmx_write64_uint8(
pci_addr.u64, val);
328 static struct pci_ops octeon_pci_ops = {
333 static struct resource octeon_pci_mem_resource = {
336 .name =
"Octeon PCI MEM",
344 static struct resource octeon_pci_io_resource = {
347 .name =
"Octeon PCI IO",
352 .pci_ops = &octeon_pci_ops,
353 .mem_resource = &octeon_pci_mem_resource,
355 .io_resource = &octeon_pci_io_resource,
364 static void octeon_pci_initialize(
void)
381 ctl_status.s.max_word = 1;
382 ctl_status.s.timer = 1;
392 ctl_status_2.u32 = 0;
393 ctl_status_2.s.tsr_hwm = 1;
395 ctl_status_2.s.bar2pres = 1;
396 ctl_status_2.s.bar2_enb = 1;
397 ctl_status_2.s.bar2_cax = 1;
398 ctl_status_2.s.bar2_esx = 1;
399 ctl_status_2.s.pmo_amod = 1;
403 ctl_status_2.s.bb1_siz = 1;
404 ctl_status_2.s.bb_ca = 1;
405 ctl_status_2.s.bb_es = 1;
406 ctl_status_2.s.bb1 = 1;
407 ctl_status_2.s.bb0 = 1;
415 ctl_status_2.s.ap_pcix ?
"PCI-X" :
"PCI",
416 ctl_status_2.s.ap_64ad ?
"64" :
"32");
421 unsigned long cycles, pci_clock;
428 pci_clock = (cnt_reg_end.s.pcicnt - cnt_reg_start.s.pcicnt) /
430 pr_notice(
"PCI Clock: %lu MHz\n", pci_clock);
441 if (ctl_status_2.s.ap_pcix) {
493 #ifdef USE_OCTEON_INTERNAL_ARBITER
502 pci_int_arb_cfg.
u64 = 0;
503 pci_int_arb_cfg.s.en = 1;
568 static int __init octeon_pci_setup(
void)
593 pr_notice(
"Not in host mode, PCI Controller not initialized\n");
601 octeon_pci_initialize();
638 for (index = 0; index < 32; index++) {
643 bar1_index.s.addr_idx =
648 bar1_index.s.end_swp = 1;
650 bar1_index.s.addr_v = 1;
656 octeon_pci_mem_resource.
start =
659 octeon_pci_mem_resource.
end =
660 octeon_pci_mem_resource.
start + (1ul << 30);
674 for (index = 0; index < 32; index++) {
679 bar1_index.s.addr_idx =
684 bar1_index.s.end_swp = 1;
686 bar1_index.s.addr_v = 1;
692 octeon_pci_mem_resource.
start =
695 octeon_pci_mem_resource.
end =
696 octeon_pci_mem_resource.
start + (1ul << 30);