commit
b8a1f47be3
@ -0,0 +1,192 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2018 NXP |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <linux/libfdt.h> |
||||
#include <fdt_support.h> |
||||
|
||||
#include <asm/io.h> |
||||
#include <asm/processor.h> |
||||
#include <asm/arch-fsl-layerscape/fsl_icid.h> |
||||
#include <fsl_fman.h> |
||||
|
||||
static void set_icid(struct icid_id_table *tbl, int size) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < size; i++) |
||||
out_be32((u32 *)(tbl[i].reg_addr), tbl[i].reg); |
||||
} |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_FMAN |
||||
void set_fman_icids(struct fman_icid_id_table *tbl, int size) |
||||
{ |
||||
int i; |
||||
ccsr_fman_t *fm = (void *)CONFIG_SYS_FSL_FM1_ADDR; |
||||
|
||||
for (i = 0; i < size; i++) { |
||||
out_be32(&fm->fm_bmi_common.fmbm_ppid[tbl[i].port_id - 1], |
||||
tbl[i].icid); |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
void set_icids(void) |
||||
{ |
||||
/* setup general icid offsets */ |
||||
set_icid(icid_tbl, icid_tbl_sz); |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_FMAN |
||||
set_fman_icids(fman_icid_tbl, fman_icid_tbl_sz); |
||||
#endif |
||||
} |
||||
|
||||
int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids) |
||||
{ |
||||
int i, ret; |
||||
u32 prop[8]; |
||||
|
||||
/*
|
||||
* Note: The "iommus" property definition mentions Stream IDs while |
||||
* this code handles ICIDs. The current implementation assumes that |
||||
* ICIDs and Stream IDs are equal. |
||||
*/ |
||||
for (i = 0; i < num_ids; i++) { |
||||
prop[i * 2] = cpu_to_fdt32(smmu_ph); |
||||
prop[i * 2 + 1] = cpu_to_fdt32(ids[i]); |
||||
} |
||||
ret = fdt_setprop(blob, off, "iommus", |
||||
prop, sizeof(u32) * num_ids * 2); |
||||
if (ret) { |
||||
printf("WARNING unable to set iommus: %s\n", fdt_strerror(ret)); |
||||
return ret; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
int fdt_fixup_icid_tbl(void *blob, int smmu_ph, |
||||
struct icid_id_table *tbl, int size) |
||||
{ |
||||
int i, err, off; |
||||
|
||||
for (i = 0; i < size; i++) { |
||||
if (!tbl[i].compat) |
||||
continue; |
||||
|
||||
off = fdt_node_offset_by_compat_reg(blob, |
||||
tbl[i].compat, |
||||
tbl[i].compat_addr); |
||||
if (off > 0) { |
||||
err = fdt_set_iommu_prop(blob, off, smmu_ph, |
||||
&tbl[i].id, 1); |
||||
if (err) |
||||
return err; |
||||
} else { |
||||
printf("WARNING could not find node %s: %s.\n", |
||||
tbl[i].compat, fdt_strerror(off)); |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_FMAN |
||||
int get_fman_port_icid(int port_id, struct fman_icid_id_table *tbl, |
||||
const int size) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < size; i++) { |
||||
if (tbl[i].port_id == port_id) |
||||
return tbl[i].icid; |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
void fdt_fixup_fman_port_icid_by_compat(void *blob, int smmu_ph, |
||||
const char *compat) |
||||
{ |
||||
int noff, len, icid; |
||||
const u32 *prop; |
||||
|
||||
noff = fdt_node_offset_by_compatible(blob, -1, compat); |
||||
while (noff > 0) { |
||||
prop = fdt_getprop(blob, noff, "cell-index", &len); |
||||
if (!prop) { |
||||
printf("WARNING missing cell-index for fman port\n"); |
||||
continue; |
||||
} |
||||
if (len != 4) { |
||||
printf("WARNING bad cell-index size for fman port\n"); |
||||
continue; |
||||
} |
||||
|
||||
icid = get_fman_port_icid(fdt32_to_cpu(*prop), |
||||
fman_icid_tbl, fman_icid_tbl_sz); |
||||
if (icid < 0) { |
||||
printf("WARNING unknown ICID for fman port %d\n", |
||||
*prop); |
||||
continue; |
||||
} |
||||
|
||||
fdt_set_iommu_prop(blob, noff, smmu_ph, (u32 *)&icid, 1); |
||||
|
||||
noff = fdt_node_offset_by_compatible(blob, noff, compat); |
||||
} |
||||
} |
||||
|
||||
void fdt_fixup_fman_icids(void *blob, int smmu_ph) |
||||
{ |
||||
static const char * const compats[] = { |
||||
"fsl,fman-v3-port-oh", |
||||
"fsl,fman-v3-port-rx", |
||||
"fsl,fman-v3-port-tx", |
||||
}; |
||||
int i; |
||||
|
||||
for (i = 0; i < ARRAY_SIZE(compats); i++) |
||||
fdt_fixup_fman_port_icid_by_compat(blob, smmu_ph, compats[i]); |
||||
} |
||||
#endif |
||||
|
||||
int fdt_get_smmu_phandle(void *blob) |
||||
{ |
||||
int noff, smmu_ph; |
||||
|
||||
noff = fdt_node_offset_by_compatible(blob, -1, "arm,mmu-500"); |
||||
if (noff < 0) { |
||||
printf("WARNING failed to get smmu node: %s\n", |
||||
fdt_strerror(noff)); |
||||
return noff; |
||||
} |
||||
|
||||
smmu_ph = fdt_get_phandle(blob, noff); |
||||
if (!smmu_ph) { |
||||
smmu_ph = fdt_create_phandle(blob, noff); |
||||
if (!smmu_ph) { |
||||
printf("WARNING failed to get smmu phandle\n"); |
||||
return -1; |
||||
} |
||||
} |
||||
|
||||
return smmu_ph; |
||||
} |
||||
|
||||
void fdt_fixup_icid(void *blob) |
||||
{ |
||||
int smmu_ph; |
||||
|
||||
smmu_ph = fdt_get_smmu_phandle(blob); |
||||
if (smmu_ph < 0) |
||||
return; |
||||
|
||||
fdt_fixup_icid_tbl(blob, smmu_ph, icid_tbl, icid_tbl_sz); |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_FMAN |
||||
fdt_fixup_fman_icids(blob, smmu_ph); |
||||
#endif |
||||
} |
@ -0,0 +1,89 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2018 NXP |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <asm/arch-fsl-layerscape/immap_lsch2.h> |
||||
#include <asm/arch-fsl-layerscape/fsl_icid.h> |
||||
#include <asm/arch-fsl-layerscape/fsl_portals.h> |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_QBMAN |
||||
struct qportal_info qp_info[CONFIG_SYS_QMAN_NUM_PORTALS] = { |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0), |
||||
}; |
||||
#endif |
||||
|
||||
struct icid_id_table icid_tbl[] = { |
||||
#ifdef CONFIG_SYS_DPAA_QBMAN |
||||
SET_QMAN_ICID(FSL_DPAA1_STREAM_ID_START), |
||||
SET_BMAN_ICID(FSL_DPAA1_STREAM_ID_START + 1), |
||||
#endif |
||||
|
||||
SET_SDHC_ICID(FSL_SDHC_STREAM_ID), |
||||
|
||||
SET_USB_ICID(1, "snps,dwc3", FSL_USB1_STREAM_ID), |
||||
SET_USB_ICID(2, "snps,dwc3", FSL_USB2_STREAM_ID), |
||||
SET_USB_ICID(3, "snps,dwc3", FSL_USB3_STREAM_ID), |
||||
|
||||
SET_SATA_ICID("fsl,ls1046a-ahci", FSL_SATA_STREAM_ID), |
||||
SET_QDMA_ICID("fsl,ls1046a-qdma", FSL_QDMA_STREAM_ID), |
||||
SET_EDMA_ICID(FSL_EDMA_STREAM_ID), |
||||
SET_ETR_ICID(FSL_ETR_STREAM_ID), |
||||
SET_DEBUG_ICID(FSL_DEBUG_STREAM_ID), |
||||
#ifdef CONFIG_FSL_CAAM |
||||
SET_SEC_QI_ICID(FSL_DPAA1_STREAM_ID_START + 2), |
||||
SET_SEC_JR_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 3), |
||||
SET_SEC_JR_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 4), |
||||
SET_SEC_JR_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 5), |
||||
SET_SEC_JR_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 6), |
||||
SET_SEC_RTIC_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 7), |
||||
SET_SEC_RTIC_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 8), |
||||
SET_SEC_RTIC_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 9), |
||||
SET_SEC_RTIC_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 10), |
||||
SET_SEC_DECO_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 11), |
||||
SET_SEC_DECO_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 12), |
||||
SET_SEC_DECO_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 13), |
||||
#endif |
||||
}; |
||||
|
||||
int icid_tbl_sz = ARRAY_SIZE(icid_tbl); |
||||
|
||||
#ifdef CONFIG_SYS_DPAA_FMAN |
||||
struct fman_icid_id_table fman_icid_tbl[] = { |
||||
/* port id, icid */ |
||||
SET_FMAN_ICID_ENTRY(0x02, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x03, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x04, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x05, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x06, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x07, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x08, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x09, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x0a, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x0b, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x0c, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x0d, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x28, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x29, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x2a, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x2b, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x2c, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x2d, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x10, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x11, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x30, FSL_DPAA1_STREAM_ID_END), |
||||
SET_FMAN_ICID_ENTRY(0x31, FSL_DPAA1_STREAM_ID_END), |
||||
}; |
||||
|
||||
int fman_icid_tbl_sz = ARRAY_SIZE(fman_icid_tbl); |
||||
#endif |
@ -0,0 +1,115 @@ |
||||
/* SPDX-License-Identifier: GPL-2.0+ */ |
||||
/*
|
||||
* Copyright 2018 NXP |
||||
*/ |
||||
|
||||
#ifndef _FSL_ICID_H_ |
||||
#define _FSL_ICID_H_ |
||||
|
||||
#include <asm/types.h> |
||||
#include <fsl_qbman.h> |
||||
#include <fsl_sec.h> |
||||
|
||||
struct icid_id_table { |
||||
const char *compat; |
||||
u32 id; |
||||
u32 reg; |
||||
phys_addr_t compat_addr; |
||||
phys_addr_t reg_addr; |
||||
}; |
||||
|
||||
struct fman_icid_id_table { |
||||
u32 port_id; |
||||
u32 icid; |
||||
}; |
||||
|
||||
u32 get_ppid_icid(int ppid_tbl_idx, int ppid); |
||||
int fdt_get_smmu_phandle(void *blob); |
||||
int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids); |
||||
void set_icids(void); |
||||
void fdt_fixup_icid(void *blob); |
||||
|
||||
#define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \ |
||||
{ .compat = name, \
|
||||
.id = idA, \
|
||||
.reg = regA, \
|
||||
.compat_addr = compataddr, \
|
||||
.reg_addr = addr, \
|
||||
} |
||||
|
||||
#define SET_SCFG_ICID(compat, streamid, name, compataddr) \ |
||||
SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \
|
||||
offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \
|
||||
compataddr) |
||||
|
||||
#define SET_USB_ICID(usb_num, compat, streamid) \ |
||||
SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\
|
||||
CONFIG_SYS_XHCI_USB##usb_num##_ADDR) |
||||
|
||||
#define SET_SATA_ICID(compat, streamid) \ |
||||
SET_SCFG_ICID(compat, streamid, sata_icid,\
|
||||
AHCI_BASE_ADDR) |
||||
|
||||
#define SET_SDHC_ICID(streamid) \ |
||||
SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\
|
||||
CONFIG_SYS_FSL_ESDHC_ADDR) |
||||
|
||||
#define SET_QDMA_ICID(compat, streamid) \ |
||||
SET_SCFG_ICID(compat, streamid, dma_icid,\
|
||||
QDMA_BASE_ADDR) |
||||
|
||||
#define SET_EDMA_ICID(streamid) \ |
||||
SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\
|
||||
EDMA_BASE_ADDR) |
||||
|
||||
#define SET_ETR_ICID(streamid) \ |
||||
SET_SCFG_ICID(NULL, streamid, etr_icid, 0) |
||||
|
||||
#define SET_DEBUG_ICID(streamid) \ |
||||
SET_SCFG_ICID(NULL, streamid, debug_icid, 0) |
||||
|
||||
#define SET_QMAN_ICID(streamid) \ |
||||
SET_ICID_ENTRY("fsl,qman", streamid, streamid, \
|
||||
offsetof(struct ccsr_qman, liodnr) + \
|
||||
CONFIG_SYS_FSL_QMAN_ADDR, \
|
||||
CONFIG_SYS_FSL_QMAN_ADDR) |
||||
|
||||
#define SET_BMAN_ICID(streamid) \ |
||||
SET_ICID_ENTRY("fsl,bman", streamid, streamid, \
|
||||
offsetof(struct ccsr_bman, liodnr) + \
|
||||
CONFIG_SYS_FSL_BMAN_ADDR, \
|
||||
CONFIG_SYS_FSL_BMAN_ADDR) |
||||
|
||||
#define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ |
||||
{ .port_id = (_port_id), .icid = (streamid) } |
||||
|
||||
#define SET_SEC_QI_ICID(streamid) \ |
||||
SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \
|
||||
(((streamid) << 16) | (streamid)), \
|
||||
offsetof(ccsr_sec_t, qilcr_ls) + \
|
||||
CONFIG_SYS_FSL_SEC_ADDR, \
|
||||
CONFIG_SYS_FSL_SEC_ADDR) |
||||
|
||||
#define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ |
||||
SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \
|
||||
(((streamid) << 16) | (streamid)), \
|
||||
offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \
|
||||
CONFIG_SYS_FSL_SEC_ADDR, \
|
||||
FSL_SEC_JR##jr_num##_BASE_ADDR) |
||||
|
||||
#define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ |
||||
SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
|
||||
offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \
|
||||
CONFIG_SYS_FSL_SEC_ADDR, 0) |
||||
|
||||
#define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ |
||||
SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
|
||||
offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \
|
||||
CONFIG_SYS_FSL_SEC_ADDR, 0) |
||||
|
||||
extern struct icid_id_table icid_tbl[]; |
||||
extern struct fman_icid_id_table fman_icid_tbl[]; |
||||
extern int icid_tbl_sz; |
||||
extern int fman_icid_tbl_sz; |
||||
|
||||
#endif |
@ -0,0 +1,24 @@ |
||||
/* SPDX-License-Identifier: GPL-2.0+ */ |
||||
/*
|
||||
* Copyright 2018 NXP |
||||
*/ |
||||
|
||||
#ifndef _FSL_PORTALS_H_ |
||||
#define _FSL_PORTALS_H_ |
||||
|
||||
struct qportal_info { |
||||
u16 dicid; /* DQRR ICID */ |
||||
u16 ficid; /* frame data ICID */ |
||||
u16 icid; |
||||
u8 sdest; |
||||
}; |
||||
|
||||
#define SET_QP_INFO(streamid, dest) \ |
||||
{ .dicid = (streamid), .ficid = (streamid), .icid = (streamid), \
|
||||
.sdest = (dest) } |
||||
|
||||
extern struct qportal_info qp_info[]; |
||||
void fdt_portal(void *blob, const char *compat, const char *container, |
||||
u64 addr, u32 size); |
||||
|
||||
#endif |
Loading…
Reference in new issue