blob: 510f638ffea8f9ab63eaa93bfca1ee65ca12fd5a [file] [log] [blame]
Peter Tyserccf0fdd2008-12-17 16:36:23 -06001/*
2 * Copyright 2008 Extreme Engineering Solutions, Inc.
3 * Copyright 2007-2008 Freescale Semiconductor, Inc.
4 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02005 * SPDX-License-Identifier: GPL-2.0+
Peter Tyserccf0fdd2008-12-17 16:36:23 -06006 */
7
8#include <common.h>
9#include <pci.h>
Kumar Galac8514622009-04-02 13:22:48 -050010#include <asm/fsl_pci.h>
Kumar Gala5d27e022010-12-15 04:55:20 -060011#include <asm/fsl_serdes.h>
Peter Tyser1bb61b62009-08-07 13:16:34 -050012#include <asm/io.h>
Peter Tyser9660c5d2010-10-22 00:20:22 -050013#include <linux/compiler.h>
Peter Tyserccf0fdd2008-12-17 16:36:23 -060014#include <libfdt.h>
15#include <fdt_support.h>
16
Peter Tyserccf0fdd2008-12-17 16:36:23 -060017
Peter Tyser78bbc5c2008-12-01 13:47:13 -060018#ifdef CONFIG_PCI1
19static struct pci_controller pci1_hose;
20#endif
Peter Tyserccf0fdd2008-12-17 16:36:23 -060021
22void pci_init_board(void)
23{
Peter Tyser9660c5d2010-10-22 00:20:22 -050024 int first_free_busno = 0;
Peter Tyserccf0fdd2008-12-17 16:36:23 -060025
Peter Tyser78bbc5c2008-12-01 13:47:13 -060026#ifdef CONFIG_PCI1
Kumar Gala66357092010-12-17 10:23:03 -060027 int pcie_ep;
28 struct fsl_pci_info pci_info;
29 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
30 u32 devdisr = in_be32(&gur->devdisr);
Peter Tyser1bb61b62009-08-07 13:16:34 -050031 uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
32 uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
33 uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
34 uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
Peter Tyser78bbc5c2008-12-01 13:47:13 -060035 uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
Peter Tyserccf0fdd2008-12-17 16:36:23 -060036
Peter Tyser78bbc5c2008-12-01 13:47:13 -060037 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
Kumar Gala66357092010-12-17 10:23:03 -060038 SET_STD_PCI_INFO(pci_info, 1);
39 set_next_law(pci_info.mem_phys,
40 law_size_bits(pci_info.mem_size), pci_info.law);
41 set_next_law(pci_info.io_phys,
42 law_size_bits(pci_info.io_size), pci_info.law);
43
44 pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
Peter Tyser8ca78f22010-10-29 17:59:24 -050045 printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
Peter Tyser78bbc5c2008-12-01 13:47:13 -060046 pci_32 ? 32 : 64,
47 pcix ? "PCIX" : "PCI",
Peter Tyser1bb61b62009-08-07 13:16:34 -050048 pci_spd_norm ? ">=" : "<=",
Peter Tyser78bbc5c2008-12-01 13:47:13 -060049 pcix ? freq * 2 : freq,
Peter Tyser9660c5d2010-10-22 00:20:22 -050050 pcie_ep ? "agent" : "host",
Peter Tyser78bbc5c2008-12-01 13:47:13 -060051 pci_arb ? "arbiter" : "external-arbiter");
52
Kumar Gala66357092010-12-17 10:23:03 -060053 first_free_busno = fsl_pci_init_port(&pci_info,
Peter Tyser9660c5d2010-10-22 00:20:22 -050054 &pci1_hose, first_free_busno);
Peter Tyser78bbc5c2008-12-01 13:47:13 -060055 } else {
Peter Tyser8ca78f22010-10-29 17:59:24 -050056 printf("PCI1: disabled\n");
Peter Tyser78bbc5c2008-12-01 13:47:13 -060057 }
58#elif defined CONFIG_MPC8548
Kumar Gala66357092010-12-17 10:23:03 -060059 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser78bbc5c2008-12-01 13:47:13 -060060 /* PCI1 not present on MPC8572 */
Peter Tyser1bb61b62009-08-07 13:16:34 -050061 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
Peter Tyser78bbc5c2008-12-01 13:47:13 -060062#endif
Peter Tyser9660c5d2010-10-22 00:20:22 -050063
Kumar Gala66357092010-12-17 10:23:03 -060064 fsl_pcie_init_board(first_free_busno);
Peter Tyserccf0fdd2008-12-17 16:36:23 -060065}
66
67#if defined(CONFIG_OF_BOARD_SETUP)
Peter Tyserccf0fdd2008-12-17 16:36:23 -060068void ft_board_pci_setup(void *blob, bd_t *bd)
69{
Kumar Gala6525d512010-07-08 22:37:44 -050070 FT_FSL_PCI_SETUP;
Peter Tyserccf0fdd2008-12-17 16:36:23 -060071}
72#endif /* CONFIG_OF_BOARD_SETUP */