diff options
Diffstat (limited to 'drivers/rapidio/switches/idtcps.c')
-rw-r--r-- | drivers/rapidio/switches/idtcps.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c new file mode 100644 index 000000000000..2c790c144f89 --- /dev/null +++ b/drivers/rapidio/switches/idtcps.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * IDT CPS RapidIO switches support | ||
3 | * | ||
4 | * Copyright 2009-2010 Integrated Device Technology, Inc. | ||
5 | * Alexandre Bounine <alexandre.bounine@idt.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/rio.h> | ||
14 | #include <linux/rio_drv.h> | ||
15 | #include <linux/rio_ids.h> | ||
16 | #include "../rio.h" | ||
17 | |||
18 | #define CPS_DEFAULT_ROUTE 0xde | ||
19 | #define CPS_NO_ROUTE 0xdf | ||
20 | |||
21 | #define IDTCPS_RIO_DOMAIN 0xf20020 | ||
22 | |||
23 | static int | ||
24 | idtcps_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
25 | u16 table, u16 route_destid, u8 route_port) | ||
26 | { | ||
27 | u32 result; | ||
28 | |||
29 | if (table == RIO_GLOBAL_TABLE) { | ||
30 | rio_mport_write_config_32(mport, destid, hopcount, | ||
31 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid); | ||
32 | |||
33 | rio_mport_read_config_32(mport, destid, hopcount, | ||
34 | RIO_STD_RTE_CONF_PORT_SEL_CSR, &result); | ||
35 | |||
36 | result = (0xffffff00 & result) | (u32)route_port; | ||
37 | rio_mport_write_config_32(mport, destid, hopcount, | ||
38 | RIO_STD_RTE_CONF_PORT_SEL_CSR, result); | ||
39 | } | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | static int | ||
45 | idtcps_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
46 | u16 table, u16 route_destid, u8 *route_port) | ||
47 | { | ||
48 | u32 result; | ||
49 | |||
50 | if (table == RIO_GLOBAL_TABLE) { | ||
51 | rio_mport_write_config_32(mport, destid, hopcount, | ||
52 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid); | ||
53 | |||
54 | rio_mport_read_config_32(mport, destid, hopcount, | ||
55 | RIO_STD_RTE_CONF_PORT_SEL_CSR, &result); | ||
56 | |||
57 | if (CPS_DEFAULT_ROUTE == (u8)result || | ||
58 | CPS_NO_ROUTE == (u8)result) | ||
59 | *route_port = RIO_INVALID_ROUTE; | ||
60 | else | ||
61 | *route_port = (u8)result; | ||
62 | } | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int | ||
68 | idtcps_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
69 | u16 table) | ||
70 | { | ||
71 | u32 i; | ||
72 | |||
73 | if (table == RIO_GLOBAL_TABLE) { | ||
74 | for (i = 0x80000000; i <= 0x800000ff;) { | ||
75 | rio_mport_write_config_32(mport, destid, hopcount, | ||
76 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, i); | ||
77 | rio_mport_write_config_32(mport, destid, hopcount, | ||
78 | RIO_STD_RTE_CONF_PORT_SEL_CSR, | ||
79 | (CPS_DEFAULT_ROUTE << 24) | | ||
80 | (CPS_DEFAULT_ROUTE << 16) | | ||
81 | (CPS_DEFAULT_ROUTE << 8) | CPS_DEFAULT_ROUTE); | ||
82 | i += 4; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static int | ||
90 | idtcps_set_domain(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
91 | u8 sw_domain) | ||
92 | { | ||
93 | /* | ||
94 | * Switch domain configuration operates only at global level | ||
95 | */ | ||
96 | rio_mport_write_config_32(mport, destid, hopcount, | ||
97 | IDTCPS_RIO_DOMAIN, (u32)sw_domain); | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static int | ||
102 | idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
103 | u8 *sw_domain) | ||
104 | { | ||
105 | u32 regval; | ||
106 | |||
107 | /* | ||
108 | * Switch domain configuration operates only at global level | ||
109 | */ | ||
110 | rio_mport_read_config_32(mport, destid, hopcount, | ||
111 | IDTCPS_RIO_DOMAIN, ®val); | ||
112 | |||
113 | *sw_domain = (u8)(regval & 0xff); | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) | ||
119 | { | ||
120 | pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); | ||
121 | rdev->rswitch->add_entry = idtcps_route_add_entry; | ||
122 | rdev->rswitch->get_entry = idtcps_route_get_entry; | ||
123 | rdev->rswitch->clr_table = idtcps_route_clr_table; | ||
124 | rdev->rswitch->set_domain = idtcps_set_domain; | ||
125 | rdev->rswitch->get_domain = idtcps_get_domain; | ||
126 | rdev->rswitch->em_init = NULL; | ||
127 | rdev->rswitch->em_handle = NULL; | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS6Q, idtcps_switch_init); | ||
133 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS8, idtcps_switch_init); | ||
134 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS10Q, idtcps_switch_init); | ||
135 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS12, idtcps_switch_init); | ||
136 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS16, idtcps_switch_init); | ||
137 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDT70K200, idtcps_switch_init); | ||