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) \ 58a954f6feSLaurentiu Tudor SET_ICID_ENTRY(compat, streamid, (1 << 31) | (streamid), \ 59a954f6feSLaurentiu Tudor QDMA_BASE_ADDR + QMAN_CQSIDR_REG, \ 60a954f6feSLaurentiu Tudor QDMA_BASE_ADDR), \ 61a954f6feSLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (1 << 31) | (streamid), \ 62a954f6feSLaurentiu Tudor QDMA_BASE_ADDR + QMAN_CQSIDR_REG + 4, \ 633cb4fe65SLaurentiu Tudor QDMA_BASE_ADDR) 643cb4fe65SLaurentiu Tudor 653cb4fe65SLaurentiu Tudor #define SET_EDMA_ICID(streamid) \ 663cb4fe65SLaurentiu Tudor SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\ 673cb4fe65SLaurentiu Tudor EDMA_BASE_ADDR) 683cb4fe65SLaurentiu Tudor 693cb4fe65SLaurentiu Tudor #define SET_ETR_ICID(streamid) \ 703cb4fe65SLaurentiu Tudor SET_SCFG_ICID(NULL, streamid, etr_icid, 0) 713cb4fe65SLaurentiu Tudor 723cb4fe65SLaurentiu Tudor #define SET_DEBUG_ICID(streamid) \ 733cb4fe65SLaurentiu Tudor SET_SCFG_ICID(NULL, streamid, debug_icid, 0) 743cb4fe65SLaurentiu Tudor 75dc29a4c1SLaurentiu Tudor #define SET_QE_ICID(streamid) \ 76dc29a4c1SLaurentiu Tudor SET_SCFG_ICID("fsl,qe", streamid, qe_icid,\ 77dc29a4c1SLaurentiu Tudor QE_BASE_ADDR) 78dc29a4c1SLaurentiu Tudor 793cb4fe65SLaurentiu Tudor #define SET_QMAN_ICID(streamid) \ 803cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ 813cb4fe65SLaurentiu Tudor offsetof(struct ccsr_qman, liodnr) + \ 823cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR, \ 833cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR) 843cb4fe65SLaurentiu Tudor 853cb4fe65SLaurentiu Tudor #define SET_BMAN_ICID(streamid) \ 863cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ 873cb4fe65SLaurentiu Tudor offsetof(struct ccsr_bman, liodnr) + \ 883cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR, \ 893cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR) 903cb4fe65SLaurentiu Tudor 91b50ff5e1SLaurentiu Tudor #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ 92b50ff5e1SLaurentiu Tudor { .port_id = (_port_id), .icid = (streamid) } 93b50ff5e1SLaurentiu Tudor 945651f438SLaurentiu Tudor #define SET_SEC_QI_ICID(streamid) \ 955651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ 96*e82d9ee7SLaurentiu Tudor 0, offsetof(ccsr_sec_t, qilcr_ls) + \ 975651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 985651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR) 995651f438SLaurentiu Tudor 1005651f438SLaurentiu Tudor #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ 1015651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \ 1025651f438SLaurentiu Tudor (((streamid) << 16) | (streamid)), \ 1035651f438SLaurentiu Tudor offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ 1045651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 1055651f438SLaurentiu Tudor FSL_SEC_JR##jr_num##_BASE_ADDR) 1065651f438SLaurentiu Tudor 1075651f438SLaurentiu Tudor #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ 1085651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 1095651f438SLaurentiu Tudor offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ 1105651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 1115651f438SLaurentiu Tudor 1125651f438SLaurentiu Tudor #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ 1135651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 1145651f438SLaurentiu Tudor offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ 1155651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 1165651f438SLaurentiu Tudor 1173cb4fe65SLaurentiu Tudor extern struct icid_id_table icid_tbl[]; 118b50ff5e1SLaurentiu Tudor extern struct fman_icid_id_table fman_icid_tbl[]; 1193cb4fe65SLaurentiu Tudor extern int icid_tbl_sz; 120b50ff5e1SLaurentiu Tudor extern int fman_icid_tbl_sz; 1213cb4fe65SLaurentiu Tudor 1223cb4fe65SLaurentiu Tudor #endif 123