2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-12-17 22:36:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Extreme Engineering Solutions, Inc.
|
|
|
|
* Copyright 2007-2008 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:47 +00:00
|
|
|
#include <init.h>
|
2008-12-17 22:36:23 +00:00
|
|
|
#include <pci.h>
|
2009-04-02 18:22:48 +00:00
|
|
|
#include <asm/fsl_pci.h>
|
2010-12-15 10:55:20 +00:00
|
|
|
#include <asm/fsl_serdes.h>
|
2009-08-07 18:16:34 +00:00
|
|
|
#include <asm/io.h>
|
2010-10-22 05:20:22 +00:00
|
|
|
#include <linux/compiler.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2008-12-17 22:36:23 +00:00
|
|
|
#include <fdt_support.h>
|
|
|
|
|
|
|
|
|
2008-12-01 19:47:13 +00:00
|
|
|
#ifdef CONFIG_PCI1
|
|
|
|
static struct pci_controller pci1_hose;
|
|
|
|
#endif
|
2008-12-17 22:36:23 +00:00
|
|
|
|
|
|
|
void pci_init_board(void)
|
|
|
|
{
|
2010-10-22 05:20:22 +00:00
|
|
|
int first_free_busno = 0;
|
|
|
|
|
2010-12-17 16:23:03 +00:00
|
|
|
#ifdef CONFIG_PCI1
|
|
|
|
int pcie_ep;
|
|
|
|
struct fsl_pci_info pci_info;
|
2008-12-17 22:36:23 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2010-10-22 05:20:22 +00:00
|
|
|
u32 devdisr = in_be32(&gur->devdisr);
|
2009-08-07 18:16:34 +00:00
|
|
|
uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
|
|
|
|
uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
|
|
|
|
uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
|
|
|
|
uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
|
2008-12-01 19:47:13 +00:00
|
|
|
uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
|
|
|
|
|
|
|
|
if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
|
2010-12-17 16:23:03 +00:00
|
|
|
SET_STD_PCI_INFO(pci_info, 1);
|
|
|
|
set_next_law(pci_info.mem_phys,
|
|
|
|
law_size_bits(pci_info.mem_size), pci_info.law);
|
|
|
|
set_next_law(pci_info.io_phys,
|
|
|
|
law_size_bits(pci_info.io_size), pci_info.law);
|
|
|
|
|
|
|
|
pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
|
2010-10-29 22:59:24 +00:00
|
|
|
printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
|
2008-12-01 19:47:13 +00:00
|
|
|
pci_32 ? 32 : 64,
|
|
|
|
pcix ? "PCIX" : "PCI",
|
2009-08-07 18:16:34 +00:00
|
|
|
pci_spd_norm ? ">=" : "<=",
|
2008-12-01 19:47:13 +00:00
|
|
|
pcix ? freq * 2 : freq,
|
2010-10-22 05:20:22 +00:00
|
|
|
pcie_ep ? "agent" : "host",
|
2008-12-01 19:47:13 +00:00
|
|
|
pci_arb ? "arbiter" : "external-arbiter");
|
2008-12-17 22:36:23 +00:00
|
|
|
|
2010-12-17 16:23:03 +00:00
|
|
|
first_free_busno = fsl_pci_init_port(&pci_info,
|
2010-10-22 05:20:22 +00:00
|
|
|
&pci1_hose, first_free_busno);
|
2008-12-01 19:47:13 +00:00
|
|
|
} else {
|
2010-10-29 22:59:24 +00:00
|
|
|
printf("PCI1: disabled\n");
|
2008-12-01 19:47:13 +00:00
|
|
|
}
|
2016-11-15 21:52:34 +00:00
|
|
|
#elif defined CONFIG_ARCH_MPC8548
|
2010-12-17 16:23:03 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2008-12-01 19:47:13 +00:00
|
|
|
/* PCI1 not present on MPC8572 */
|
2009-08-07 18:16:34 +00:00
|
|
|
setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
|
2008-12-01 19:47:13 +00:00
|
|
|
#endif
|
2008-12-17 22:36:23 +00:00
|
|
|
|
2010-12-17 16:23:03 +00:00
|
|
|
fsl_pcie_init_board(first_free_busno);
|
2008-12-17 22:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_OF_BOARD_SETUP)
|
2020-06-26 06:13:33 +00:00
|
|
|
void ft_board_pci_setup(void *blob, struct bd_info *bd)
|
2008-12-17 22:36:23 +00:00
|
|
|
{
|
2010-07-09 03:37:44 +00:00
|
|
|
FT_FSL_PCI_SETUP;
|
2008-12-17 22:36:23 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_OF_BOARD_SETUP */
|