diff options
Diffstat (limited to 'drivers/rapidio/switches/tsi568.c')
-rw-r--r-- | drivers/rapidio/switches/tsi568.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/rapidio/switches/tsi568.c b/drivers/rapidio/switches/tsi568.c new file mode 100644 index 000000000000..bce9112ff0d9 --- /dev/null +++ b/drivers/rapidio/switches/tsi568.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * RapidIO Tsi568 switch support | ||
3 | * | ||
4 | * Copyright 2009-2010 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 | |||
28 | static int | ||
29 | tsi568_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), | ||
40 | route_destid); | ||
41 | rio_mport_write_config_32(mport, destid, hopcount, | ||
42 | SPP_ROUTE_CFG_PORT(table), route_port); | ||
43 | } | ||
44 | |||
45 | udelay(10); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int | ||
51 | tsi568_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
52 | u16 table, u16 route_destid, u8 *route_port) | ||
53 | { | ||
54 | int ret = 0; | ||
55 | u32 result; | ||
56 | |||
57 | if (table == RIO_GLOBAL_TABLE) { | ||
58 | rio_mport_write_config_32(mport, destid, hopcount, | ||
59 | SPBC_ROUTE_CFG_DESTID, route_destid); | ||
60 | rio_mport_read_config_32(mport, destid, hopcount, | ||
61 | SPBC_ROUTE_CFG_PORT, &result); | ||
62 | } else { | ||
63 | rio_mport_write_config_32(mport, destid, hopcount, | ||
64 | SPP_ROUTE_CFG_DESTID(table), | ||
65 | route_destid); | ||
66 | rio_mport_read_config_32(mport, destid, hopcount, | ||
67 | SPP_ROUTE_CFG_PORT(table), &result); | ||
68 | } | ||
69 | |||
70 | *route_port = result; | ||
71 | if (*route_port > 15) | ||
72 | ret = -1; | ||
73 | |||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | static int | ||
78 | tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
79 | u16 table) | ||
80 | { | ||
81 | u32 route_idx; | ||
82 | u32 lut_size; | ||
83 | |||
84 | lut_size = (mport->sys_size) ? 0x1ff : 0xff; | ||
85 | |||
86 | if (table == RIO_GLOBAL_TABLE) { | ||
87 | rio_mport_write_config_32(mport, destid, hopcount, | ||
88 | SPBC_ROUTE_CFG_DESTID, 0x80000000); | ||
89 | for (route_idx = 0; route_idx <= lut_size; route_idx++) | ||
90 | rio_mport_write_config_32(mport, destid, hopcount, | ||
91 | SPBC_ROUTE_CFG_PORT, | ||
92 | RIO_INVALID_ROUTE); | ||
93 | } else { | ||
94 | rio_mport_write_config_32(mport, destid, hopcount, | ||
95 | SPP_ROUTE_CFG_DESTID(table), | ||
96 | 0x80000000); | ||
97 | for (route_idx = 0; route_idx <= lut_size; route_idx++) | ||
98 | rio_mport_write_config_32(mport, destid, hopcount, | ||
99 | SPP_ROUTE_CFG_PORT(table), | ||
100 | RIO_INVALID_ROUTE); | ||
101 | } | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table); | ||