1 /* 2 * Copyright 2009-2011 Freescale Semiconductor, Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #ifndef _FSL_LIODN_H_ 8 #define _FSL_LIODN_H_ 9 10 #include <asm/types.h> 11 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 32 struct liodn_id_table { 33 const char * compat; 34 u32 id[2]; 35 u8 num_ids; 36 phys_addr_t compat_offset; 37 unsigned long reg_offset; 38 }; 39 40 extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid); 41 extern void set_liodns(void); 42 extern void fdt_fixup_liodn(void *blob); 43 44 #define SET_LIODN_BASE_1(idA) \ 45 { .id = { idA }, .num_ids = 1, } 46 47 #define SET_LIODN_BASE_2(idA, idB) \ 48 { .id = { idA, idB }, .num_ids = 2 } 49 50 #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \ 51 { .compat = name, \ 52 .id = { idA }, .num_ids = 1, \ 53 .reg_offset = off + CONFIG_SYS_CCSRBAR, \ 54 .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ 55 } 56 57 #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \ 58 { .compat = name, \ 59 .id = { idA, idB }, .num_ids = 2, \ 60 .reg_offset = off + CONFIG_SYS_CCSRBAR, \ 61 .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ 62 } 63 64 #define SET_GUTS_LIODN(compat, liodn, name, compatoff) \ 65 SET_LIODN_ENTRY_1(compat, liodn, \ 66 offsetof(ccsr_gur_t, name) + CONFIG_SYS_MPC85xx_GUTS_OFFSET, \ 67 compatoff) 68 69 #define SET_USB_LIODN(usbNum, compat, liodn) \ 70 SET_GUTS_LIODN(compat, liodn, usb##usbNum##liodnr,\ 71 CONFIG_SYS_MPC85xx_USB##usbNum##_OFFSET) 72 73 #define SET_SATA_LIODN(sataNum, liodn) \ 74 SET_GUTS_LIODN("fsl,pq-sata-v2", liodn, sata##sataNum##liodnr,\ 75 CONFIG_SYS_MPC85xx_SATA##sataNum##_OFFSET) 76 77 #define SET_PCI_LIODN(compat, pciNum, liodn) \ 78 SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\ 79 CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) 80 81 #define SET_PCI_LIODN_BASE(compat, pciNum, liodn) \ 82 SET_LIODN_ENTRY_1(compat, liodn,\ 83 offsetof(ccsr_pcix_t, liodn_base) + CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET,\ 84 CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) 85 86 /* reg nodes for DMA start @ 0x300 */ 87 #define SET_DMA_LIODN(dmaNum, liodn) \ 88 SET_GUTS_LIODN("fsl,eloplus-dma", liodn, dma##dmaNum##liodnr,\ 89 CONFIG_SYS_MPC85xx_DMA##dmaNum##_OFFSET + 0x300) 90 91 #define SET_SDHC_LIODN(sdhcNum, liodn) \ 92 SET_GUTS_LIODN("fsl,esdhc", liodn, sdmmc##sdhcNum##liodnr,\ 93 CONFIG_SYS_MPC85xx_ESDHC_OFFSET) 94 95 #define SET_QMAN_LIODN(liodn) \ 96 SET_LIODN_ENTRY_1("fsl,qman", liodn, offsetof(ccsr_qman_t, liodnr) + \ 97 CONFIG_SYS_FSL_QMAN_OFFSET, \ 98 CONFIG_SYS_FSL_QMAN_OFFSET) 99 100 #define SET_BMAN_LIODN(liodn) \ 101 SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \ 102 CONFIG_SYS_FSL_BMAN_OFFSET, \ 103 CONFIG_SYS_FSL_BMAN_OFFSET) 104 105 #define SET_PME_LIODN(liodn) \ 106 SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \ 107 CONFIG_SYS_FSL_CORENET_PME_OFFSET, \ 108 CONFIG_SYS_FSL_CORENET_PME_OFFSET) 109 110 #define SET_PMAN_LIODN(num, liodn) \ 111 SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \ 112 offsetof(struct ccsr_pman, ppa1) + \ 113 CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \ 114 CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET) 115 116 /* -1 from portID due to how immap has the registers */ 117 #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \ 118 CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \ 119 offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1]) 120 121 /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */ 122 #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \ 123 SET_LIODN_ENTRY_1("fsl,fman-port-1g-rx", liodn, \ 124 FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \ 125 CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) \ 126 127 /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */ 128 #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \ 129 SET_LIODN_ENTRY_1("fsl,fman-port-10g-rx", liodn, \ 130 FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \ 131 CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) \ 132 133 /* 134 * handle both old and new versioned SEC properties: 135 * "fsl,secX.Y" became "fsl,sec-vX.Y" during development 136 */ 137 #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \ 138 SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\ 139 offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ 140 CONFIG_SYS_FSL_SEC_OFFSET, \ 141 CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \ 142 SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\ 143 offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ 144 CONFIG_SYS_FSL_SEC_OFFSET, \ 145 CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum) 146 147 /* This is a bit evil since we treat rtic param as both a string & hex value */ 148 #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \ 149 SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \ 150 liodnA, \ 151 offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ 152 CONFIG_SYS_FSL_SEC_OFFSET, \ 153 CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \ 154 SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \ 155 liodnA, \ 156 offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ 157 CONFIG_SYS_FSL_SEC_OFFSET, \ 158 CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)) 159 160 #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \ 161 SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \ 162 offsetof(ccsr_sec_t, decoliodnr[num].ls) + \ 163 CONFIG_SYS_FSL_SEC_OFFSET, 0) 164 165 #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \ 166 SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \ 167 liodnA, \ 168 offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \ 169 CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \ 170 offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \ 171 CONFIG_SYS_FSL_RAID_ENGINE_OFFSET) 172 173 #define SET_RMAN_LIODN(ibNum, liodn) \ 174 SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \ 175 offsetof(struct ccsr_rman, mmitdr) + \ 176 CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \ 177 CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000) 178 179 extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[]; 180 extern struct liodn_id_table raide_liodn_tbl[]; 181 extern struct liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[]; 182 #ifdef CONFIG_SYS_SRIO 183 extern struct srio_liodn_id_table srio_liodn_tbl[]; 184 extern int srio_liodn_tbl_sz; 185 #endif 186 extern struct liodn_id_table rman_liodn_tbl[]; 187 extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz; 188 extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz; 189 extern int rman_liodn_tbl_sz; 190 191 #endif 192