2 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
13 #include <fdt_support.h>
14 #include <asm/fsl_i2c.h>
15 #include <asm/fsl_mpc83xx_serdes.h>
17 static struct pci_region pci_regions
[] = {
19 bus_start
: CONFIG_SYS_PCI_MEM_BASE
,
20 phys_start
: CONFIG_SYS_PCI_MEM_PHYS
,
21 size
: CONFIG_SYS_PCI_MEM_SIZE
,
22 flags
: PCI_REGION_MEM
| PCI_REGION_PREFETCH
25 bus_start
: CONFIG_SYS_PCI_MMIO_BASE
,
26 phys_start
: CONFIG_SYS_PCI_MMIO_PHYS
,
27 size
: CONFIG_SYS_PCI_MMIO_SIZE
,
31 bus_start
: CONFIG_SYS_PCI_IO_BASE
,
32 phys_start
: CONFIG_SYS_PCI_IO_PHYS
,
33 size
: CONFIG_SYS_PCI_IO_SIZE
,
38 static struct pci_region pcie_regions_0
[] = {
40 .bus_start
= CONFIG_SYS_PCIE1_MEM_BASE
,
41 .phys_start
= CONFIG_SYS_PCIE1_MEM_PHYS
,
42 .size
= CONFIG_SYS_PCIE1_MEM_SIZE
,
43 .flags
= PCI_REGION_MEM
,
46 .bus_start
= CONFIG_SYS_PCIE1_IO_BASE
,
47 .phys_start
= CONFIG_SYS_PCIE1_IO_PHYS
,
48 .size
= CONFIG_SYS_PCIE1_IO_SIZE
,
49 .flags
= PCI_REGION_IO
,
53 static struct pci_region pcie_regions_1
[] = {
55 .bus_start
= CONFIG_SYS_PCIE2_MEM_BASE
,
56 .phys_start
= CONFIG_SYS_PCIE2_MEM_PHYS
,
57 .size
= CONFIG_SYS_PCIE2_MEM_SIZE
,
58 .flags
= PCI_REGION_MEM
,
61 .bus_start
= CONFIG_SYS_PCIE2_IO_BASE
,
62 .phys_start
= CONFIG_SYS_PCIE2_IO_PHYS
,
63 .size
= CONFIG_SYS_PCIE2_IO_SIZE
,
64 .flags
= PCI_REGION_IO
,
68 static int is_pex_x2(void)
70 const char *pex_x2
= getenv("pex_x2");
72 if (pex_x2
&& !strcmp(pex_x2
, "yes"))
77 void pci_init_board(void)
79 volatile immap_t
*immr
= (volatile immap_t
*)CONFIG_SYS_IMMR
;
80 volatile sysconf83xx_t
*sysconf
= &immr
->sysconf
;
81 volatile clk83xx_t
*clk
= (volatile clk83xx_t
*)&immr
->clk
;
82 volatile law83xx_t
*pci_law
= immr
->sysconf
.pcilaw
;
83 volatile law83xx_t
*pcie_law
= sysconf
->pcielaw
;
84 struct pci_region
*reg
[] = { pci_regions
};
85 struct pci_region
*pcie_reg
[] = { pcie_regions_0
, pcie_regions_1
, };
86 u32 spridr
= in_be32(&immr
->sysconf
.spridr
);
87 int pex2
= is_pex_x2();
89 if (board_pci_host_broken())
92 /* Enable all 5 PCI_CLK_OUTPUTS */
93 clk
->occr
|= 0xf8000000;
96 /* Configure PCI Local Access Windows */
97 pci_law
[0].bar
= CONFIG_SYS_PCI_MEM_PHYS
& LAWBAR_BAR
;
98 pci_law
[0].ar
= LBLAWAR_EN
| LBLAWAR_512MB
;
100 pci_law
[1].bar
= CONFIG_SYS_PCI_IO_PHYS
& LAWBAR_BAR
;
101 pci_law
[1].ar
= LBLAWAR_EN
| LBLAWAR_1MB
;
105 mpc83xx_pci_init(1, reg
);
107 /* There is no PEX in MPC8379 parts. */
108 if (PARTID_NO_E(spridr
) == SPR_8379
)
112 fsl_setup_serdes(CONFIG_FSL_SERDES2
, FSL_SERDES_PROTO_PEX_X2
,
113 FSL_SERDES_CLK_100
, FSL_SERDES_VDD_1V
);
115 fsl_setup_serdes(CONFIG_FSL_SERDES2
, FSL_SERDES_PROTO_PEX
,
116 FSL_SERDES_CLK_100
, FSL_SERDES_VDD_1V
);
118 /* Configure the clock for PCIE controller */
119 clrsetbits_be32(&clk
->sccr
, SCCR_PCIEXP1CM
| SCCR_PCIEXP2CM
,
120 SCCR_PCIEXP1CM_1
| SCCR_PCIEXP2CM_1
);
122 /* Deassert the resets in the control register */
123 out_be32(&sysconf
->pecr1
, 0xE0008000);
125 out_be32(&sysconf
->pecr2
, 0xE0008000);
128 /* Configure PCI Express Local Access Windows */
129 out_be32(&pcie_law
[0].bar
, CONFIG_SYS_PCIE1_BASE
& LAWBAR_BAR
);
130 out_be32(&pcie_law
[0].ar
, LBLAWAR_EN
| LBLAWAR_512MB
);
132 out_be32(&pcie_law
[1].bar
, CONFIG_SYS_PCIE2_BASE
& LAWBAR_BAR
);
133 out_be32(&pcie_law
[1].ar
, LBLAWAR_EN
| LBLAWAR_512MB
);
135 mpc83xx_pcie_init(pex2
? 1 : 2, pcie_reg
);
138 void ft_pcie_fixup(void *blob
, bd_t
*bd
)
140 const char *status
= "disabled (PCIE1 is x2)";
145 do_fixup_by_path(blob
, "pci2", "status", status
,
146 strlen(status
) + 1, 1);