2 * RapidIO Tsi568 switch support
4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org>
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.
14 #include <linux/rio.h>
15 #include <linux/rio_drv.h>
16 #include <linux/rio_ids.h>
17 #include <linux/delay.h>
20 /* Global (broadcast) route registers */
21 #define SPBC_ROUTE_CFG_DESTID 0x10070
22 #define SPBC_ROUTE_CFG_PORT 0x10074
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)
28 #define TSI568_SP_MODE_BC 0x10004
29 #define TSI568_SP_MODE_PW_DIS 0x08000000
32 tsi568_route_add_entry(struct rio_mport
*mport
, u16 destid
, u8 hopcount
,
33 u16 table
, u16 route_destid
, u8 route_port
)
35 if (table
== RIO_GLOBAL_TABLE
) {
36 rio_mport_write_config_32(mport
, destid
, hopcount
,
37 SPBC_ROUTE_CFG_DESTID
, route_destid
);
38 rio_mport_write_config_32(mport
, destid
, hopcount
,
39 SPBC_ROUTE_CFG_PORT
, route_port
);
41 rio_mport_write_config_32(mport
, destid
, hopcount
,
42 SPP_ROUTE_CFG_DESTID(table
),
44 rio_mport_write_config_32(mport
, destid
, hopcount
,
45 SPP_ROUTE_CFG_PORT(table
), route_port
);
54 tsi568_route_get_entry(struct rio_mport
*mport
, u16 destid
, u8 hopcount
,
55 u16 table
, u16 route_destid
, u8
*route_port
)
60 if (table
== RIO_GLOBAL_TABLE
) {
61 rio_mport_write_config_32(mport
, destid
, hopcount
,
62 SPBC_ROUTE_CFG_DESTID
, route_destid
);
63 rio_mport_read_config_32(mport
, destid
, hopcount
,
64 SPBC_ROUTE_CFG_PORT
, &result
);
66 rio_mport_write_config_32(mport
, destid
, hopcount
,
67 SPP_ROUTE_CFG_DESTID(table
),
69 rio_mport_read_config_32(mport
, destid
, hopcount
,
70 SPP_ROUTE_CFG_PORT(table
), &result
);
81 tsi568_route_clr_table(struct rio_mport
*mport
, u16 destid
, u8 hopcount
,
87 lut_size
= (mport
->sys_size
) ? 0x1ff : 0xff;
89 if (table
== RIO_GLOBAL_TABLE
) {
90 rio_mport_write_config_32(mport
, destid
, hopcount
,
91 SPBC_ROUTE_CFG_DESTID
, 0x80000000);
92 for (route_idx
= 0; route_idx
<= lut_size
; route_idx
++)
93 rio_mport_write_config_32(mport
, destid
, hopcount
,
97 rio_mport_write_config_32(mport
, destid
, hopcount
,
98 SPP_ROUTE_CFG_DESTID(table
),
100 for (route_idx
= 0; route_idx
<= lut_size
; route_idx
++)
101 rio_mport_write_config_32(mport
, destid
, hopcount
,
102 SPP_ROUTE_CFG_PORT(table
),
109 DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA
, RIO_DID_TSI568
, tsi568_route_add_entry
, tsi568_route_get_entry
, tsi568_route_clr_table
);
112 tsi568_em_init(struct rio_dev
*rdev
)
114 struct rio_mport
*mport
= rdev
->net
->hport
;
115 u16 destid
= rdev
->rswitch
->destid
;
116 u8 hopcount
= rdev
->rswitch
->hopcount
;
119 pr_debug("TSI568 %s [%d:%d]\n", __func__
, destid
, hopcount
);
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
);
130 DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA
, RIO_DID_TSI568
, tsi568_em_init
, NULL
);