1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2008 Extreme Engineering Solutions, Inc.
4 * Copyright 2007-2008 Freescale Semiconductor, Inc.
5 */
6
7 #include <common.h>
8 #include <init.h>
9 #include <pci.h>
10 #include <asm/fsl_pci.h>
11 #include <asm/fsl_serdes.h>
12 #include <asm/io.h>
13 #include <linux/compiler.h>
14 #include <linux/libfdt.h>
15 #include <fdt_support.h>
16
17
18 #ifdef CONFIG_PCI1
19 static struct pci_controller pci1_hose;
20 #endif
21
pci_init_board(void)22 void pci_init_board(void)
23 {
24 int first_free_busno = 0;
25
26 #ifdef CONFIG_PCI1
27 int pcie_ep;
28 struct fsl_pci_info pci_info;
29 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
30 u32 devdisr = in_be32(&gur->devdisr);
31 uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
32 uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
33 uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
34 uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
35 uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
36
37 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
38 SET_STD_PCI_INFO(pci_info, 1);
39 set_next_law(pci_info.mem_phys,
40 law_size_bits(pci_info.mem_size), pci_info.law);
41 set_next_law(pci_info.io_phys,
42 law_size_bits(pci_info.io_size), pci_info.law);
43
44 pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
45 printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
46 pci_32 ? 32 : 64,
47 pcix ? "PCIX" : "PCI",
48 pci_spd_norm ? ">=" : "<=",
49 pcix ? freq * 2 : freq,
50 pcie_ep ? "agent" : "host",
51 pci_arb ? "arbiter" : "external-arbiter");
52
53 first_free_busno = fsl_pci_init_port(&pci_info,
54 &pci1_hose, first_free_busno);
55 } else {
56 printf("PCI1: disabled\n");
57 }
58 #elif defined CONFIG_ARCH_MPC8548
59 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
60 /* PCI1 not present on MPC8572 */
61 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
62 #endif
63
64 fsl_pcie_init_board(first_free_busno);
65 }
66
67 #if defined(CONFIG_OF_BOARD_SETUP)
ft_board_pci_setup(void * blob,struct bd_info * bd)68 void ft_board_pci_setup(void *blob, struct bd_info *bd)
69 {
70 FT_FSL_PCI_SETUP;
71 }
72 #endif /* CONFIG_OF_BOARD_SETUP */
73