blob: 28c83c7ca43f7081881b520631369506b9664a64 [file] [log] [blame]
Peter Tyser1c2b3292008-12-17 16:36:23 -06001/*
2 * Copyright 2008 Extreme Engineering Solutions, Inc.
3 * Copyright 2007-2008 Freescale Semiconductor, Inc.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <pci.h>
Kumar Gala9bbd6432009-04-02 13:22:48 -050026#include <asm/fsl_pci.h>
Kumar Gala3d020382010-12-15 04:55:20 -060027#include <asm/fsl_serdes.h>
Peter Tyser2b1a48d2009-08-07 13:16:34 -050028#include <asm/io.h>
Peter Tyser51944772010-10-22 00:20:22 -050029#include <linux/compiler.h>
Peter Tyser1c2b3292008-12-17 16:36:23 -060030#include <libfdt.h>
31#include <fdt_support.h>
32
Peter Tyser1c2b3292008-12-17 16:36:23 -060033
Peter Tyser59b5fdf2008-12-01 13:47:13 -060034#ifdef CONFIG_PCI1
35static struct pci_controller pci1_hose;
36#endif
Peter Tyser75379822009-05-22 10:26:35 -050037
Peter Tyser1c2b3292008-12-17 16:36:23 -060038void pci_init_board(void)
39{
Peter Tyser51944772010-10-22 00:20:22 -050040 int first_free_busno = 0;
Peter Tyser51944772010-10-22 00:20:22 -050041
Kumar Galaf330c6b2010-12-17 10:23:03 -060042#ifdef CONFIG_PCI1
43 int pcie_ep;
44 struct fsl_pci_info pci_info;
Peter Tyser1c2b3292008-12-17 16:36:23 -060045 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser51944772010-10-22 00:20:22 -050046 u32 devdisr = in_be32(&gur->devdisr);
Peter Tyser2b1a48d2009-08-07 13:16:34 -050047 uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
48 uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
49 uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
50 uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
Peter Tyser59b5fdf2008-12-01 13:47:13 -060051 uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
52
Peter Tyser59b5fdf2008-12-01 13:47:13 -060053 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
Kumar Galaf330c6b2010-12-17 10:23:03 -060054 SET_STD_PCI_INFO(pci_info, 1);
55 set_next_law(pci_info.mem_phys,
56 law_size_bits(pci_info.mem_size), pci_info.law);
57 set_next_law(pci_info.io_phys,
58 law_size_bits(pci_info.io_size), pci_info.law);
59
60 pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
Peter Tyser2b91f712010-10-29 17:59:24 -050061 printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060062 pci_32 ? 32 : 64,
63 pcix ? "PCIX" : "PCI",
Peter Tyser2b1a48d2009-08-07 13:16:34 -050064 pci_spd_norm ? ">=" : "<=",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060065 pcix ? freq * 2 : freq,
Peter Tyser51944772010-10-22 00:20:22 -050066 pcie_ep ? "agent" : "host",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060067 pci_arb ? "arbiter" : "external-arbiter");
68
Kumar Galaf330c6b2010-12-17 10:23:03 -060069 first_free_busno = fsl_pci_init_port(&pci_info,
Peter Tyser51944772010-10-22 00:20:22 -050070 &pci1_hose, first_free_busno);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060071 } else {
Peter Tyser2b91f712010-10-29 17:59:24 -050072 printf("PCI1: disabled\n");
Peter Tyser59b5fdf2008-12-01 13:47:13 -060073 }
74#elif defined CONFIG_MPC8548
Kumar Galaf330c6b2010-12-17 10:23:03 -060075 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060076 /* PCI1 not present on MPC8572 */
Peter Tyser2b1a48d2009-08-07 13:16:34 -050077 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060078#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060079
Kumar Galaf330c6b2010-12-17 10:23:03 -060080 fsl_pcie_init_board(first_free_busno);
Peter Tyser1c2b3292008-12-17 16:36:23 -060081}
82
83#if defined(CONFIG_OF_BOARD_SETUP)
Peter Tyser1c2b3292008-12-17 16:36:23 -060084void ft_board_pci_setup(void *blob, bd_t *bd)
85{
Kumar Galad0f27d32010-07-08 22:37:44 -050086 FT_FSL_PCI_SETUP;
Peter Tyser1c2b3292008-12-17 16:36:23 -060087}
88#endif /* CONFIG_OF_BOARD_SETUP */