aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio/switches/tsi57x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rapidio/switches/tsi57x.c')
-rw-r--r--drivers/rapidio/switches/tsi57x.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c
new file mode 100644
index 000000000000..5ad7880787c9
--- /dev/null
+++ b/drivers/rapidio/switches/tsi57x.c
@@ -0,0 +1,106 @@
1/*
2 * RapidIO Tsi57x switch family support
3 *
4 * Copyright 2009 Integrated Device Technology, Inc.
5 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/rio.h>
15#include <linux/rio_drv.h>
16#include <linux/rio_ids.h>
17#include <linux/delay.h>
18#include "../rio.h"
19
20/* Global (broadcast) route registers */
21#define SPBC_ROUTE_CFG_DESTID 0x10070
22#define SPBC_ROUTE_CFG_PORT 0x10074
23
24/* Per port route registers */
25#define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n)
26#define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n)
27
28static int
29tsi57x_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
30 u16 table, u16 route_destid, u8 route_port)
31{
32 if (table == RIO_GLOBAL_TABLE) {
33 rio_mport_write_config_32(mport, destid, hopcount,
34 SPBC_ROUTE_CFG_DESTID, route_destid);
35 rio_mport_write_config_32(mport, destid, hopcount,
36 SPBC_ROUTE_CFG_PORT, route_port);
37 } else {
38 rio_mport_write_config_32(mport, destid, hopcount,
39 SPP_ROUTE_CFG_DESTID(table), route_destid);
40 rio_mport_write_config_32(mport, destid, hopcount,
41 SPP_ROUTE_CFG_PORT(table), route_port);
42 }
43
44 udelay(10);
45
46 return 0;
47}
48
49static int
50tsi57x_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
51 u16 table, u16 route_destid, u8 *route_port)
52{
53 int ret = 0;
54 u32 result;
55
56 if (table == RIO_GLOBAL_TABLE) {
57 /* Use local RT of the ingress port to avoid possible
58 race condition */
59 rio_mport_read_config_32(mport, destid, hopcount,
60 RIO_SWP_INFO_CAR, &result);
61 table = (result & RIO_SWP_INFO_PORT_NUM_MASK);
62 }
63
64 rio_mport_write_config_32(mport, destid, hopcount,
65 SPP_ROUTE_CFG_DESTID(table), route_destid);
66 rio_mport_read_config_32(mport, destid, hopcount,
67 SPP_ROUTE_CFG_PORT(table), &result);
68
69 *route_port = (u8)result;
70 if (*route_port > 15)
71 ret = -1;
72
73 return ret;
74}
75
76static int
77tsi57x_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
78 u16 table)
79{
80 u32 route_idx;
81 u32 lut_size;
82
83 lut_size = (mport->sys_size) ? 0x1ff : 0xff;
84
85 if (table == RIO_GLOBAL_TABLE) {
86 rio_mport_write_config_32(mport, destid, hopcount,
87 SPBC_ROUTE_CFG_DESTID, 0x80000000);
88 for (route_idx = 0; route_idx <= lut_size; route_idx++)
89 rio_mport_write_config_32(mport, destid, hopcount,
90 SPBC_ROUTE_CFG_PORT,
91 RIO_INVALID_ROUTE);
92 } else {
93 rio_mport_write_config_32(mport, destid, hopcount,
94 SPP_ROUTE_CFG_DESTID(table), 0x80000000);
95 for (route_idx = 0; route_idx <= lut_size; route_idx++)
96 rio_mport_write_config_32(mport, destid, hopcount,
97 SPP_ROUTE_CFG_PORT(table) , RIO_INVALID_ROUTE);
98 }
99
100 return 0;
101}
102
103DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
104DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
105DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
106DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);