diff options
Diffstat (limited to 'arch/powerpc/cpu/mpc85xx/liodn.c')
| -rw-r--r-- | arch/powerpc/cpu/mpc85xx/liodn.c | 60 | 
1 files changed, 60 insertions, 0 deletions
| diff --git a/arch/powerpc/cpu/mpc85xx/liodn.c b/arch/powerpc/cpu/mpc85xx/liodn.c index 11881c948..2e533672f 100644 --- a/arch/powerpc/cpu/mpc85xx/liodn.c +++ b/arch/powerpc/cpu/mpc85xx/liodn.c @@ -40,6 +40,7 @@ int get_dpaa_liodn(enum fsl_dpaa_dev dpaa_dev, u32 *liodns, int liodn_offset)  	return liodn_bases[dpaa_dev].num_ids;  } +#ifdef CONFIG_SYS_SRIO  static void set_srio_liodn(struct srio_liodn_id_table *tbl, int size)  {  	int i; @@ -54,6 +55,7 @@ static void set_srio_liodn(struct srio_liodn_id_table *tbl, int size)  		}  	}  } +#endif  static void set_liodn(struct liodn_id_table *tbl, int size)  { @@ -181,8 +183,10 @@ void set_liodns(void)  	/* setup general liodn offsets */  	set_liodn(liodn_tbl, liodn_tbl_sz); +#ifdef CONFIG_SYS_SRIO  	/* setup SRIO port liodns */  	set_srio_liodn(srio_liodn_tbl, srio_liodn_tbl_sz); +#endif  	/* setup SEC block liodn bases & offsets if we have one */  	if (IS_E_PROCESSOR(get_svr())) { @@ -219,6 +223,7 @@ void set_liodns(void)  #endif  } +#ifdef CONFIG_SYS_SRIO  static void fdt_fixup_srio_liodn(void *blob, struct srio_liodn_id_table *tbl)  {  	int i, srio_off; @@ -247,6 +252,57 @@ static void fdt_fixup_srio_liodn(void *blob, struct srio_liodn_id_table *tbl)  		}  	}  } +#endif + +#define CONFIG_SYS_MAX_PCI_EPS		8 +#define CONFIG_SYS_PCI_EP_LIODN_START	256 + +static void fdt_fixup_pci_liodn_offsets(void *fdt, const char *compat) +{ +	int off, pci_idx = 0, pci_cnt = 0, i, rc; +	const uint32_t *base_liodn; +	uint32_t liodn_offs[CONFIG_SYS_MAX_PCI_EPS + 1] = { 0 }; + +	/* +	 * Count the number of pci nodes. +	 * It's needed later when the interleaved liodn offsets are generated. +	 */ +	off = fdt_node_offset_by_compatible(fdt, -1, compat); +	while (off != -FDT_ERR_NOTFOUND) { +		pci_cnt++; +		off = fdt_node_offset_by_compatible(fdt, off, compat); +	} + +	for (off = fdt_node_offset_by_compatible(fdt, -1, compat); +	     off != -FDT_ERR_NOTFOUND; +	     off = fdt_node_offset_by_compatible(fdt, off, compat)) { +		base_liodn = fdt_getprop(fdt, off, "fsl,liodn", &rc); +		if (!base_liodn) { +			char path[64]; + +			if (fdt_get_path(fdt, off, path, sizeof(path)) < 0) +				strcpy(path, "(unknown)"); +			printf("WARNING Could not get liodn of node %s: %s\n", +			       path, fdt_strerror(rc)); +			continue; +		} +		for (i = 0; i < CONFIG_SYS_MAX_PCI_EPS; i++) +			liodn_offs[i + 1] = CONFIG_SYS_PCI_EP_LIODN_START + +					i * pci_cnt + pci_idx - *base_liodn; +		rc = fdt_setprop(fdt, off, "fsl,liodn-offset-list", +				 liodn_offs, sizeof(liodn_offs)); +		if (rc) { +			char path[64]; + +			if (fdt_get_path(fdt, off, path, sizeof(path)) < 0) +				strcpy(path, "(unknown)"); +			printf("WARNING Unable to set fsl,liodn-offset-list for " +			       "node %s: %s\n", path, fdt_strerror(rc)); +			continue; +		} +		pci_idx++; +	} +}  static void fdt_fixup_liodn_tbl(void *blob, struct liodn_id_table *tbl, int sz)  { @@ -277,7 +333,9 @@ static void fdt_fixup_liodn_tbl(void *blob, struct liodn_id_table *tbl, int sz)  void fdt_fixup_liodn(void *blob)  { +#ifdef CONFIG_SYS_SRIO  	fdt_fixup_srio_liodn(blob, srio_liodn_tbl); +#endif  	fdt_fixup_liodn_tbl(blob, liodn_tbl, liodn_tbl_sz);  #ifdef CONFIG_SYS_DPAA_FMAN @@ -295,4 +353,6 @@ void fdt_fixup_liodn(void *blob)  #ifdef CONFIG_SYS_DPAA_RMAN  	fdt_fixup_liodn_tbl(blob, rman_liodn_tbl, rman_liodn_tbl_sz);  #endif + +	fdt_fixup_pci_liodn_offsets(blob, "fsl,qoriq-pcie-v2.4");  } |