Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 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> |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 11 | #include <fsl_sec.h> |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 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 | |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 21 | struct fman_icid_id_table { |
| 22 | u32 port_id; |
| 23 | u32 icid; |
| 24 | }; |
| 25 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 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) \ |
Laurentiu Tudor | e03b485 | 2018-12-12 13:45:51 +0200 | [diff] [blame] | 58 | SET_ICID_ENTRY(compat, streamid, (1 << 31) | (streamid), \ |
| 59 | QDMA_BASE_ADDR + QMAN_CQSIDR_REG, \ |
| 60 | QDMA_BASE_ADDR), \ |
| 61 | SET_ICID_ENTRY(NULL, streamid, (1 << 31) | (streamid), \ |
| 62 | QDMA_BASE_ADDR + QMAN_CQSIDR_REG + 4, \ |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 63 | QDMA_BASE_ADDR) |
| 64 | |
| 65 | #define SET_EDMA_ICID(streamid) \ |
| 66 | SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\ |
| 67 | EDMA_BASE_ADDR) |
| 68 | |
| 69 | #define SET_ETR_ICID(streamid) \ |
| 70 | SET_SCFG_ICID(NULL, streamid, etr_icid, 0) |
| 71 | |
| 72 | #define SET_DEBUG_ICID(streamid) \ |
| 73 | SET_SCFG_ICID(NULL, streamid, debug_icid, 0) |
| 74 | |
Laurentiu Tudor | 22012d5 | 2018-08-27 17:33:59 +0300 | [diff] [blame] | 75 | #define SET_QE_ICID(streamid) \ |
| 76 | SET_SCFG_ICID("fsl,qe", streamid, qe_icid,\ |
| 77 | QE_BASE_ADDR) |
| 78 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 79 | #define SET_QMAN_ICID(streamid) \ |
| 80 | SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ |
| 81 | offsetof(struct ccsr_qman, liodnr) + \ |
| 82 | CONFIG_SYS_FSL_QMAN_ADDR, \ |
| 83 | CONFIG_SYS_FSL_QMAN_ADDR) |
| 84 | |
| 85 | #define SET_BMAN_ICID(streamid) \ |
| 86 | SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ |
| 87 | offsetof(struct ccsr_bman, liodnr) + \ |
| 88 | CONFIG_SYS_FSL_BMAN_ADDR, \ |
| 89 | CONFIG_SYS_FSL_BMAN_ADDR) |
| 90 | |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 91 | #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ |
| 92 | { .port_id = (_port_id), .icid = (streamid) } |
| 93 | |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 94 | #define SET_SEC_QI_ICID(streamid) \ |
| 95 | SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ |
Laurentiu Tudor | 8aee3d6 | 2019-02-26 13:18:33 +0200 | [diff] [blame^] | 96 | 0, offsetof(ccsr_sec_t, qilcr_ls) + \ |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 97 | CONFIG_SYS_FSL_SEC_ADDR, \ |
| 98 | CONFIG_SYS_FSL_SEC_ADDR) |
| 99 | |
| 100 | #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ |
| 101 | SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \ |
| 102 | (((streamid) << 16) | (streamid)), \ |
| 103 | offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ |
| 104 | CONFIG_SYS_FSL_SEC_ADDR, \ |
| 105 | FSL_SEC_JR##jr_num##_BASE_ADDR) |
| 106 | |
| 107 | #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ |
| 108 | SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ |
| 109 | offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ |
| 110 | CONFIG_SYS_FSL_SEC_ADDR, 0) |
| 111 | |
| 112 | #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ |
| 113 | SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \ |
| 114 | offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ |
| 115 | CONFIG_SYS_FSL_SEC_ADDR, 0) |
| 116 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 117 | extern struct icid_id_table icid_tbl[]; |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 118 | extern struct fman_icid_id_table fman_icid_tbl[]; |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 119 | extern int icid_tbl_sz; |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 120 | extern int fman_icid_tbl_sz; |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 121 | |
| 122 | #endif |