powerpc/85xx: Cleanup SGMII detection and reporting
[oweals/u-boot.git] / board / freescale / p1_p2_rdb / pci.c
1 /*
2  * Copyright 2009-2010 Freescale Semiconductor, Inc.
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
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.
11  *
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.
16  *
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,
20  * MA 02111-1307 USA
21  */
22
23 #include <common.h>
24 #include <command.h>
25 #include <pci.h>
26 #include <asm/immap_85xx.h>
27 #include <asm/fsl_serdes.h>
28 #include <asm/io.h>
29 #include <asm/fsl_pci.h>
30 #include <libfdt.h>
31 #include <fdt_support.h>
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 #ifdef CONFIG_PCIE1
36 static struct pci_controller pcie1_hose;
37 #endif
38
39 #ifdef CONFIG_PCIE2
40 static struct pci_controller pcie2_hose;
41 #endif
42
43 void pci_init_board(void)
44 {
45         volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
46         struct fsl_pci_info pci_info[2];
47         u32 devdisr, pordevsr;
48         int first_free_busno = 0;
49         int num = 0;
50
51         int pcie_ep, pcie_configured;
52
53         devdisr = in_be32(&gur->devdisr);
54         pordevsr = in_be32(&gur->pordevsr);
55
56         puts("\n");
57 #ifdef CONFIG_PCIE2
58         pcie_configured = is_serdes_configured(PCIE2);
59
60         if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
61                 SET_STD_PCIE_INFO(pci_info[num], 2);
62                 pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs);
63                 printf("PCIE2: connected to Slot 1 as %s (base addr %lx)\n",
64                         pcie_ep ? "Endpoint" : "Root Complex",
65                         pci_info[num].regs);
66                 first_free_busno = fsl_pci_init_port(&pci_info[num++],
67                                         &pcie2_hose, first_free_busno);
68         } else {
69                 printf("PCIE2: disabled\n");
70         }
71         puts("\n");
72 #else
73         setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
74 #endif
75
76 #ifdef CONFIG_PCIE1
77         pcie_configured = is_serdes_configured(PCIE1);
78
79         if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
80                 SET_STD_PCIE_INFO(pci_info[num], 1);
81                 pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
82                 printf("PCIE1: connected to Slot 2 as %s (base addr %lx)\n",
83                         pcie_ep ? "Endpoint" : "Root Complex",
84                         pci_info[num].regs);
85                 first_free_busno = fsl_pci_init_port(&pci_info[num++],
86                                         &pcie1_hose, first_free_busno);
87         } else {
88                 printf("PCIE1: disabled\n");
89         }
90         puts("\n");
91 #else
92         setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
93 #endif
94 }
95
96 void ft_pci_board_setup(void *blob)
97 {
98         FT_FSL_PCI_SETUP;
99 }