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 | |
| 47 | extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid); |
| 48 | extern void set_liodns(void); |
| 49 | extern void fdt_fixup_liodn(void *blob); |
| 50 | |
| 51 | #define SET_LIODN_BASE_1(idA) \ |
| 52 | { .id = { idA }, .num_ids = 1, } |
| 53 | |
| 54 | #define SET_LIODN_BASE_2(idA, idB) \ |
| 55 | { .id = { idA, idB }, .num_ids = 2 } |
| 56 | |
| 57 | #define SET_LIODN_ENTRY_1(name, idA, off, compatoff) \ |
| 58 | { .compat = name, \ |
| 59 | .id = { idA }, .num_ids = 1, \ |
| 60 | .reg_offset = off + CONFIG_SYS_CCSRBAR, \ |
| 61 | .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ |
| 62 | } |
| 63 | |
| 64 | #define SET_LIODN_ENTRY_2(name, idA, idB, off, compatoff) \ |
| 65 | { .compat = name, \ |
| 66 | .id = { idA, idB }, .num_ids = 2, \ |
| 67 | .reg_offset = off + CONFIG_SYS_CCSRBAR, \ |
| 68 | .compat_offset = compatoff + CONFIG_SYS_CCSRBAR_PHYS, \ |
| 69 | } |
| 70 | |
| 71 | #define SET_GUTS_LIODN(compat, liodn, name, compatoff) \ |
| 72 | SET_LIODN_ENTRY_1(compat, liodn, \ |
| 73 | offsetof(ccsr_gur_t, name) + CONFIG_SYS_MPC85xx_GUTS_OFFSET, \ |
| 74 | compatoff) |
| 75 | |
| 76 | #define SET_USB_LIODN(usbNum, compat, liodn) \ |
| 77 | SET_GUTS_LIODN(compat, liodn, usb##usbNum##liodnr,\ |
| 78 | CONFIG_SYS_MPC85xx_USB##usbNum##_OFFSET) |
| 79 | |
| 80 | #define SET_SATA_LIODN(sataNum, liodn) \ |
| 81 | SET_GUTS_LIODN("fsl,pq-sata-v2", liodn, sata##sataNum##liodnr,\ |
| 82 | CONFIG_SYS_MPC85xx_SATA##sataNum##_OFFSET) |
| 83 | |
Laurentiu TUDOR | 960f87f | 2011-03-15 16:37:36 +0200 | [diff] [blame] | 84 | #define SET_PCI_LIODN(compat, pciNum, liodn) \ |
| 85 | SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 86 | CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) |
| 87 | |
Laurentiu Tudor | b173eaf | 2012-10-05 09:48:51 +0000 | [diff] [blame] | 88 | #define SET_PCI_LIODN_BASE(compat, pciNum, liodn) \ |
| 89 | SET_LIODN_ENTRY_1(compat, liodn,\ |
| 90 | offsetof(ccsr_pcix_t, liodn_base) + CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET,\ |
| 91 | CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET) |
| 92 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 93 | /* reg nodes for DMA start @ 0x300 */ |
| 94 | #define SET_DMA_LIODN(dmaNum, liodn) \ |
| 95 | SET_GUTS_LIODN("fsl,eloplus-dma", liodn, dma##dmaNum##liodnr,\ |
| 96 | CONFIG_SYS_MPC85xx_DMA##dmaNum##_OFFSET + 0x300) |
| 97 | |
| 98 | #define SET_SDHC_LIODN(sdhcNum, liodn) \ |
| 99 | SET_GUTS_LIODN("fsl,esdhc", liodn, sdmmc##sdhcNum##liodnr,\ |
| 100 | CONFIG_SYS_MPC85xx_ESDHC_OFFSET) |
| 101 | |
| 102 | #define SET_QMAN_LIODN(liodn) \ |
| 103 | SET_LIODN_ENTRY_1("fsl,qman", liodn, offsetof(ccsr_qman_t, liodnr) + \ |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 104 | CONFIG_SYS_FSL_QMAN_OFFSET, \ |
| 105 | CONFIG_SYS_FSL_QMAN_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 106 | |
| 107 | #define SET_BMAN_LIODN(liodn) \ |
| 108 | SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \ |
Haiying Wang | 325a12f | 2011-01-20 22:26:31 +0000 | [diff] [blame] | 109 | CONFIG_SYS_FSL_BMAN_OFFSET, \ |
| 110 | CONFIG_SYS_FSL_BMAN_OFFSET) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 111 | |
| 112 | #define SET_PME_LIODN(liodn) \ |
| 113 | SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \ |
| 114 | CONFIG_SYS_FSL_CORENET_PME_OFFSET, \ |
| 115 | CONFIG_SYS_FSL_CORENET_PME_OFFSET) |
| 116 | |
Andy Fleming | 81177ad | 2012-10-08 07:44:18 +0000 | [diff] [blame] | 117 | #define SET_PMAN_LIODN(num, liodn) \ |
| 118 | SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \ |
| 119 | offsetof(struct ccsr_pman, ppa1) + \ |
| 120 | CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \ |
| 121 | CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET) |
| 122 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 123 | /* -1 from portID due to how immap has the registers */ |
| 124 | #define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \ |
| 125 | CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \ |
| 126 | offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1]) |
| 127 | |
| 128 | /* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */ |
| 129 | #define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \ |
| 130 | SET_LIODN_ENTRY_1("fsl,fman-port-1g-rx", liodn, \ |
| 131 | FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \ |
| 132 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) \ |
| 133 | |
| 134 | /* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */ |
| 135 | #define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \ |
| 136 | SET_LIODN_ENTRY_1("fsl,fman-port-10g-rx", liodn, \ |
| 137 | FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \ |
| 138 | CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) \ |
| 139 | |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 140 | /* |
| 141 | * handle both old and new versioned SEC properties: |
| 142 | * "fsl,secX.Y" became "fsl,sec-vX.Y" during development |
| 143 | */ |
Kumar Gala | 1c9cee9 | 2010-08-17 23:12:37 -0500 | [diff] [blame] | 144 | #define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \ |
| 145 | SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\ |
| 146 | offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 147 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 148 | CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \ |
| 149 | SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\ |
| 150 | offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \ |
| 151 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kumar Gala | 1c9cee9 | 2010-08-17 23:12:37 -0500 | [diff] [blame] | 152 | CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum) |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 153 | |
| 154 | /* This is a bit evil since we treat rtic param as both a string & hex value */ |
| 155 | #define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \ |
| 156 | SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \ |
| 157 | liodnA, \ |
| 158 | offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ |
| 159 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kim Phillips | e49f1c3 | 2011-04-12 14:12:47 -0500 | [diff] [blame] | 160 | CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \ |
| 161 | SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \ |
| 162 | liodnA, \ |
| 163 | offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \ |
| 164 | CONFIG_SYS_FSL_SEC_OFFSET, \ |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 165 | CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)) |
| 166 | |
| 167 | #define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \ |
| 168 | SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \ |
| 169 | offsetof(ccsr_sec_t, decoliodnr[num].ls) + \ |
| 170 | CONFIG_SYS_FSL_SEC_OFFSET, 0) |
| 171 | |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 172 | #define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \ |
| 173 | SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \ |
| 174 | liodnA, \ |
| 175 | offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \ |
| 176 | CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \ |
| 177 | offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \ |
| 178 | CONFIG_SYS_FSL_RAID_ENGINE_OFFSET) |
| 179 | |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 180 | #define SET_RMAN_LIODN(ibNum, liodn) \ |
| 181 | SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \ |
| 182 | offsetof(struct ccsr_rman, mmitdr) + \ |
| 183 | CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \ |
| 184 | CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000) |
| 185 | |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 186 | extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[]; |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 187 | extern struct liodn_id_table raide_liodn_tbl[]; |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 188 | extern struct liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[]; |
Timur Tabi | ebede50 | 2012-10-05 09:48:52 +0000 | [diff] [blame] | 189 | #ifdef CONFIG_SYS_SRIO |
Kumar Gala | 2b2b696 | 2011-10-14 00:01:23 -0500 | [diff] [blame] | 190 | extern struct srio_liodn_id_table srio_liodn_tbl[]; |
Timur Tabi | ebede50 | 2012-10-05 09:48:52 +0000 | [diff] [blame] | 191 | extern int srio_liodn_tbl_sz; |
| 192 | #endif |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 193 | extern struct liodn_id_table rman_liodn_tbl[]; |
Kumar Gala | 9d8e813 | 2011-09-10 10:44:13 -0500 | [diff] [blame] | 194 | 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] | 195 | extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz; |
Kumar Gala | 4eb3c37 | 2011-10-14 13:28:52 -0500 | [diff] [blame] | 196 | extern int rman_liodn_tbl_sz; |
Kumar Gala | 38449a4 | 2009-09-10 03:02:13 -0500 | [diff] [blame] | 197 | |
| 198 | #endif |