blob: 97d4f834b08ed700de6c6418a6066fbce43b2b33 [file] [log] [blame]
Poonam Aggrwalf857ed92009-08-21 07:29:58 +05301/*
Kumar Galad0f27d32010-07-08 22:37:44 -05002 * Copyright 2009-2010 Freescale Semiconductor, Inc.
Poonam Aggrwalf857ed92009-08-21 07:29:58 +05303 *
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/io.h>
28#include <asm/fsl_pci.h>
29#include <libfdt.h>
30#include <fdt_support.h>
31
32DECLARE_GLOBAL_DATA_PTR;
33
34#ifdef CONFIG_PCIE1
35static struct pci_controller pcie1_hose;
36#endif
37
38#ifdef CONFIG_PCIE2
39static struct pci_controller pcie2_hose;
40#endif
41
42void pci_init_board(void)
43{
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053044 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kumar Gala584fae52009-09-03 10:09:04 -050045 struct fsl_pci_info pci_info[2];
Kumar Gala5a0b9bd2009-11-04 13:01:38 -060046 u32 devdisr, pordevsr, io_sel;
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053047 int first_free_busno = 0;
Kumar Gala584fae52009-09-03 10:09:04 -050048 int num = 0;
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053049
50 int pcie_ep, pcie_configured;
51
Kumar Gala584fae52009-09-03 10:09:04 -050052 devdisr = in_be32(&gur->devdisr);
53 pordevsr = in_be32(&gur->pordevsr);
54 io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
Kumar Gala584fae52009-09-03 10:09:04 -050055
Kumar Gala5a0b9bd2009-11-04 13:01:38 -060056 debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053057
Kumar Gala584fae52009-09-03 10:09:04 -050058 if (!(pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS))
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053059 printf (" eTSEC2 is in sgmii mode.\n");
60
Kumar Gala584fae52009-09-03 10:09:04 -050061 puts("\n");
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053062#ifdef CONFIG_PCIE2
Kumar Gala666ced12009-09-02 09:03:08 -050063 pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_2, io_sel);
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053064
65 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
Kumar Gala584fae52009-09-03 10:09:04 -050066 SET_STD_PCIE_INFO(pci_info[num], 2);
Kumar Gala5a0b9bd2009-11-04 13:01:38 -060067 pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs);
Kumar Gala584fae52009-09-03 10:09:04 -050068 printf(" PCIE2 connected to Slot 1 as %s (base addr %lx)\n",
Peter Tyser62825a52010-01-17 15:38:26 -060069 pcie_ep ? "Endpoint" : "Root Complex",
Kumar Gala584fae52009-09-03 10:09:04 -050070 pci_info[num].regs);
71 first_free_busno = fsl_pci_init_port(&pci_info[num++],
Kumar Galab83ff072009-11-04 01:29:04 -060072 &pcie2_hose, first_free_busno);
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053073 } else {
74 printf (" PCIE2: disabled\n");
75 }
Kumar Gala584fae52009-09-03 10:09:04 -050076 puts("\n");
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053077#else
Kumar Gala584fae52009-09-03 10:09:04 -050078 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053079#endif
80
81#ifdef CONFIG_PCIE1
Kumar Gala666ced12009-09-02 09:03:08 -050082 pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_1, io_sel);
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053083
84 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
Kumar Gala584fae52009-09-03 10:09:04 -050085 SET_STD_PCIE_INFO(pci_info[num], 1);
Kumar Gala5a0b9bd2009-11-04 13:01:38 -060086 pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
Kumar Gala584fae52009-09-03 10:09:04 -050087 printf(" PCIE1 connected to Slot 2 as %s (base addr %lx)\n",
Peter Tyser62825a52010-01-17 15:38:26 -060088 pcie_ep ? "Endpoint" : "Root Complex",
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053089 pci_info[num].regs);
Kumar Gala584fae52009-09-03 10:09:04 -050090 first_free_busno = fsl_pci_init_port(&pci_info[num++],
Kumar Galab83ff072009-11-04 01:29:04 -060091 &pcie1_hose, first_free_busno);
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053092 } else {
93 printf (" PCIE1: disabled\n");
94 }
Kumar Gala584fae52009-09-03 10:09:04 -050095 puts("\n");
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053096#else
Kumar Gala584fae52009-09-03 10:09:04 -050097 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
Poonam Aggrwalf857ed92009-08-21 07:29:58 +053098#endif
99}
100
101void ft_pci_board_setup(void *blob)
102{
Kumar Galad0f27d32010-07-08 22:37:44 -0500103 FT_FSL_PCI_SETUP;
Poonam Aggrwalf857ed92009-08-21 07:29:58 +0530104}