diff options
author | Alexandre Bounine <alexandre.bounine@idt.com> | 2010-05-26 17:43:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:50 -0400 |
commit | e5cabeb3d60f9cd3e3950aff071319ae0e2d08d8 (patch) | |
tree | e866f1a9076608630a40f21f0a50c073dedb0e57 /drivers/rapidio/switches | |
parent | 818a04a0bb93643d57dd8935815de2ff307b58a3 (diff) |
rapidio: add Port-Write handling for EM
Add RapidIO Port-Write message handling in the context of Error
Management Extensions Specification Rev.1.3.
Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Tested-by: Thomas Moll <thomas.moll@sysgo.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio/switches')
-rw-r--r-- | drivers/rapidio/switches/tsi568.c | 24 | ||||
-rw-r--r-- | drivers/rapidio/switches/tsi57x.c | 153 |
2 files changed, 177 insertions, 0 deletions
diff --git a/drivers/rapidio/switches/tsi568.c b/drivers/rapidio/switches/tsi568.c index bce9112ff0d9..905cf9cb09cc 100644 --- a/drivers/rapidio/switches/tsi568.c +++ b/drivers/rapidio/switches/tsi568.c | |||
@@ -25,6 +25,9 @@ | |||
25 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) | 25 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) |
26 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) | 26 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) |
27 | 27 | ||
28 | #define TSI568_SP_MODE_BC 0x10004 | ||
29 | #define TSI568_SP_MODE_PW_DIS 0x08000000 | ||
30 | |||
28 | static int | 31 | static int |
29 | tsi568_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | 32 | tsi568_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, |
30 | u16 table, u16 route_destid, u8 route_port) | 33 | u16 table, u16 route_destid, u8 route_port) |
@@ -104,3 +107,24 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, | |||
104 | } | 107 | } |
105 | 108 | ||
106 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table); | 109 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table); |
110 | |||
111 | static int | ||
112 | tsi568_em_init(struct rio_dev *rdev) | ||
113 | { | ||
114 | struct rio_mport *mport = rdev->net->hport; | ||
115 | u16 destid = rdev->rswitch->destid; | ||
116 | u8 hopcount = rdev->rswitch->hopcount; | ||
117 | u32 regval; | ||
118 | |||
119 | pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount); | ||
120 | |||
121 | /* Make sure that Port-Writes are disabled (for all ports) */ | ||
122 | rio_mport_read_config_32(mport, destid, hopcount, | ||
123 | TSI568_SP_MODE_BC, ®val); | ||
124 | rio_mport_write_config_32(mport, destid, hopcount, | ||
125 | TSI568_SP_MODE_BC, regval | TSI568_SP_MODE_PW_DIS); | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_em_init, NULL); | ||
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c index 5ad7880787c9..23040b92ea76 100644 --- a/drivers/rapidio/switches/tsi57x.c +++ b/drivers/rapidio/switches/tsi57x.c | |||
@@ -25,6 +25,14 @@ | |||
25 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) | 25 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) |
26 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) | 26 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) |
27 | 27 | ||
28 | #define TSI578_SP_MODE(n) (0x11004 + n*0x100) | ||
29 | #define TSI578_SP_MODE_PW_DIS 0x08000000 | ||
30 | |||
31 | #define TSI578_SP_CTL_INDEP(n) (0x13004 + n*0x100) | ||
32 | #define TSI578_SP_LUT_PEINF(n) (0x13010 + n*0x100) | ||
33 | #define TSI578_SP_CS_TX(n) (0x13014 + n*0x100) | ||
34 | #define TSI578_SP_INT_STATUS(n) (0x13018 + n*0x100) | ||
35 | |||
28 | static int | 36 | static int |
29 | tsi57x_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | 37 | tsi57x_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, |
30 | u16 table, u16 route_destid, u8 route_port) | 38 | u16 table, u16 route_destid, u8 route_port) |
@@ -104,3 +112,148 @@ DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_route_add_entry, ts | |||
104 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); | 112 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); |
105 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); | 113 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); |
106 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); | 114 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table); |
115 | |||
116 | static int | ||
117 | tsi57x_em_init(struct rio_dev *rdev) | ||
118 | { | ||
119 | struct rio_mport *mport = rdev->net->hport; | ||
120 | u16 destid = rdev->rswitch->destid; | ||
121 | u8 hopcount = rdev->rswitch->hopcount; | ||
122 | u32 regval; | ||
123 | int portnum; | ||
124 | |||
125 | pr_debug("TSI578 %s [%d:%d]\n", __func__, destid, hopcount); | ||
126 | |||
127 | for (portnum = 0; portnum < 16; portnum++) { | ||
128 | /* Make sure that Port-Writes are enabled (for all ports) */ | ||
129 | rio_mport_read_config_32(mport, destid, hopcount, | ||
130 | TSI578_SP_MODE(portnum), ®val); | ||
131 | rio_mport_write_config_32(mport, destid, hopcount, | ||
132 | TSI578_SP_MODE(portnum), | ||
133 | regval & ~TSI578_SP_MODE_PW_DIS); | ||
134 | |||
135 | /* Clear all pending interrupts */ | ||
136 | rio_mport_read_config_32(mport, destid, hopcount, | ||
137 | rdev->phys_efptr + | ||
138 | RIO_PORT_N_ERR_STS_CSR(portnum), | ||
139 | ®val); | ||
140 | rio_mport_write_config_32(mport, destid, hopcount, | ||
141 | rdev->phys_efptr + | ||
142 | RIO_PORT_N_ERR_STS_CSR(portnum), | ||
143 | regval & 0x07120214); | ||
144 | |||
145 | rio_mport_read_config_32(mport, destid, hopcount, | ||
146 | TSI578_SP_INT_STATUS(portnum), ®val); | ||
147 | rio_mport_write_config_32(mport, destid, hopcount, | ||
148 | TSI578_SP_INT_STATUS(portnum), | ||
149 | regval & 0x000700bd); | ||
150 | |||
151 | /* Enable all interrupts to allow ports to send a port-write */ | ||
152 | rio_mport_read_config_32(mport, destid, hopcount, | ||
153 | TSI578_SP_CTL_INDEP(portnum), ®val); | ||
154 | rio_mport_write_config_32(mport, destid, hopcount, | ||
155 | TSI578_SP_CTL_INDEP(portnum), | ||
156 | regval | 0x000b0000); | ||
157 | |||
158 | /* Skip next (odd) port if the current port is in x4 mode */ | ||
159 | rio_mport_read_config_32(mport, destid, hopcount, | ||
160 | rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), | ||
161 | ®val); | ||
162 | if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4) | ||
163 | portnum++; | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | static int | ||
170 | tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) | ||
171 | { | ||
172 | struct rio_mport *mport = rdev->net->hport; | ||
173 | u16 destid = rdev->rswitch->destid; | ||
174 | u8 hopcount = rdev->rswitch->hopcount; | ||
175 | u32 intstat, err_status; | ||
176 | int sendcount, checkcount; | ||
177 | u8 route_port; | ||
178 | u32 regval; | ||
179 | |||
180 | rio_mport_read_config_32(mport, destid, hopcount, | ||
181 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), | ||
182 | &err_status); | ||
183 | |||
184 | if ((err_status & RIO_PORT_N_ERR_STS_PORT_OK) && | ||
185 | (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES | | ||
186 | RIO_PORT_N_ERR_STS_PW_INP_ES))) { | ||
187 | /* Remove any queued packets by locking/unlocking port */ | ||
188 | rio_mport_read_config_32(mport, destid, hopcount, | ||
189 | rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), | ||
190 | ®val); | ||
191 | if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) { | ||
192 | rio_mport_write_config_32(mport, destid, hopcount, | ||
193 | rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), | ||
194 | regval | RIO_PORT_N_CTL_LOCKOUT); | ||
195 | udelay(50); | ||
196 | rio_mport_write_config_32(mport, destid, hopcount, | ||
197 | rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), | ||
198 | regval); | ||
199 | } | ||
200 | |||
201 | /* Read from link maintenance response register to clear | ||
202 | * valid bit | ||
203 | */ | ||
204 | rio_mport_read_config_32(mport, destid, hopcount, | ||
205 | rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum), | ||
206 | ®val); | ||
207 | |||
208 | /* Send a Packet-Not-Accepted/Link-Request-Input-Status control | ||
209 | * symbol to recover from IES/OES | ||
210 | */ | ||
211 | sendcount = 3; | ||
212 | while (sendcount) { | ||
213 | rio_mport_write_config_32(mport, destid, hopcount, | ||
214 | TSI578_SP_CS_TX(portnum), 0x40fc8000); | ||
215 | checkcount = 3; | ||
216 | while (checkcount--) { | ||
217 | udelay(50); | ||
218 | rio_mport_read_config_32( | ||
219 | mport, destid, hopcount, | ||
220 | rdev->phys_efptr + | ||
221 | RIO_PORT_N_MNT_RSP_CSR(portnum), | ||
222 | ®val); | ||
223 | if (regval & RIO_PORT_N_MNT_RSP_RVAL) | ||
224 | goto exit_es; | ||
225 | } | ||
226 | |||
227 | sendcount--; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | exit_es: | ||
232 | /* Clear implementation specific error status bits */ | ||
233 | rio_mport_read_config_32(mport, destid, hopcount, | ||
234 | TSI578_SP_INT_STATUS(portnum), &intstat); | ||
235 | pr_debug("TSI578[%x:%x] SP%d_INT_STATUS=0x%08x\n", | ||
236 | destid, hopcount, portnum, intstat); | ||
237 | |||
238 | if (intstat & 0x10000) { | ||
239 | rio_mport_read_config_32(mport, destid, hopcount, | ||
240 | TSI578_SP_LUT_PEINF(portnum), ®val); | ||
241 | regval = (mport->sys_size) ? (regval >> 16) : (regval >> 24); | ||
242 | route_port = rdev->rswitch->route_table[regval]; | ||
243 | pr_debug("RIO: TSI578[%s] P%d LUT Parity Error (destID=%d)\n", | ||
244 | rio_name(rdev), portnum, regval); | ||
245 | tsi57x_route_add_entry(mport, destid, hopcount, | ||
246 | RIO_GLOBAL_TABLE, regval, route_port); | ||
247 | } | ||
248 | |||
249 | rio_mport_write_config_32(mport, destid, hopcount, | ||
250 | TSI578_SP_INT_STATUS(portnum), | ||
251 | intstat & 0x000700bd); | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_em_init, tsi57x_em_handler); | ||
257 | DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_em_init, tsi57x_em_handler); | ||
258 | DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_em_init, tsi57x_em_handler); | ||
259 | DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_em_init, tsi57x_em_handler); | ||