2 * Copyright 2009 Freescale Semiconductor, Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/immap_85xx.h>
28 #include <asm/fsl_pci.h>
30 #include <fdt_support.h>
32 DECLARE_GLOBAL_DATA_PTR;
35 static struct pci_controller pcie1_hose;
39 static struct pci_controller pcie2_hose;
42 void pci_init_board(void)
44 struct fsl_pci_info pci_info[2];
45 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
46 uint devdisr = in_be32(&gur->devdisr);
47 uint io_sel = (in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_IO_SEL) >> 19;
48 uint host_agent = (in_be32(&gur->porbmsr) & MPC85xx_PORBMSR_HA) >> 16;
50 int first_free_busno = 0;
52 int pcie_ep, pcie_configured;
54 debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
55 devdisr, io_sel, host_agent);
57 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS))
58 printf (" eTSEC2 is in sgmii mode.\n");
61 SET_STD_PCIE_INFO(pci_info[num], 2);
62 pcie_ep = (host_agent == 2) || (host_agent == 4) ||
63 (host_agent == 6) || (host_agent == 0);
64 pcie_configured = (io_sel == 0xE);
66 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
67 puts ("\n PCIE2 connected to Slot 1 as ");
68 printf ("%s (base address %lx)",
69 pcie_ep ? "End Point": "Root Complex", pci_info[num].regs);
70 first_free_busno = fsl_pci_init_port(&pci_info[num],
71 &pcie2_hose, first_free_busno);
74 printf (" PCIE2: disabled\n");
77 set_bits32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
81 SET_STD_PCIE_INFO(pci_info[num], 1);
83 pcie_ep = (host_agent <= 1) || (host_agent == 4) ||
85 pcie_configured = (io_sel == 0xE);
87 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
88 puts ("\n PCIE1 connected to Slot 2 as ");
89 printf ("%s (base address %lx)",
90 pcie_ep ? "End Point" : "Root Complex",
92 first_free_busno = fsl_pci_init_port(&pci_info[num],
93 &pcie1_hose, first_free_busno);
96 printf (" PCIE1: disabled\n");
99 set_bits32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
103 void ft_pci_board_setup(void *blob)
105 /* According to h/w manual, PCIE2 is at lower address(0x9000)
106 * than PCIE1(0xa000).
107 * Hence PCIE2 is made to occupy the pci1 position in dts to
108 * keep the addresses sorted there.
109 * Generally the case with all FSL SOCs.
112 ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
115 ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);