1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright 2018 NXP 4 */ 5 6 #ifndef _FSL_ICID_H_ 7 #define _FSL_ICID_H_ 8 9 #include <asm/types.h> 10 #include <fsl_qbman.h> 11 #include <fsl_sec.h> 12 13 struct icid_id_table { 14 const char *compat; 15 u32 id; 16 u32 reg; 17 phys_addr_t compat_addr; 18 phys_addr_t reg_addr; 19 }; 20 21 struct fman_icid_id_table { 22 u32 port_id; 23 u32 icid; 24 }; 25 26 u32 get_ppid_icid(int ppid_tbl_idx, int ppid); 27 int fdt_get_smmu_phandle(void *blob); 28 int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids); 29 void set_icids(void); 30 void fdt_fixup_icid(void *blob); 31 32 #define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \ 33 { .compat = name, \ 34 .id = idA, \ 35 .reg = regA, \ 36 .compat_addr = compataddr, \ 37 .reg_addr = addr, \ 38 } 39 40 #define SET_SCFG_ICID(compat, streamid, name, compataddr) \ 41 SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \ 42 offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \ 43 compataddr) 44 45 #define SET_USB_ICID(usb_num, compat, streamid) \ 46 SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\ 47 CONFIG_SYS_XHCI_USB##usb_num##_ADDR) 48 49 #define SET_SATA_ICID(compat, streamid) \ 50 SET_SCFG_ICID(compat, streamid, sata_icid,\ 51 AHCI_BASE_ADDR) 52 53 #define SET_SDHC_ICID(streamid) \ 54 SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\ 55 CONFIG_SYS_FSL_ESDHC_ADDR) 56 57 #define SET_QDMA_ICID(compat, streamid) \ 58 SET_SCFG_ICID(compat, streamid, dma_icid,\ 59 QDMA_BASE_ADDR) 60 61 #define SET_EDMA_ICID(streamid) \ 62 SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\ 63 EDMA_BASE_ADDR) 64 65 #define SET_ETR_ICID(streamid) \ 66 SET_SCFG_ICID(NULL, streamid, etr_icid, 0) 67 68 #define SET_DEBUG_ICID(streamid) \ 69 SET_SCFG_ICID(NULL, streamid, debug_icid, 0) 70 71 #define SET_QMAN_ICID(streamid) \ 72 SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ 73 offsetof(struct ccsr_qman, liodnr) + \ 74 CONFIG_SYS_FSL_QMAN_ADDR, \ 75 CONFIG_SYS_FSL_QMAN_ADDR) 76 77 #define SET_BMAN_ICID(streamid) \ 78 SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ 79 offsetof(struct ccsr_bman, liodnr) + \ 80 CONFIG_SYS_FSL_BMAN_ADDR, \ 81 CONFIG_SYS_FSL_BMAN_ADDR) 82 83 #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ 84 { .port_id = (_port_id), .icid = (streamid) } 85 86 #define SET_SEC_QI_ICID(streamid) \ 87 SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ 88 (((streamid) << 16) | (streamid)), \ 89 offsetof(ccsr_sec_t, qilcr_ls) + \ 90 CONFIG_SYS_FSL_SEC_ADDR, \ 91 CONFIG_SYS_FSL_SEC_ADDR) 92 93 #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ 94 SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \ 95 (((streamid) << 16) | (streamid)), \ 96 offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ 97 CONFIG_SYS_FSL_SEC_ADDR, \ 98 FSL_SEC_JR##jr_num##_BASE_ADDR) 99 100 #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ 101 SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 102 offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ 103 CONFIG_SYS_FSL_SEC_ADDR, 0) 104 105 #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ 106 SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 107 offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ 108 CONFIG_SYS_FSL_SEC_ADDR, 0) 109 110 extern struct icid_id_table icid_tbl[]; 111 extern struct fman_icid_id_table fman_icid_tbl[]; 112 extern int icid_tbl_sz; 113 extern int fman_icid_tbl_sz; 114 115 #endif 116