static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base, &dove_mbus_dram_info); /* * IORESOURCE_IO */ snprintf(pp->io_space_name, sizeof(pp->io_space_name), "PCIe %d I/O", pp->index); pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; pp->res[0].name = pp->io_space_name; if (pp->index == 0) { pp->res[0].start = DOVE_PCIE0_IO_PHYS_BASE; pp->res[0].end = pp->res[0].start + DOVE_PCIE0_IO_SIZE - 1; } else { pp->res[0].start = DOVE_PCIE1_IO_PHYS_BASE; pp->res[0].end = pp->res[0].start + DOVE_PCIE1_IO_SIZE - 1; } pp->res[0].flags = IORESOURCE_IO; if (request_resource(&ioport_resource, &pp->res[0])) panic("Request PCIe IO resource failed\n"); sys->resource[0] = &pp->res[0]; /* * IORESOURCE_MEM */ snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), "PCIe %d MEM", pp->index); pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; pp->res[1].name = pp->mem_space_name; if (pp->index == 0) { pp->res[1].start = DOVE_PCIE0_MEM_PHYS_BASE; pp->res[1].end = pp->res[1].start + DOVE_PCIE0_MEM_SIZE - 1; } else { pp->res[1].start = DOVE_PCIE1_MEM_PHYS_BASE; pp->res[1].end = pp->res[1].start + DOVE_PCIE1_MEM_SIZE - 1; } pp->res[1].flags = IORESOURCE_MEM; if (request_resource(&iomem_resource, &pp->res[1])) panic("Request PCIe Memory resource failed\n"); sys->resource[1] = &pp->res[1]; sys->resource[2] = NULL; return 1; }
static int __init pcie_setup(struct pci_sys_data *sys) { struct resource *res; int dev; /* * Generic PCIe unit setup. */ orion_pcie_setup(PCIE_BASE, &orion5x_mbus_dram_info); /* * Check whether to apply Orion-1/Orion-NAS PCIe config * read transaction workaround. */ dev = orion_pcie_dev_id(PCIE_BASE); if (dev == MV88F5181_DEV_ID || dev == MV88F5182_DEV_ID) { printk(KERN_NOTICE "Applying Orion-1/Orion-NAS PCIe config " "read transaction workaround\n"); orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, ORION5X_PCIE_WA_SIZE); pcie_ops.read = pcie_rd_conf_wa; } /* * Request resources. */ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); if (!res) panic("pcie_setup unable to alloc resources"); /* * IORESOURCE_IO */ res[0].name = "PCIe I/O Space"; res[0].flags = IORESOURCE_IO; res[0].start = ORION5X_PCIE_IO_BUS_BASE; res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1; if (request_resource(&ioport_resource, &res[0])) panic("Request PCIe IO resource failed\n"); sys->resource[0] = &res[0]; /* * IORESOURCE_MEM */ res[1].name = "PCIe Memory Space"; res[1].flags = IORESOURCE_MEM; res[1].start = ORION5X_PCIE_MEM_PHYS_BASE; res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1; if (request_resource(&iomem_resource, &res[1])) panic("Request PCIe Memory resource failed\n"); sys->resource[1] = &res[1]; sys->resource[2] = NULL; sys->io_offset = 0; return 1; }
static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) { extern unsigned int kirkwood_clk_ctrl; struct pcie_port *pp; int index; if (nr >= num_pcie_ports) return 0; index = pcie_port_map[nr]; printk(KERN_INFO "PCI: bus%d uses PCIe port %d\n", sys->busnr, index); pp = kzalloc(sizeof(*pp), GFP_KERNEL); if (!pp) panic("PCIe: failed to allocate pcie_port data"); sys->private_data = pp; pp->root_bus_nr = sys->busnr; spin_lock_init(&pp->conf_lock); switch (index) { case 0: kirkwood_clk_ctrl |= CGC_PEX0; pcie0_ioresources_init(pp); break; case 1: kirkwood_clk_ctrl |= CGC_PEX1; pcie1_ioresources_init(pp); break; default: panic("PCIe setup: invalid controller %d", index); } if (request_resource(&ioport_resource, &pp->res[0])) panic("Request PCIe%d IO resource failed\n", index); if (request_resource(&iomem_resource, &pp->res[1])) panic("Request PCIe%d Memory resource failed\n", index); sys->resource[0] = &pp->res[0]; sys->resource[1] = &pp->res[1]; sys->resource[2] = NULL; sys->io_offset = 0; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base, &kirkwood_mbus_dram_info); return 1; }
static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; int index; if (nr >= num_pcie_ports) return 0; index = pcie_port_map[nr]; printk(KERN_INFO "PCI: bus%d uses PCIe port %d\n", sys->busnr, index); pp = kzalloc(sizeof(*pp), GFP_KERNEL); if (!pp) panic("PCIe: failed to allocate pcie_port data"); sys->private_data = pp; pp->root_bus_nr = sys->busnr; spin_lock_init(&pp->conf_lock); switch (index) { case 0: kirkwood_enable_pcie_clk("0"); pcie0_ioresources_init(pp); pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE_IO_PHYS_BASE); break; case 1: kirkwood_enable_pcie_clk("1"); pcie1_ioresources_init(pp); pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE1_IO_PHYS_BASE); break; default: panic("PCIe setup: invalid controller %d", index); } if (request_resource(&iomem_resource, &pp->res)) panic("Request PCIe%d Memory resource failed\n", index); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); return 1; }
static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) { struct resource *res; extern unsigned int kirkwood_clk_ctrl; /* * Generic PCIe unit setup. */ orion_pcie_setup(PCIE_BASE, &kirkwood_mbus_dram_info); /* * Request resources. */ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); if (!res) panic("pcie_setup unable to alloc resources"); /* * IORESOURCE_IO */ res[0].name = "PCIe I/O Space"; res[0].flags = IORESOURCE_IO; res[0].start = KIRKWOOD_PCIE_IO_BUS_BASE; res[0].end = res[0].start + KIRKWOOD_PCIE_IO_SIZE - 1; if (request_resource(&ioport_resource, &res[0])) panic("Request PCIe IO resource failed\n"); sys->resource[0] = &res[0]; /* * IORESOURCE_MEM */ res[1].name = "PCIe Memory Space"; res[1].flags = IORESOURCE_MEM; res[1].start = KIRKWOOD_PCIE_MEM_BUS_BASE; res[1].end = res[1].start + KIRKWOOD_PCIE_MEM_SIZE - 1; if (request_resource(&iomem_resource, &res[1])) panic("Request PCIe Memory resource failed\n"); sys->resource[1] = &res[1]; sys->resource[2] = NULL; sys->io_offset = 0; kirkwood_clk_ctrl |= CGC_PEX0; return 1; }
static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; sys->private_data = pp; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); if (pp->index == 0) pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE); else pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE1_IO_PHYS_BASE); /* * IORESOURCE_MEM */ snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), "PCIe %d MEM", pp->index); pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; pp->res.name = pp->mem_space_name; if (pp->index == 0) { pp->res.start = DOVE_PCIE0_MEM_PHYS_BASE; pp->res.end = pp->res.start + DOVE_PCIE0_MEM_SIZE - 1; } else { pp->res.start = DOVE_PCIE1_MEM_PHYS_BASE; pp->res.end = pp->res.start + DOVE_PCIE1_MEM_SIZE - 1; } pp->res.flags = IORESOURCE_MEM; if (request_resource(&iomem_resource, &pp->res)) panic("Request PCIe Memory resource failed\n"); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); return 1; }
static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base, &mv78xx0_mbus_dram_info); sys->resource[0] = &pp->res[0]; sys->resource[1] = &pp->res[1]; sys->resource[2] = NULL; return 1; }
void dove_restore_pcie_regs(void) { u32 i; u32 timeout = 50; u32 reg; /* Configure PCIE ports */ for (i = 0; i<num_pcie_ports; i++) { orion_pcie_set_local_bus_nr(pcie_port[i].base, pcie_port[i].root_bus_nr); orion_pcie_setup(pcie_port[i].base); dove_pcie_clk_out_config(i); dove_pcie_tune_phy(pcie_port[i].base); } /* Enable Link on both ports */ reg = readl(CPU_CONTROL); reg &= ~(CPU_CTRL_PCIE0_LINK | CPU_CTRL_PCIE1_LINK); writel(reg, CPU_CONTROL); /* * Loop waiting for link up on the phy of the ports. */ do { int i; int links_ready = 1; for (i = 0; i < num_pcie_ports; i++) if (!orion_pcie_link_up(pcie_port[i].base)) links_ready = 0; if (links_ready) break; mdelay(1); } while (timeout--); }
static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; if (nr >= num_pcie_ports) return 0; pp = &pcie_port[nr]; sys->private_data = pp; pp->root_bus_nr = sys->busnr; /* * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); orion_pcie_setup(pp->base); pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr)); pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); return 1; }