xref: /openbmc/u-boot/board/xes/common/fsl_8xxx_pci.c (revision e30d2bd4)
1 /*
2  * Copyright 2008 Extreme Engineering Solutions, Inc.
3  * Copyright 2007-2008 Freescale Semiconductor, Inc.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.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 <libfdt.h>
15 #include <fdt_support.h>
16 
17 
18 #ifdef CONFIG_PCI1
19 static struct pci_controller pci1_hose;
20 #endif
21 
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)
68 void ft_board_pci_setup(void *blob, bd_t *bd)
69 {
70 	FT_FSL_PCI_SETUP;
71 }
72 #endif /* CONFIG_OF_BOARD_SETUP */
73