blob: f658bcbc66ae07396f9bf8adf9bb3e1d20ef42c0 [file] [log] [blame]
Kumar Galadb977ab2009-09-10 03:02:13 -05001/*
Haiying Wang24995d82011-01-20 22:26:31 +00002 * Copyright 2009-2011 Freescale Semiconductor, Inc.
Kumar Galadb977ab2009-09-10 03:02:13 -05003 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Kumar Galadb977ab2009-09-10 03:02:13 -05005 */
6
7#ifndef _FSL_LIODN_H_
8#define _FSL_LIODN_H_
9
10#include <asm/types.h>
11
Kumar Gala1a0c6422011-10-14 00:01:23 -050012struct 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 Gangb3831022013-06-25 18:12:12 +080032#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 Galadb977ab2009-09-10 03:02:13 -050039struct 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
47extern u32 get_ppid_liodn(int ppid_tbl_idx, int ppid);
48extern void set_liodns(void);
49extern 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 TUDOR33e68352011-03-15 16:37:36 +020084#define SET_PCI_LIODN(compat, pciNum, liodn) \
85 SET_GUTS_LIODN(compat, liodn, pex##pciNum##liodnr,\
Kumar Galadb977ab2009-09-10 03:02:13 -050086 CONFIG_SYS_MPC85xx_PCIE##pciNum##_OFFSET)
87
Laurentiu Tudore389a372012-10-05 09:48:51 +000088#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 Galadb977ab2009-09-10 03:02:13 -050093/* 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
Zhao Qiang2a44efe2014-03-21 16:21:45 +0800102#define SET_QE_LIODN(liodn) \
103 SET_GUTS_LIODN("fsl,qe", liodn, qeliodnr,\
104 CONFIG_SYS_MPC85xx_QE_OFFSET)
105
Kumar Galadb977ab2009-09-10 03:02:13 -0500106#define SET_QMAN_LIODN(liodn) \
107 SET_LIODN_ENTRY_1("fsl,qman", liodn, offsetof(ccsr_qman_t, liodnr) + \
Haiying Wang24995d82011-01-20 22:26:31 +0000108 CONFIG_SYS_FSL_QMAN_OFFSET, \
109 CONFIG_SYS_FSL_QMAN_OFFSET)
Kumar Galadb977ab2009-09-10 03:02:13 -0500110
111#define SET_BMAN_LIODN(liodn) \
112 SET_LIODN_ENTRY_1("fsl,bman", liodn, offsetof(ccsr_bman_t, liodnr) + \
Haiying Wang24995d82011-01-20 22:26:31 +0000113 CONFIG_SYS_FSL_BMAN_OFFSET, \
114 CONFIG_SYS_FSL_BMAN_OFFSET)
Kumar Galadb977ab2009-09-10 03:02:13 -0500115
116#define SET_PME_LIODN(liodn) \
117 SET_LIODN_ENTRY_1("fsl,pme", liodn, offsetof(ccsr_pme_t, liodnr) + \
118 CONFIG_SYS_FSL_CORENET_PME_OFFSET, \
119 CONFIG_SYS_FSL_CORENET_PME_OFFSET)
120
Andy Flemingf3118382012-10-08 07:44:18 +0000121#define SET_PMAN_LIODN(num, liodn) \
122 SET_LIODN_ENTRY_2("fsl,pman", liodn, 0, \
123 offsetof(struct ccsr_pman, ppa1) + \
124 CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET, \
125 CONFIG_SYS_FSL_CORENET_PMAN##num##_OFFSET)
126
Kumar Galadb977ab2009-09-10 03:02:13 -0500127/* -1 from portID due to how immap has the registers */
128#define FM_PPID_RX_PORT_OFFSET(fmNum, portID) \
129 CONFIG_SYS_FSL_FM##fmNum##_OFFSET + \
130 offsetof(struct ccsr_fman, fm_bmi_common.fmbm_ppid[portID - 1])
131
132/* enetNum is 0, 1, 2... so we + 8 for 1g to get to HW Port ID */
133#define SET_FMAN_RX_1G_LIODN(fmNum, enetNum, liodn) \
134 SET_LIODN_ENTRY_1("fsl,fman-port-1g-rx", liodn, \
135 FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 8), \
136 CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_1G_OFFSET) \
137
138/* enetNum is 0, 1, 2... so we + 16 for 10g to get to HW Port ID */
139#define SET_FMAN_RX_10G_LIODN(fmNum, enetNum, liodn) \
140 SET_LIODN_ENTRY_1("fsl,fman-port-10g-rx", liodn, \
141 FM_PPID_RX_PORT_OFFSET(fmNum, enetNum + 16), \
142 CONFIG_SYS_FSL_FM##fmNum##_RX##enetNum##_10G_OFFSET) \
143
Kim Phillips416202f2011-04-12 14:12:47 -0500144/*
145 * handle both old and new versioned SEC properties:
146 * "fsl,secX.Y" became "fsl,sec-vX.Y" during development
147 */
Kumar Galaed062e02010-08-17 23:12:37 -0500148#define SET_SEC_JR_LIODN_ENTRY(jrNum, liodnA, liodnB) \
149 SET_LIODN_ENTRY_2("fsl,sec4.0-job-ring", liodnA, liodnB,\
150 offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
Kumar Galadb977ab2009-09-10 03:02:13 -0500151 CONFIG_SYS_FSL_SEC_OFFSET, \
Kim Phillips416202f2011-04-12 14:12:47 -0500152 CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum), \
153 SET_LIODN_ENTRY_2("fsl,sec-v4.0-job-ring", liodnA, liodnB,\
154 offsetof(ccsr_sec_t, jrliodnr[jrNum].ls) + \
155 CONFIG_SYS_FSL_SEC_OFFSET, \
Kumar Galaed062e02010-08-17 23:12:37 -0500156 CONFIG_SYS_FSL_SEC_OFFSET + 0x1000 + 0x1000 * jrNum)
Kumar Galadb977ab2009-09-10 03:02:13 -0500157
158/* This is a bit evil since we treat rtic param as both a string & hex value */
159#define SET_SEC_RTIC_LIODN_ENTRY(rtic, liodnA) \
160 SET_LIODN_ENTRY_1("fsl,sec4.0-rtic-memory", \
161 liodnA, \
162 offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
163 CONFIG_SYS_FSL_SEC_OFFSET, \
Kim Phillips416202f2011-04-12 14:12:47 -0500164 CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa)), \
165 SET_LIODN_ENTRY_1("fsl,sec-v4.0-rtic-memory", \
166 liodnA, \
167 offsetof(ccsr_sec_t, rticliodnr[0x##rtic-0xa].ls) + \
168 CONFIG_SYS_FSL_SEC_OFFSET, \
Kumar Galadb977ab2009-09-10 03:02:13 -0500169 CONFIG_SYS_FSL_SEC_OFFSET + 0x6100 + 0x20 * (0x##rtic-0xa))
170
171#define SET_SEC_DECO_LIODN_ENTRY(num, liodnA, liodnB) \
172 SET_LIODN_ENTRY_2(NULL, liodnA, liodnB, \
173 offsetof(ccsr_sec_t, decoliodnr[num].ls) + \
174 CONFIG_SYS_FSL_SEC_OFFSET, 0)
175
Kumar Gala6b3a8d02011-09-10 10:44:13 -0500176#define SET_RAID_ENGINE_JQ_LIODN_ENTRY(jqNum, rNum, liodnA) \
177 SET_LIODN_ENTRY_1("fsl,raideng-v1.0-job-ring", \
178 liodnA, \
179 offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg1) + \
180 CONFIG_SYS_FSL_RAID_ENGINE_OFFSET, \
181 offsetof(struct ccsr_raide, jq[jqNum].ring[rNum].cfg0) + \
182 CONFIG_SYS_FSL_RAID_ENGINE_OFFSET)
183
Kumar Gala4d28db82011-10-14 13:28:52 -0500184#define SET_RMAN_LIODN(ibNum, liodn) \
185 SET_LIODN_ENTRY_1("fsl,rman-inbound-block", liodn, \
186 offsetof(struct ccsr_rman, mmitdr) + \
187 CONFIG_SYS_FSL_CORENET_RMAN_OFFSET, \
188 CONFIG_SYS_FSL_CORENET_RMAN_OFFSET + ibNum * 0x1000)
189
Kumar Galadb977ab2009-09-10 03:02:13 -0500190extern struct liodn_id_table liodn_tbl[], liodn_bases[], sec_liodn_tbl[];
Kumar Gala6b3a8d02011-09-10 10:44:13 -0500191extern struct liodn_id_table raide_liodn_tbl[];
Kumar Galadb977ab2009-09-10 03:02:13 -0500192extern struct liodn_id_table fman1_liodn_tbl[], fman2_liodn_tbl[];
Timur Tabifd946042012-10-05 09:48:52 +0000193#ifdef CONFIG_SYS_SRIO
Kumar Gala1a0c6422011-10-14 00:01:23 -0500194extern struct srio_liodn_id_table srio_liodn_tbl[];
Timur Tabifd946042012-10-05 09:48:52 +0000195extern int srio_liodn_tbl_sz;
196#endif
Kumar Gala4d28db82011-10-14 13:28:52 -0500197extern struct liodn_id_table rman_liodn_tbl[];
Kumar Gala6b3a8d02011-09-10 10:44:13 -0500198extern int liodn_tbl_sz, sec_liodn_tbl_sz, raide_liodn_tbl_sz;
Kumar Galadb977ab2009-09-10 03:02:13 -0500199extern int fman1_liodn_tbl_sz, fman2_liodn_tbl_sz;
Kumar Gala4d28db82011-10-14 13:28:52 -0500200extern int rman_liodn_tbl_sz;
Kumar Galadb977ab2009-09-10 03:02:13 -0500201
202#endif