2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-04-16 19:34:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) Freescale Semiconductor, Inc. 2007
|
|
|
|
*
|
|
|
|
* Author: Scott Wood <scottwood@freescale.com>,
|
|
|
|
* with some bits from older board-specific PCI initialization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2007-04-16 19:34:21 +00:00
|
|
|
#include <pci.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <asm/bitops.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2007-07-26 00:25:28 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2007-12-20 20:09:22 +00:00
|
|
|
#include <fdt_support.h>
|
2007-07-26 00:25:28 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-16 19:34:21 +00:00
|
|
|
#include <asm/mpc8349_pci.h>
|
|
|
|
|
|
|
|
#define MAX_BUSES 2
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
static struct pci_controller pci_hose[MAX_BUSES];
|
|
|
|
static int pci_num_buses;
|
|
|
|
|
2007-07-26 00:25:28 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
2020-06-26 06:13:33 +00:00
|
|
|
void ft_pci_setup(void *blob, struct bd_info *bd)
|
2007-07-26 00:25:28 +00:00
|
|
|
{
|
|
|
|
int nodeoffset;
|
|
|
|
int tmp[2];
|
2007-12-20 20:09:22 +00:00
|
|
|
const char *path;
|
2007-07-26 00:25:28 +00:00
|
|
|
|
|
|
|
if (pci_num_buses < 1)
|
|
|
|
return;
|
|
|
|
|
2007-12-20 20:09:22 +00:00
|
|
|
nodeoffset = fdt_path_offset(blob, "/aliases");
|
2007-07-26 00:25:28 +00:00
|
|
|
if (nodeoffset >= 0) {
|
2007-12-20 20:09:22 +00:00
|
|
|
path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
|
|
|
|
if (path) {
|
|
|
|
tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
|
|
|
|
tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
|
|
|
|
do_fixup_by_path(blob, path, "bus-range",
|
|
|
|
&tmp, sizeof(tmp), 1);
|
|
|
|
|
|
|
|
tmp[0] = cpu_to_be32(gd->pci_clk);
|
|
|
|
do_fixup_by_path(blob, path, "clock-frequency",
|
|
|
|
&tmp, sizeof(tmp[0]), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pci_num_buses < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = fdt_getprop(blob, nodeoffset, "pci1", NULL);
|
|
|
|
if (path) {
|
2009-02-19 15:20:46 +00:00
|
|
|
tmp[0] = cpu_to_be32(pci_hose[1].first_busno);
|
|
|
|
tmp[1] = cpu_to_be32(pci_hose[1].last_busno);
|
2007-12-20 20:09:22 +00:00
|
|
|
do_fixup_by_path(blob, path, "bus-range",
|
|
|
|
&tmp, sizeof(tmp), 1);
|
|
|
|
|
|
|
|
tmp[0] = cpu_to_be32(gd->pci_clk);
|
|
|
|
do_fixup_by_path(blob, path, "clock-frequency",
|
|
|
|
&tmp, sizeof(tmp[0]), 1);
|
|
|
|
}
|
2007-04-16 19:34:21 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-20 20:09:22 +00:00
|
|
|
#endif /* CONFIG_OF_LIBFDT */
|