blob: 84ca4d12154196ac043aa17b7f5e3a30ac959ab7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peter Tyser1c2b3292008-12-17 16:36:23 -06002/*
3 * Copyright 2008 Extreme Engineering Solutions, Inc.
4 * Copyright 2007-2008 Freescale Semiconductor, Inc.
Peter Tyser1c2b3292008-12-17 16:36:23 -06005 */
6
7#include <common.h>
8#include <pci.h>
Kumar Gala9bbd6432009-04-02 13:22:48 -05009#include <asm/fsl_pci.h>
Kumar Gala3d020382010-12-15 04:55:20 -060010#include <asm/fsl_serdes.h>
Peter Tyser2b1a48d2009-08-07 13:16:34 -050011#include <asm/io.h>
Peter Tyser51944772010-10-22 00:20:22 -050012#include <linux/compiler.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090013#include <linux/libfdt.h>
Peter Tyser1c2b3292008-12-17 16:36:23 -060014#include <fdt_support.h>
15
Peter Tyser1c2b3292008-12-17 16:36:23 -060016
Peter Tyser59b5fdf2008-12-01 13:47:13 -060017#ifdef CONFIG_PCI1
18static struct pci_controller pci1_hose;
19#endif
Peter Tyser75379822009-05-22 10:26:35 -050020
Peter Tyser1c2b3292008-12-17 16:36:23 -060021void pci_init_board(void)
22{
Peter Tyser51944772010-10-22 00:20:22 -050023 int first_free_busno = 0;
Peter Tyser51944772010-10-22 00:20:22 -050024
Kumar Galaf330c6b2010-12-17 10:23:03 -060025#ifdef CONFIG_PCI1
26 int pcie_ep;
27 struct fsl_pci_info pci_info;
Peter Tyser1c2b3292008-12-17 16:36:23 -060028 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser51944772010-10-22 00:20:22 -050029 u32 devdisr = in_be32(&gur->devdisr);
Peter Tyser2b1a48d2009-08-07 13:16:34 -050030 uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
31 uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
32 uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
33 uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
Peter Tyser59b5fdf2008-12-01 13:47:13 -060034 uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
35
Peter Tyser59b5fdf2008-12-01 13:47:13 -060036 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
Kumar Galaf330c6b2010-12-17 10:23:03 -060037 SET_STD_PCI_INFO(pci_info, 1);
38 set_next_law(pci_info.mem_phys,
39 law_size_bits(pci_info.mem_size), pci_info.law);
40 set_next_law(pci_info.io_phys,
41 law_size_bits(pci_info.io_size), pci_info.law);
42
43 pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
Peter Tyser2b91f712010-10-29 17:59:24 -050044 printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060045 pci_32 ? 32 : 64,
46 pcix ? "PCIX" : "PCI",
Peter Tyser2b1a48d2009-08-07 13:16:34 -050047 pci_spd_norm ? ">=" : "<=",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060048 pcix ? freq * 2 : freq,
Peter Tyser51944772010-10-22 00:20:22 -050049 pcie_ep ? "agent" : "host",
Peter Tyser59b5fdf2008-12-01 13:47:13 -060050 pci_arb ? "arbiter" : "external-arbiter");
51
Kumar Galaf330c6b2010-12-17 10:23:03 -060052 first_free_busno = fsl_pci_init_port(&pci_info,
Peter Tyser51944772010-10-22 00:20:22 -050053 &pci1_hose, first_free_busno);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060054 } else {
Peter Tyser2b91f712010-10-29 17:59:24 -050055 printf("PCI1: disabled\n");
Peter Tyser59b5fdf2008-12-01 13:47:13 -060056 }
York Sunefc49e02016-11-15 13:52:34 -080057#elif defined CONFIG_ARCH_MPC8548
Kumar Galaf330c6b2010-12-17 10:23:03 -060058 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060059 /* PCI1 not present on MPC8572 */
Peter Tyser2b1a48d2009-08-07 13:16:34 -050060 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
Peter Tyser59b5fdf2008-12-01 13:47:13 -060061#endif
Peter Tyser1c2b3292008-12-17 16:36:23 -060062
Kumar Galaf330c6b2010-12-17 10:23:03 -060063 fsl_pcie_init_board(first_free_busno);
Peter Tyser1c2b3292008-12-17 16:36:23 -060064}
65
66#if defined(CONFIG_OF_BOARD_SETUP)
Peter Tyser1c2b3292008-12-17 16:36:23 -060067void ft_board_pci_setup(void *blob, bd_t *bd)
68{
Kumar Galad0f27d32010-07-08 22:37:44 -050069 FT_FSL_PCI_SETUP;
Peter Tyser1c2b3292008-12-17 16:36:23 -060070}
71#endif /* CONFIG_OF_BOARD_SETUP */