2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2006-06-28 15:43:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2004 Freescale Semiconductor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2007-11-29 06:11:44 +00:00
|
|
|
#include <fdt_support.h>
|
2006-09-13 15:33:56 +00:00
|
|
|
#include "cadmus.h"
|
|
|
|
|
2007-11-29 06:11:44 +00:00
|
|
|
#if defined(CONFIG_OF_BOARD_SETUP)
|
2019-08-27 11:05:16 +00:00
|
|
|
#if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI)
|
2006-09-13 15:33:56 +00:00
|
|
|
static void cds_pci_fixup(void *blob)
|
|
|
|
{
|
2011-11-09 16:01:06 +00:00
|
|
|
int node;
|
2007-11-29 06:11:44 +00:00
|
|
|
const char *path;
|
|
|
|
int len, slot, i;
|
2012-11-19 22:31:24 +00:00
|
|
|
u32 *map = NULL, *piccells = NULL;
|
|
|
|
int off, cells;
|
2006-09-13 15:33:56 +00:00
|
|
|
|
2007-11-29 06:11:44 +00:00
|
|
|
node = fdt_path_offset(blob, "/aliases");
|
|
|
|
if (node >= 0) {
|
|
|
|
path = fdt_getprop(blob, node, "pci0", NULL);
|
|
|
|
if (path) {
|
|
|
|
node = fdt_path_offset(blob, path);
|
|
|
|
if (node >= 0) {
|
|
|
|
map = fdt_getprop_w(blob, node, "interrupt-map", &len);
|
|
|
|
}
|
2012-11-19 22:31:24 +00:00
|
|
|
/* Each item in "interrupt-map" property is translated with
|
|
|
|
* following cells:
|
|
|
|
* PCI #address-cells, PCI #interrupt-cells,
|
|
|
|
* PIC address, PIC #address-cells, PIC #interrupt-cells.
|
|
|
|
*/
|
|
|
|
cells = fdt_getprop_u32_default(blob, path, "#address-cells", 1);
|
|
|
|
cells += fdt_getprop_u32_default(blob, path, "#interrupt-cells", 1);
|
|
|
|
off = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*(map+cells)));
|
|
|
|
if (off <= 0)
|
|
|
|
return;
|
|
|
|
cells += 1;
|
|
|
|
piccells = (u32 *)fdt_getprop(blob, off, "#address-cells", NULL);
|
|
|
|
if (piccells == NULL)
|
|
|
|
return;
|
|
|
|
cells += *piccells;
|
|
|
|
piccells = (u32 *)fdt_getprop(blob, off, "#interrupt-cells", NULL);
|
|
|
|
if (piccells == NULL)
|
|
|
|
return;
|
|
|
|
cells += *piccells;
|
2007-11-29 06:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-13 15:33:56 +00:00
|
|
|
|
2007-10-11 05:29:18 +00:00
|
|
|
if (map) {
|
|
|
|
len /= sizeof(u32);
|
2006-09-13 15:33:56 +00:00
|
|
|
|
2007-10-11 05:29:18 +00:00
|
|
|
slot = get_pci_slot();
|
2006-09-13 15:33:56 +00:00
|
|
|
|
2012-11-19 22:31:24 +00:00
|
|
|
for (i=0;i<len;i+=cells) {
|
2007-10-11 05:29:18 +00:00
|
|
|
/* We rotate the interrupt pins so that the mapping
|
|
|
|
* changes depending on the slot the carrier card is in.
|
|
|
|
*/
|
|
|
|
map[3] = ((map[3] + slot - 2) % 4) + 1;
|
2012-11-19 22:31:24 +00:00
|
|
|
map+=cells;
|
2007-10-11 05:29:18 +00:00
|
|
|
}
|
2006-09-13 15:33:56 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-27 11:05:16 +00:00
|
|
|
#endif
|
2006-06-28 15:43:36 +00:00
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int ft_board_setup(void *blob, struct bd_info *bd)
|
2006-06-28 15:43:36 +00:00
|
|
|
{
|
2007-11-29 06:11:44 +00:00
|
|
|
ft_cpu_setup(blob, bd);
|
2019-08-27 11:05:16 +00:00
|
|
|
#if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI)
|
2006-06-28 15:46:13 +00:00
|
|
|
ft_pci_setup(blob, bd);
|
2006-09-13 15:33:56 +00:00
|
|
|
cds_pci_fixup(blob);
|
2007-11-29 06:11:44 +00:00
|
|
|
#endif
|
2014-10-24 00:58:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2006-06-28 15:43:36 +00:00
|
|
|
}
|
|
|
|
#endif
|