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 | 96a37ef | 2019-02-26 13:18:34 +0200 | [diff] [blame] | 12 | #include <asm/armv8/sec_firmware.h> |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 13 | |
| 14 | struct icid_id_table { |
| 15 | const char *compat; |
| 16 | u32 id; |
| 17 | u32 reg; |
| 18 | phys_addr_t compat_addr; |
| 19 | phys_addr_t reg_addr; |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 20 | bool le; |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 21 | }; |
| 22 | |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 23 | struct fman_icid_id_table { |
| 24 | u32 port_id; |
| 25 | u32 icid; |
| 26 | }; |
| 27 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 28 | u32 get_ppid_icid(int ppid_tbl_idx, int ppid); |
| 29 | int fdt_get_smmu_phandle(void *blob); |
| 30 | int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids); |
| 31 | void set_icids(void); |
| 32 | void fdt_fixup_icid(void *blob); |
| 33 | |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 34 | #define SET_ICID_ENTRY(name, idA, regA, addr, compataddr, _le) \ |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 35 | { .compat = name, \ |
| 36 | .id = idA, \ |
| 37 | .reg = regA, \ |
| 38 | .compat_addr = compataddr, \ |
| 39 | .reg_addr = addr, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 40 | .le = _le \ |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 41 | } |
| 42 | |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 43 | #ifdef CONFIG_SYS_FSL_SEC_LE |
| 44 | #define SEC_IS_LE true |
| 45 | #elif defined(CONFIG_SYS_FSL_SEC_BE) |
| 46 | #define SEC_IS_LE false |
| 47 | #endif |
| 48 | |
| 49 | #ifdef CONFIG_FSL_LSCH2 |
| 50 | |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 51 | #ifdef CONFIG_SYS_FSL_CCSR_SCFG_LE |
| 52 | #define SCFG_IS_LE true |
| 53 | #elif defined(CONFIG_SYS_FSL_CCSR_SCFG_BE) |
| 54 | #define SCFG_IS_LE false |
| 55 | #endif |
| 56 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 57 | #define SET_SCFG_ICID(compat, streamid, name, compataddr) \ |
| 58 | SET_ICID_ENTRY(compat, streamid, (((streamid) << 24) | (1 << 23)), \ |
| 59 | offsetof(struct ccsr_scfg, name) + CONFIG_SYS_FSL_SCFG_ADDR, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 60 | compataddr, SCFG_IS_LE) |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 61 | |
| 62 | #define SET_USB_ICID(usb_num, compat, streamid) \ |
| 63 | SET_SCFG_ICID(compat, streamid, usb##usb_num##_icid,\ |
| 64 | CONFIG_SYS_XHCI_USB##usb_num##_ADDR) |
| 65 | |
| 66 | #define SET_SATA_ICID(compat, streamid) \ |
| 67 | SET_SCFG_ICID(compat, streamid, sata_icid,\ |
| 68 | AHCI_BASE_ADDR) |
| 69 | |
| 70 | #define SET_SDHC_ICID(streamid) \ |
| 71 | SET_SCFG_ICID("fsl,esdhc", streamid, sdhc_icid,\ |
| 72 | CONFIG_SYS_FSL_ESDHC_ADDR) |
| 73 | |
| 74 | #define SET_QDMA_ICID(compat, streamid) \ |
Laurentiu Tudor | e03b485 | 2018-12-12 13:45:51 +0200 | [diff] [blame] | 75 | SET_ICID_ENTRY(compat, streamid, (1 << 31) | (streamid), \ |
| 76 | QDMA_BASE_ADDR + QMAN_CQSIDR_REG, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 77 | QDMA_BASE_ADDR, false), \ |
Laurentiu Tudor | e03b485 | 2018-12-12 13:45:51 +0200 | [diff] [blame] | 78 | SET_ICID_ENTRY(NULL, streamid, (1 << 31) | (streamid), \ |
| 79 | QDMA_BASE_ADDR + QMAN_CQSIDR_REG + 4, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 80 | QDMA_BASE_ADDR, false) |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 81 | |
| 82 | #define SET_EDMA_ICID(streamid) \ |
| 83 | SET_SCFG_ICID("fsl,vf610-edma", streamid, edma_icid,\ |
| 84 | EDMA_BASE_ADDR) |
| 85 | |
| 86 | #define SET_ETR_ICID(streamid) \ |
| 87 | SET_SCFG_ICID(NULL, streamid, etr_icid, 0) |
| 88 | |
| 89 | #define SET_DEBUG_ICID(streamid) \ |
| 90 | SET_SCFG_ICID(NULL, streamid, debug_icid, 0) |
| 91 | |
Laurentiu Tudor | 22012d5 | 2018-08-27 17:33:59 +0300 | [diff] [blame] | 92 | #define SET_QE_ICID(streamid) \ |
| 93 | SET_SCFG_ICID("fsl,qe", streamid, qe_icid,\ |
| 94 | QE_BASE_ADDR) |
| 95 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 96 | #define SET_QMAN_ICID(streamid) \ |
| 97 | SET_ICID_ENTRY("fsl,qman", streamid, streamid, \ |
| 98 | offsetof(struct ccsr_qman, liodnr) + \ |
| 99 | CONFIG_SYS_FSL_QMAN_ADDR, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 100 | CONFIG_SYS_FSL_QMAN_ADDR, false) |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 101 | |
| 102 | #define SET_BMAN_ICID(streamid) \ |
| 103 | SET_ICID_ENTRY("fsl,bman", streamid, streamid, \ |
| 104 | offsetof(struct ccsr_bman, liodnr) + \ |
| 105 | CONFIG_SYS_FSL_BMAN_ADDR, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 106 | CONFIG_SYS_FSL_BMAN_ADDR, false) |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 107 | |
Laurentiu Tudor | dcb7f3d | 2018-08-09 15:19:48 +0300 | [diff] [blame] | 108 | #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \ |
| 109 | { .port_id = (_port_id), .icid = (streamid) } |
| 110 | |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 111 | #define SEC_ICID_REG_VAL(streamid) (((streamid) << 16) | (streamid)) |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 112 | |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 113 | #define SET_SEC_QI_ICID(streamid) \ |
| 114 | SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \ |
Laurentiu Tudor | 8aee3d6 | 2019-02-26 13:18:33 +0200 | [diff] [blame] | 115 | 0, offsetof(ccsr_sec_t, qilcr_ls) + \ |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 116 | CONFIG_SYS_FSL_SEC_ADDR, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 117 | CONFIG_SYS_FSL_SEC_ADDR, SEC_IS_LE) |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 118 | |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 119 | extern struct fman_icid_id_table fman_icid_tbl[]; |
| 120 | extern int fman_icid_tbl_sz; |
| 121 | |
| 122 | #else /* CONFIG_FSL_LSCH2 */ |
| 123 | |
| 124 | #ifdef CONFIG_SYS_FSL_CCSR_GUR_LE |
| 125 | #define GUR_IS_LE true |
| 126 | #elif defined(CONFIG_SYS_FSL_CCSR_GUR_BE) |
| 127 | #define GUR_IS_LE false |
| 128 | #endif |
| 129 | |
| 130 | #define SET_GUR_ICID(compat, streamid, name, compataddr) \ |
| 131 | SET_ICID_ENTRY(compat, streamid, streamid, \ |
| 132 | offsetof(struct ccsr_gur, name) + CONFIG_SYS_FSL_GUTS_ADDR, \ |
| 133 | compataddr, GUR_IS_LE) |
| 134 | |
| 135 | #define SET_USB_ICID(usb_num, compat, streamid) \ |
| 136 | SET_GUR_ICID(compat, streamid, usb##usb_num##_amqr,\ |
| 137 | CONFIG_SYS_XHCI_USB##usb_num##_ADDR) |
| 138 | |
| 139 | #define SET_SATA_ICID(sata_num, compat, streamid) \ |
| 140 | SET_GUR_ICID(compat, streamid, sata##sata_num##_amqr, \ |
| 141 | AHCI_BASE_ADDR##sata_num) |
| 142 | |
| 143 | #define SET_SDHC_ICID(streamid) \ |
| 144 | SET_GUR_ICID("fsl,esdhc", streamid, sdmm1_amqr,\ |
| 145 | CONFIG_SYS_FSL_ESDHC_ADDR) |
| 146 | |
| 147 | #define SEC_ICID_REG_VAL(streamid) (streamid) |
| 148 | |
| 149 | #endif /* CONFIG_FSL_LSCH2 */ |
| 150 | |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 151 | #define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \ |
Laurentiu Tudor | 96a37ef | 2019-02-26 13:18:34 +0200 | [diff] [blame] | 152 | SET_ICID_ENTRY( \ |
| 153 | (CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT && \ |
| 154 | (FSL_SEC_JR##jr_num##_OFFSET == \ |
| 155 | SEC_JR3_OFFSET + CONFIG_SYS_FSL_SEC_OFFSET) \ |
| 156 | ? NULL \ |
| 157 | : "fsl,sec-v4.0-job-ring"), \ |
| 158 | streamid, \ |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 159 | SEC_ICID_REG_VAL(streamid), \ |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 160 | offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \ |
| 161 | CONFIG_SYS_FSL_SEC_ADDR, \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 162 | FSL_SEC_JR##jr_num##_BASE_ADDR, SEC_IS_LE) |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 163 | |
| 164 | #define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \ |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 165 | SET_ICID_ENTRY(NULL, streamid, SEC_ICID_REG_VAL(streamid), \ |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 166 | offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 167 | CONFIG_SYS_FSL_SEC_ADDR, 0, SEC_IS_LE) |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 168 | |
| 169 | #define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \ |
Laurentiu Tudor | 7690ea7 | 2019-07-30 17:29:58 +0300 | [diff] [blame^] | 170 | SET_ICID_ENTRY(NULL, streamid, SEC_ICID_REG_VAL(streamid), \ |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 171 | offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \ |
Laurentiu Tudor | 7c326ac | 2019-07-30 17:29:57 +0300 | [diff] [blame] | 172 | CONFIG_SYS_FSL_SEC_ADDR, 0, SEC_IS_LE) |
Laurentiu Tudor | 3987b04 | 2018-08-09 15:19:49 +0300 | [diff] [blame] | 173 | |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 174 | extern struct icid_id_table icid_tbl[]; |
| 175 | extern int icid_tbl_sz; |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame] | 176 | |
| 177 | #endif |