13cb4fe65SLaurentiu Tudor /* SPDX-License-Identifier: GPL-2.0+ */ 23cb4fe65SLaurentiu Tudor /* 33cb4fe65SLaurentiu Tudor * Copyright 2018 NXP 43cb4fe65SLaurentiu Tudor */ 53cb4fe65SLaurentiu Tudor 63cb4fe65SLaurentiu Tudor #ifndef _FSL_ICID_H_ 73cb4fe65SLaurentiu Tudor #define _FSL_ICID_H_ 83cb4fe65SLaurentiu Tudor 93cb4fe65SLaurentiu Tudor #include <asm/types.h> 103cb4fe65SLaurentiu Tudor #include <fsl_qbman.h> 115651f438SLaurentiu Tudor #include <fsl_sec.h> 123cb4fe65SLaurentiu Tudor 133cb4fe65SLaurentiu Tudor struct icid_id_table { 143cb4fe65SLaurentiu Tudor const char *compat; 153cb4fe65SLaurentiu Tudor u32 id; 163cb4fe65SLaurentiu Tudor u32 reg; 173cb4fe65SLaurentiu Tudor phys_addr_t compat_addr; 183cb4fe65SLaurentiu Tudor phys_addr_t reg_addr; 193cb4fe65SLaurentiu Tudor }; 203cb4fe65SLaurentiu Tudor 21b50ff5e1SLaurentiu Tudor struct fman_icid_id_table { 22b50ff5e1SLaurentiu Tudor u32 port_id; 23b50ff5e1SLaurentiu Tudor u32 icid; 24b50ff5e1SLaurentiu Tudor }; 25b50ff5e1SLaurentiu Tudor 263cb4fe65SLaurentiu Tudor u32 get_ppid_icid(int ppid_tbl_idx, int ppid); 273cb4fe65SLaurentiu Tudor int fdt_get_smmu_phandle(void *blob); 283cb4fe65SLaurentiu Tudor int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids); 293cb4fe65SLaurentiu Tudor void set_icids(void); 303cb4fe65SLaurentiu Tudor void fdt_fixup_icid(void *blob); 313cb4fe65SLaurentiu Tudor 323cb4fe65SLaurentiu Tudor #define SET_ICID_ENTRY(name, idA, regA, addr, compataddr) \ 333cb4fe65SLaurentiu Tudor { .compat = name, \ 343cb4fe65SLaurentiu Tudor .id = idA, \ 353cb4fe65SLaurentiu Tudor .reg = regA, \ 363cb4fe65SLaurentiu Tudor .compat_addr = compataddr, \ 373cb4fe65SLaurentiu Tudor .reg_addr = addr, \ 383cb4fe65SLaurentiu Tudor } 393cb4fe65SLaurentiu Tudor 403cb4fe65SLaurentiu Tudor #define SET_SCFG_ICID(compat, streamid, name, compataddr) \ 413cb4fe65SLaurentiu Tudor SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \ 423cb4fe65SLaurentiu Tudor offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \ 433cb4fe65SLaurentiu Tudor compataddr) 443cb4fe65SLaurentiu Tudor 453cb4fe65SLaurentiu Tudor #define SET_USB_ICID(usb_num, compat, streamid) \ 463cb4fe65SLaurentiu Tudor SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\ 473cb4fe65SLaurentiu Tudor CONFIG_SYS_XHCI_USB##usb_num##_ADDR) 483cb4fe65SLaurentiu Tudor 493cb4fe65SLaurentiu Tudor #define SET_SATA_ICID(compat, streamid) \ 503cb4fe65SLaurentiu Tudor SET_SCFG_ICID(compat, streamid, sata_icid,\ 513cb4fe65SLaurentiu Tudor AHCI_BASE_ADDR) 523cb4fe65SLaurentiu Tudor 533cb4fe65SLaurentiu Tudor #define SET_SDHC_ICID(streamid) \ 543cb4fe65SLaurentiu Tudor SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\ 553cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_ESDHC_ADDR) 563cb4fe65SLaurentiu Tudor 573cb4fe65SLaurentiu Tudor #define SET_QDMA_ICID(compat, streamid) \ 583cb4fe65SLaurentiu Tudor SET_SCFG_ICID(compat, streamid, dma_icid,\ 593cb4fe65SLaurentiu Tudor QDMA_BASE_ADDR) 603cb4fe65SLaurentiu Tudor 613cb4fe65SLaurentiu Tudor #define SET_EDMA_ICID(streamid) \ 623cb4fe65SLaurentiu Tudor SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\ 633cb4fe65SLaurentiu Tudor EDMA_BASE_ADDR) 643cb4fe65SLaurentiu Tudor 653cb4fe65SLaurentiu Tudor #define SET_ETR_ICID(streamid) \ 663cb4fe65SLaurentiu Tudor SET_SCFG_ICID(NULL, streamid, etr_icid, 0) 673cb4fe65SLaurentiu Tudor 683cb4fe65SLaurentiu Tudor #define SET_DEBUG_ICID(streamid) \ 693cb4fe65SLaurentiu Tudor SET_SCFG_ICID(NULL, streamid, debug_icid, 0) 703cb4fe65SLaurentiu Tudor 71*dc29a4c1SLaurentiu Tudor #define SET_QE_ICID(streamid) \ 72*dc29a4c1SLaurentiu Tudor SET_SCFG_ICID("fsl,qe", streamid, qe_icid,\ 73*dc29a4c1SLaurentiu Tudor QE_BASE_ADDR) 74*dc29a4c1SLaurentiu Tudor 753cb4fe65SLaurentiu Tudor #define SET_QMAN_ICID(streamid) \ 763cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ 773cb4fe65SLaurentiu Tudor offsetof(struct ccsr_qman, liodnr) + \ 783cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR, \ 793cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR) 803cb4fe65SLaurentiu Tudor 813cb4fe65SLaurentiu Tudor #define SET_BMAN_ICID(streamid) \ 823cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ 833cb4fe65SLaurentiu Tudor offsetof(struct ccsr_bman, liodnr) + \ 843cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR, \ 853cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR) 863cb4fe65SLaurentiu Tudor 87b50ff5e1SLaurentiu Tudor #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ 88b50ff5e1SLaurentiu Tudor { .port_id = (_port_id), .icid = (streamid) } 89b50ff5e1SLaurentiu Tudor 905651f438SLaurentiu Tudor #define SET_SEC_QI_ICID(streamid) \ 915651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ 925651f438SLaurentiu Tudor (((streamid) << 16) | (streamid)), \ 935651f438SLaurentiu Tudor offsetof(ccsr_sec_t, qilcr_ls) + \ 945651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 955651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR) 965651f438SLaurentiu Tudor 975651f438SLaurentiu Tudor #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ 985651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \ 995651f438SLaurentiu Tudor (((streamid) << 16) | (streamid)), \ 1005651f438SLaurentiu Tudor offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ 1015651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 1025651f438SLaurentiu Tudor FSL_SEC_JR##jr_num##_BASE_ADDR) 1035651f438SLaurentiu Tudor 1045651f438SLaurentiu Tudor #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ 1055651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 1065651f438SLaurentiu Tudor offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ 1075651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 1085651f438SLaurentiu Tudor 1095651f438SLaurentiu Tudor #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ 1105651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 1115651f438SLaurentiu Tudor offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ 1125651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 1135651f438SLaurentiu Tudor 1143cb4fe65SLaurentiu Tudor extern struct icid_id_table icid_tbl[]; 115b50ff5e1SLaurentiu Tudor extern struct fman_icid_id_table fman_icid_tbl[]; 1163cb4fe65SLaurentiu Tudor extern int icid_tbl_sz; 117b50ff5e1SLaurentiu Tudor extern int fman_icid_tbl_sz; 1183cb4fe65SLaurentiu Tudor 1193cb4fe65SLaurentiu Tudor #endif 120