2006-11-01 00:44:42 +00:00
|
|
|
/*
|
2009-07-18 23:42:13 +00:00
|
|
|
* Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
|
2006-11-01 00:44:42 +00:00
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2006-11-01 00:44:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
#include <asm/mmu.h>
|
2009-07-18 23:42:13 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <mpc83xx.h>
|
2006-11-01 00:44:42 +00:00
|
|
|
#include <pci.h>
|
|
|
|
#include <i2c.h>
|
2009-07-18 23:42:13 +00:00
|
|
|
#include <asm/fsl_i2c.h>
|
2006-11-01 00:44:42 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2009-07-18 23:42:13 +00:00
|
|
|
static struct pci_region pci1_regions[] = {
|
|
|
|
{
|
|
|
|
bus_start: CONFIG_SYS_PCI1_MEM_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI1_MEM_SIZE,
|
|
|
|
flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
|
|
|
|
},
|
|
|
|
{
|
|
|
|
bus_start: CONFIG_SYS_PCI1_IO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI1_IO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI1_IO_SIZE,
|
|
|
|
flags: PCI_REGION_IO
|
|
|
|
},
|
2006-11-01 00:44:42 +00:00
|
|
|
{
|
2009-07-18 23:42:13 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI1_MMIO_SIZE,
|
|
|
|
flags: PCI_REGION_MEM
|
|
|
|
},
|
2006-11-01 00:44:42 +00:00
|
|
|
};
|
|
|
|
|
2009-07-18 23:42:13 +00:00
|
|
|
#ifdef CONFIG_MPC83XX_PCI2
|
|
|
|
static struct pci_region pci2_regions[] = {
|
2006-11-01 00:44:42 +00:00
|
|
|
{
|
2009-07-18 23:42:13 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI2_MEM_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI2_MEM_SIZE,
|
|
|
|
flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
|
|
|
|
},
|
2006-11-01 00:44:42 +00:00
|
|
|
{
|
2009-07-18 23:42:13 +00:00
|
|
|
bus_start: CONFIG_SYS_PCI2_IO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI2_IO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI2_IO_SIZE,
|
|
|
|
flags: PCI_REGION_IO
|
|
|
|
},
|
|
|
|
{
|
|
|
|
bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
|
|
|
|
phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
|
|
|
|
size: CONFIG_SYS_PCI2_MMIO_SIZE,
|
|
|
|
flags: PCI_REGION_MEM
|
|
|
|
},
|
2006-11-01 00:44:42 +00:00
|
|
|
};
|
2009-07-18 23:42:13 +00:00
|
|
|
#endif
|
2006-11-01 00:44:42 +00:00
|
|
|
|
|
|
|
void pci_init_board(void)
|
|
|
|
{
|
2009-07-18 23:42:13 +00:00
|
|
|
volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
|
|
|
|
volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
|
|
|
|
volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
|
|
|
|
#ifndef CONFIG_MPC83XX_PCI2
|
|
|
|
struct pci_region *reg[] = { pci1_regions };
|
|
|
|
#else
|
|
|
|
struct pci_region *reg[] = { pci1_regions, pci2_regions };
|
|
|
|
#endif
|
2006-11-01 00:44:42 +00:00
|
|
|
u8 reg8;
|
|
|
|
|
2012-10-24 11:48:22 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C)
|
2006-11-04 01:15:00 +00:00
|
|
|
i2c_set_bus_num(1);
|
2006-11-01 00:44:42 +00:00
|
|
|
/* Read the PCI_M66EN jumper setting */
|
2008-10-16 13:01:15 +00:00
|
|
|
if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0) ||
|
|
|
|
(i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0)) {
|
2006-11-01 00:44:42 +00:00
|
|
|
if (reg8 & I2C_8574_PCI66)
|
|
|
|
clk->occr = 0xff000000; /* 66 MHz PCI */
|
|
|
|
else
|
|
|
|
clk->occr = 0xff600001; /* 33 MHz PCI */
|
|
|
|
} else {
|
|
|
|
clk->occr = 0xff600001; /* 33 MHz PCI */
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
clk->occr = 0xff000000; /* 66 MHz PCI */
|
|
|
|
#endif
|
|
|
|
udelay(2000);
|
|
|
|
|
2009-07-18 23:42:13 +00:00
|
|
|
/* Configure PCI Local Access Windows */
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
|
2006-11-01 00:44:42 +00:00
|
|
|
pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
|
2006-11-01 01:14:41 +00:00
|
|
|
pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
|
2006-11-01 00:44:42 +00:00
|
|
|
|
2009-07-18 23:42:13 +00:00
|
|
|
udelay(2000);
|
2007-12-20 20:09:22 +00:00
|
|
|
|
2009-07-18 23:42:13 +00:00
|
|
|
#ifndef CONFIG_MPC83XX_PCI2
|
2010-09-15 00:13:50 +00:00
|
|
|
mpc83xx_pci_init(1, reg);
|
2009-07-18 23:42:13 +00:00
|
|
|
#else
|
2010-09-15 00:13:50 +00:00
|
|
|
mpc83xx_pci_init(2, reg);
|
2007-08-16 03:30:33 +00:00
|
|
|
#endif
|
|
|
|
}
|