2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-01-16 06:38:05 +00:00
|
|
|
/*
|
2009-07-18 23:42:13 +00:00
|
|
|
* Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
|
2008-01-16 06:38:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <mpc83xx.h>
|
|
|
|
#include <pci.h>
|
2009-02-19 15:20:52 +00:00
|
|
|
#include <asm/io.h>
|
2008-01-16 06:38:05 +00:00
|
|
|
|
|
|
|
static struct pci_region pci_regions[] = {
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI_MEM_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI_MEM_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI_MEM_SIZE,
|
2008-01-16 06:38:05 +00:00
|
|
|
flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
|
|
|
|
},
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI_MMIO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI_MMIO_SIZE,
|
2008-01-16 06:38:05 +00:00
|
|
|
flags: PCI_REGION_MEM
|
|
|
|
},
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI_IO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI_IO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI_IO_SIZE,
|
2008-01-16 06:38:05 +00:00
|
|
|
flags: PCI_REGION_IO
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-02-19 15:20:52 +00:00
|
|
|
static struct pci_region pcie_regions_0[] = {
|
|
|
|
{
|
|
|
|
.bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
|
|
|
|
.phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
|
|
|
|
.size = CONFIG_SYS_PCIE1_MEM_SIZE,
|
|
|
|
.flags = PCI_REGION_MEM,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bus_start = CONFIG_SYS_PCIE1_IO_BASE,
|
|
|
|
.phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
|
|
|
|
.size = CONFIG_SYS_PCIE1_IO_SIZE,
|
|
|
|
.flags = PCI_REGION_IO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_region pcie_regions_1[] = {
|
|
|
|
{
|
|
|
|
.bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
|
|
|
|
.phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
|
|
|
|
.size = CONFIG_SYS_PCIE2_MEM_SIZE,
|
|
|
|
.flags = PCI_REGION_MEM,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bus_start = CONFIG_SYS_PCIE2_IO_BASE,
|
|
|
|
.phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
|
|
|
|
.size = CONFIG_SYS_PCIE2_IO_SIZE,
|
|
|
|
.flags = PCI_REGION_IO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-01-16 06:38:05 +00:00
|
|
|
void pci_init_board(void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
|
2009-02-19 15:20:52 +00:00
|
|
|
volatile sysconf83xx_t *sysconf = &immr->sysconf;
|
2008-01-16 06:38:05 +00:00
|
|
|
volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
|
|
|
|
volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
|
2009-02-19 15:20:52 +00:00
|
|
|
volatile law83xx_t *pcie_law = sysconf->pcielaw;
|
2008-01-16 06:38:05 +00:00
|
|
|
struct pci_region *reg[] = { pci_regions };
|
2009-02-19 15:20:52 +00:00
|
|
|
struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
|
|
|
|
u32 spridr = in_be32(&immr->sysconf.spridr);
|
2008-01-16 06:38:05 +00:00
|
|
|
|
|
|
|
/* Enable all 5 PCI_CLK_OUTPUTS */
|
|
|
|
clk->occr |= 0xf8000000;
|
|
|
|
udelay(2000);
|
|
|
|
|
|
|
|
/* Configure PCI Local Access Windows */
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
|
2008-01-16 06:38:05 +00:00
|
|
|
pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
|
2008-01-16 06:38:05 +00:00
|
|
|
pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
|
|
|
|
|
2010-09-15 00:13:50 +00:00
|
|
|
mpc83xx_pci_init(1, reg);
|
2009-02-19 15:20:52 +00:00
|
|
|
|
|
|
|
/* There is no PEX in MPC8379 parts. */
|
|
|
|
if (PARTID_NO_E(spridr) == SPR_8379)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Configure the clock for PCIE controller */
|
|
|
|
clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM,
|
|
|
|
SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1);
|
|
|
|
|
|
|
|
/* Deassert the resets in the control register */
|
|
|
|
out_be32(&sysconf->pecr1, 0xE0008000);
|
|
|
|
out_be32(&sysconf->pecr2, 0xE0008000);
|
|
|
|
udelay(2000);
|
|
|
|
|
|
|
|
/* Configure PCI Express Local Access Windows */
|
|
|
|
out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
|
|
|
|
out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
|
|
|
|
|
|
|
|
out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
|
|
|
|
out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
|
|
|
|
|
2010-09-15 00:13:50 +00:00
|
|
|
mpc83xx_pcie_init(2, pcie_reg);
|
2008-01-16 06:38:05 +00:00
|
|
|
}
|