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> 11*5651f438SLaurentiu 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 713cb4fe65SLaurentiu Tudor #define SET_QMAN_ICID(streamid) \ 723cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ 733cb4fe65SLaurentiu Tudor offsetof(struct ccsr_qman, liodnr) + \ 743cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR, \ 753cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_QMAN_ADDR) 763cb4fe65SLaurentiu Tudor 773cb4fe65SLaurentiu Tudor #define SET_BMAN_ICID(streamid) \ 783cb4fe65SLaurentiu Tudor SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ 793cb4fe65SLaurentiu Tudor offsetof(struct ccsr_bman, liodnr) + \ 803cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR, \ 813cb4fe65SLaurentiu Tudor CONFIG_SYS_FSL_BMAN_ADDR) 823cb4fe65SLaurentiu Tudor 83b50ff5e1SLaurentiu Tudor #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ 84b50ff5e1SLaurentiu Tudor { .port_id = (_port_id), .icid = (streamid) } 85b50ff5e1SLaurentiu Tudor 86*5651f438SLaurentiu Tudor #define SET_SEC_QI_ICID(streamid) \ 87*5651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ 88*5651f438SLaurentiu Tudor (((streamid) << 16) | (streamid)), \ 89*5651f438SLaurentiu Tudor offsetof(ccsr_sec_t, qilcr_ls) + \ 90*5651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 91*5651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR) 92*5651f438SLaurentiu Tudor 93*5651f438SLaurentiu Tudor #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ 94*5651f438SLaurentiu Tudor SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \ 95*5651f438SLaurentiu Tudor (((streamid) << 16) | (streamid)), \ 96*5651f438SLaurentiu Tudor offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ 97*5651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, \ 98*5651f438SLaurentiu Tudor FSL_SEC_JR##jr_num##_BASE_ADDR) 99*5651f438SLaurentiu Tudor 100*5651f438SLaurentiu Tudor #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ 101*5651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 102*5651f438SLaurentiu Tudor offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ 103*5651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 104*5651f438SLaurentiu Tudor 105*5651f438SLaurentiu Tudor #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ 106*5651f438SLaurentiu Tudor SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ 107*5651f438SLaurentiu Tudor offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ 108*5651f438SLaurentiu Tudor CONFIG_SYS_FSL_SEC_ADDR, 0) 109*5651f438SLaurentiu Tudor 1103cb4fe65SLaurentiu Tudor extern struct icid_id_table icid_tbl[]; 111b50ff5e1SLaurentiu Tudor extern struct fman_icid_id_table fman_icid_tbl[]; 1123cb4fe65SLaurentiu Tudor extern int icid_tbl_sz; 113b50ff5e1SLaurentiu Tudor extern int fman_icid_tbl_sz; 1143cb4fe65SLaurentiu Tudor 1153cb4fe65SLaurentiu Tudor #endif 116