Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 1 | /* |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 2 | * Copyright 2009-2011 Freescale Semiconductor, Inc. |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _FSL_LIODN_H_ |
| 8 | #define _FSL_LIODN_H_ |
| 9 | |
| 10 | #include <asm/types.h> |
| 11 | |
Kumar Gala | 2b2b696 | 2011-10-14 00:01:23 -0500 | [diff] [blame] | 12 | struct srio_liodn_id_table { |
| 13 | u32 id[2]; |
| 14 | unsigned long reg_offset[2]; |
| 15 | u8 num_ids; |
| 16 | u8 portid; |
| 17 | }; |
| 18 | #define SET_SRIO_LIODN_1(port, idA) \ |
| 19 | { .id = { idA }, .num_ids = 1, .portid = port, \ |
| 20 | .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \ |
| 21 | + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \ |
| 22 | } |
| 23 | |
| 24 | #define SET_SRIO_LIODN_2(port, idA, idB) \ |
| 25 | { .id = { idA, idB }, .num_ids = 2, .portid = port, \ |
| 26 | .reg_offset[0] = offsetof(ccsr_gur_t, rio##port##liodnr) \ |
| 27 | + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \ |
| 28 | .reg_offset[1] = offsetof(ccsr_gur_t, rio##port##maintliodnr) \ |
| 29 | + CONFIG_SYS_MPC85xx_GUTS_OFFSET + CONFIG_SYS_CCSRBAR, \ |
| 30 | } |
| 31 | |
Liu Gang | 1d5284b | 2013-06-25 18:12:12 +0800 | [diff] [blame] | 32 | #define SET_SRIO_LIODN_BASE(port, id_a) \ |
| 33 | { .id = { id_a }, .num_ids = 1, .portid = port, \ |
| 34 | .reg_offset[0] = offsetof(struct ccsr_rio, liodn) \ |
| 35 | + (port - 1) * 0x200 \ |
| 36 | + CONFIG_SYS_FSL_SRIO_ADDR, \ |
| 37 | } |
| 38 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 39 | struct liodn_id_table { |
| 40 | const char * compat; |
| 41 | u32 id[2]; |
| 42 | u8 num_ids; |
| 43 | phys_addr_t compat_offset; |
| 44 | unsigned long reg_offset; |
| 45 | }; |
| 46 | |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 47 | struct fman_liodn_id_table { |
| 48 | /* Freescale FMan Device Tree binding was updated for FMan. |
| 49 | * We need to support both new and old compatibles in order not to |
| 50 | * break backward compatibility. |
| 51 | */ |
| 52 | const char *compat[2]; |
| 53 | u32 id[2]; |
| 54 | u8 num_ids; |
| 55 | phys_addr_t compat_offset; |
| 56 | unsigned long reg_offset; |
| 57 | }; |
| 58 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 59 | extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid); |
| 60 | extern void set_liodns(void); |
| 61 | extern void fdt_fixup_liodn(void *blob); |
| 62 | |
| 63 | #define SET_LIODN_BASE_1(idA) \ |
| 64 | { .id = { idA }, .num_ids = 1, } |
| 65 | |
| 66 | #define SET_LIODN_BASE_2(idA, idB) \ |
| 67 | { .id = { idA, idB }, .num_ids = 2 } |
| 68 | |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 69 | #define SET_FMAN_LIODN_ENTRY(name1, name2, idA, off, compatoff)\ |
| 70 | { .compat[0] = name1, \ |
| 71 | .compat[1] = name2, \ |
| 72 | .id = { idA }, .num_ids = 1, \ |
| 73 | .reg_offset = off + CONFIG_SYS_CCSRBAR, \ |
| 74 | .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ |
| 75 | } |
| 76 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 77 | #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \ |
| 78 | { .compat = name, \ |
| 79 | .id = { idA }, .num_ids = 1, \ |
| 80 | .reg_offset = off + CONFIG_SYS_CCSRBAR, \ |
| 81 | .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ |
| 82 | } |
| 83 | |
| 84 | #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \ |
| 85 | { .compat = name, \ |
| 86 | .id = { idA, idB }, .num_ids = 2, \ |
| 87 | .reg_offset = off + CONFIG_SYS_CCSRBAR, \ |
| 88 | .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ |
| 89 | } |
| 90 | |
| 91 | #define SET_GUTS_LIODN(compat, liodn, name, compatoff) \ |
| 92 | SET_LIODN_ENTRY_1(compat, liodn, \ |
| 93 | offsetof(ccsr_gur_t, name) + CONFIG_SYS_MPC85xx_GUTS_OFFSET, \ |
| 94 | compatoff) |
| 95 | |
| 96 | #define SET_USB_LIODN(usbNum, compat, liodn) \ |
| 97 | SET_GUTS_LIODN(compat, liodn, usb##usbNum##liodnr,\ |
| 98 | CONFIG_SYS_MPC85xx_USB##usbNum##_OFFSET) |
| 99 | |
| 100 | #define SET_SATA_LIODN(sataNum, liodn) \ |
| 101 | SET_GUTS_LIODN("fsl,pq-sata-v2", liodn, sata##sataNum##liodnr,\ |
| 102 | CONFIG_SYS_MPC85xx_SATA##sataNum##_OFFSET) |
| 103 | |
Laurentiu TUDOR | 960f87f | 2011-03-15 16:37:36 +0200 | [diff] [blame] | 104 | #define SET_PCI_LIODN(compat, pciNum, liodn) \ |
| 105 | SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 106 | CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) |
| 107 | |
Laurentiu Tudor | b173eaf | 2012-10-05 09:48:51 +0000 | [diff] [blame] | 108 | #define SET_PCI_LIODN_BASE(compat, pciNum, liodn) \ |
| 109 | SET_LIODN_ENTRY_1(compat, liodn,\ |
| 110 | offsetof(ccsr_pcix_t, liodn_base) + CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET,\ |
| 111 | CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) |
| 112 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 113 | /* reg nodes for DMA start @ 0x300 */ |
Tudor Laurentiu | 7210d9a | 2014-11-20 12:09:31 +0200 | [diff] [blame] | 114 | #define SET_DMA_LIODN(dmaNum, compat, liodn) \ |
| 115 | SET_GUTS_LIODN(compat, liodn, dma##dmaNum##liodnr,\ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 116 | CONFIG_SYS_MPC85xx_DMA##dmaNum##_OFFSET + 0x300) |
| 117 | |
| 118 | #define SET_SDHC_LIODN(sdhcNum, liodn) \ |
| 119 | SET_GUTS_LIODN("fsl,esdhc", liodn, sdmmc##sdhcNum##liodnr,\ |
| 120 | CONFIG_SYS_MPC85xx_ESDHC_OFFSET) |
| 121 | |
Zhao Qiang | b818ba2 | 2014-03-21 16:21:45 +0800 | [diff] [blame] | 122 | #define SET_QE_LIODN(liodn) \ |
| 123 | SET_GUTS_LIODN("fsl,qe", liodn, qeliodnr,\ |
| 124 | CONFIG_SYS_MPC85xx_QE_OFFSET) |
| 125 | |
Sandeep Singh | 4fb16a1 | 2014-06-05 18:49:57 +0530 | [diff] [blame] | 126 | #define SET_TDM_LIODN(liodn) \ |
| 127 | SET_GUTS_LIODN("fsl,tdm1.0", liodn, tdmliodnr,\ |
| 128 | CONFIG_SYS_MPC85xx_TDM_OFFSET) |
| 129 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 130 | #define SET_QMAN_LIODN(liodn) \ |
| 131 | SET_LIODN_ENTRY_1("fsl,qman", liodn, offsetof(ccsr_qman_t, liodnr) + \ |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 132 | CONFIG_SYS_FSL_QMAN_OFFSET, \ |
| 133 | CONFIG_SYS_FSL_QMAN_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 134 | |
| 135 | #define SET_BMAN_LIODN(liodn) \ |
| 136 | SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \ |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 137 | CONFIG_SYS_FSL_BMAN_OFFSET, \ |
| 138 | CONFIG_SYS_FSL_BMAN_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 139 | |
| 140 | #define SET_PME_LIODN(liodn) \ |
| 141 | SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \ |
| 142 | CONFIG_SYS_FSL_CORENET_PME_OFFSET, \ |
| 143 | CONFIG_SYS_FSL_CORENET_PME_OFFSET) |
| 144 | |
Andy Fleming | 81177ad | 2012-10-08 07:44:18 +0000 | [diff] [blame] | 145 | #define SET_PMAN_LIODN(num, liodn) \ |
| 146 | SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \ |
| 147 | offsetof(struct ccsr_pman, ppa1) + \ |
| 148 | CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \ |
| 149 | CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET) |
| 150 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 151 | /* -1 from portID due to how immap has the registers */ |
| 152 | #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \ |
| 153 | CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \ |
| 154 | offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1]) |
| 155 | |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 156 | #ifdef CONFIG_SYS_FMAN_V3 |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 157 | /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */ |
| 158 | #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \ |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 159 | SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-1g-rx", \ |
| 160 | liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \ |
| 161 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 162 | |
| 163 | /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */ |
| 164 | #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \ |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 165 | SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \ |
| 166 | liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \ |
| 167 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 168 | |
Shengzhou Liu | 0e24d3a | 2015-05-14 16:51:39 +0800 | [diff] [blame] | 169 | /* enetNum is 0, 1, 2... so we + 8 for type-2 10g to get to HW Port ID */ |
| 170 | #define SET_FMAN_RX_10G_TYPE2_LIODN(fmNum, enetNum, liodn) \ |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 171 | SET_FMAN_LIODN_ENTRY("fsl,fman-v3-port-rx", "fsl,fman-port-10g-rx", \ |
| 172 | liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \ |
| 173 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) |
| 174 | #else |
| 175 | /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */ |
| 176 | #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \ |
| 177 | SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-1g-rx", \ |
| 178 | liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \ |
| 179 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) |
Shengzhou Liu | 0e24d3a | 2015-05-14 16:51:39 +0800 | [diff] [blame] | 180 | |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 181 | /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */ |
| 182 | #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \ |
| 183 | SET_FMAN_LIODN_ENTRY("fsl,fman-v2-port-rx", "fsl,fman-port-10g-rx", \ |
| 184 | liodn, FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \ |
| 185 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) |
| 186 | #endif |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 187 | /* |
| 188 | * handle both old and new versioned SEC properties: |
| 189 | * "fsl,secX.Y" became "fsl,sec-vX.Y" during development |
| 190 | */ |
Kumar Gala | 1c9cee9 | 2010-08-17 23:12:37 -0500 | [diff] [blame] | 191 | #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \ |
| 192 | SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\ |
| 193 | offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 194 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 195 | CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \ |
| 196 | SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\ |
| 197 | offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ |
| 198 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kumar Gala | 1c9cee9 | 2010-08-17 23:12:37 -0500 | [diff] [blame] | 199 | CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 200 | |
| 201 | /* This is a bit evil since we treat rtic param as both a string & hex value */ |
| 202 | #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \ |
| 203 | SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \ |
| 204 | liodnA, \ |
| 205 | offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ |
| 206 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 207 | CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \ |
| 208 | SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \ |
| 209 | liodnA, \ |
| 210 | offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ |
| 211 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 212 | CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)) |
| 213 | |
| 214 | #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \ |
| 215 | SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \ |
| 216 | offsetof(ccsr_sec_t, decoliodnr[num].ls) + \ |
| 217 | CONFIG_SYS_FSL_SEC_OFFSET, 0) |
| 218 | |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 219 | #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \ |
| 220 | SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \ |
| 221 | liodnA, \ |
| 222 | offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \ |
| 223 | CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \ |
| 224 | offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \ |
| 225 | CONFIG_SYS_FSL_RAID_ENGINE_OFFSET) |
| 226 | |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 227 | #define SET_RMAN_LIODN(ibNum, liodn) \ |
| 228 | SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \ |
| 229 | offsetof(struct ccsr_rman, mmitdr) + \ |
| 230 | CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \ |
| 231 | CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000) |
| 232 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 233 | extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[]; |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 234 | extern struct liodn_id_table raide_liodn_tbl[]; |
Igal Liberman | e14ec99 | 2015-08-18 14:47:05 +0300 | [diff] [blame] | 235 | extern struct fman_liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[]; |
Timur Tabi | ebede50 | 2012-10-05 09:48:52 +0000 | [diff] [blame] | 236 | #ifdef CONFIG_SYS_SRIO |
Kumar Gala | 2b2b696 | 2011-10-14 00:01:23 -0500 | [diff] [blame] | 237 | extern struct srio_liodn_id_table srio_liodn_tbl[]; |
Timur Tabi | ebede50 | 2012-10-05 09:48:52 +0000 | [diff] [blame] | 238 | extern int srio_liodn_tbl_sz; |
| 239 | #endif |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 240 | extern struct liodn_id_table rman_liodn_tbl[]; |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 241 | extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz; |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 242 | extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz; |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 243 | extern int rman_liodn_tbl_sz; |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 244 | |
| 245 | #endif |