aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2010-05-26 17:44:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 12:12:51 -0400
commit058f88d672b3161fe511ebe2996c3faef63c1c8e (patch)
treefb4bb8d93aef661cc9e24e1e6e2e8bd4edc2e764 /drivers/rapidio
parent011507e49a696462c30914e2eeebcdda33ed30f8 (diff)
rapidio: modify initialization of switch operations
Modify the way how RapidIO switch operations are declared. Multiple assignments through the linker script replaced by single initialization call. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Thomas Moll <thomas.moll@sysgo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio')
-rw-r--r--drivers/rapidio/rio-scan.c49
-rw-r--r--drivers/rapidio/rio.h56
-rw-r--r--drivers/rapidio/switches/idtcps.c27
-rw-r--r--drivers/rapidio/switches/tsi500.c18
-rw-r--r--drivers/rapidio/switches/tsi568.c20
-rw-r--r--drivers/rapidio/switches/tsi57x.c31
6 files changed, 102 insertions, 99 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 1faa1a5756e2..566432106cc5 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -246,24 +246,24 @@ static int rio_is_switch(struct rio_dev *rdev)
246} 246}
247 247
248/** 248/**
249 * rio_route_set_ops- Sets routing operations for a particular vendor switch 249 * rio_switch_init - Sets switch operations for a particular vendor switch
250 * @rdev: RIO device 250 * @rdev: RIO device
251 * @do_enum: Enumeration/Discovery mode flag
251 * 252 *
252 * Searches the RIO route ops table for known switch types. If the vid 253 * Searches the RIO switch ops table for known switch types. If the vid
253 * and did match a switch table entry, then set the add_entry() and 254 * and did match a switch table entry, then call switch initialization
254 * get_entry() ops to the table entry values. 255 * routine to setup switch-specific routines.
255 */ 256 */
256static void rio_route_set_ops(struct rio_dev *rdev) 257static void rio_switch_init(struct rio_dev *rdev, int do_enum)
257{ 258{
258 struct rio_route_ops *cur = __start_rio_route_ops; 259 struct rio_switch_ops *cur = __start_rio_switch_ops;
259 struct rio_route_ops *end = __end_rio_route_ops; 260 struct rio_switch_ops *end = __end_rio_switch_ops;
260 261
261 while (cur < end) { 262 while (cur < end) {
262 if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) { 263 if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) {
263 pr_debug("RIO: adding routing ops for %s\n", rio_name(rdev)); 264 pr_debug("RIO: calling init routine for %s\n",
264 rdev->rswitch->add_entry = cur->add_hook; 265 rio_name(rdev));
265 rdev->rswitch->get_entry = cur->get_hook; 266 cur->init_hook(rdev, do_enum);
266 rdev->rswitch->clr_table = cur->clr_hook;
267 break; 267 break;
268 } 268 }
269 cur++; 269 cur++;
@@ -283,30 +283,6 @@ static void rio_route_set_ops(struct rio_dev *rdev)
283} 283}
284 284
285/** 285/**
286 * rio_em_set_ops- Sets Error Managment operations for a particular vendor switch
287 * @rdev: RIO device
288 *
289 * Searches the RIO EM ops table for known switch types. If the vid
290 * and did match a switch table entry, then set the em_init() and
291 * em_handle() ops to the table entry values.
292 */
293static void rio_em_set_ops(struct rio_dev *rdev)
294{
295 struct rio_em_ops *cur = __start_rio_em_ops;
296 struct rio_em_ops *end = __end_rio_em_ops;
297
298 while (cur < end) {
299 if ((cur->vid == rdev->vid) && (cur->did == rdev->did)) {
300 pr_debug("RIO: adding EM ops for %s\n", rio_name(rdev));
301 rdev->rswitch->em_init = cur->init_hook;
302 rdev->rswitch->em_handle = cur->handler_hook;
303 break;
304 }
305 cur++;
306 }
307}
308
309/**
310 * rio_add_device- Adds a RIO device to the device model 286 * rio_add_device- Adds a RIO device to the device model
311 * @rdev: RIO device 287 * @rdev: RIO device
312 * 288 *
@@ -484,8 +460,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
484 rdev->rswitch = rswitch; 460 rdev->rswitch = rswitch;
485 dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id, 461 dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id,
486 rdev->rswitch->switchid); 462 rdev->rswitch->switchid);
487 rio_route_set_ops(rdev); 463 rio_switch_init(rdev, do_enum);
488 rio_em_set_ops(rdev);
489 464
490 if (do_enum && rdev->rswitch->clr_table) 465 if (do_enum && rdev->rswitch->clr_table)
491 rdev->rswitch->clr_table(port, destid, hopcount, 466 rdev->rswitch->clr_table(port, destid, hopcount,
diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h
index 2f628ce1a1c1..f27b7a9c47d2 100644
--- a/drivers/rapidio/rio.h
+++ b/drivers/rapidio/rio.h
@@ -39,55 +39,29 @@ extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
39extern struct device_attribute rio_dev_attrs[]; 39extern struct device_attribute rio_dev_attrs[];
40extern spinlock_t rio_global_list_lock; 40extern spinlock_t rio_global_list_lock;
41 41
42extern struct rio_route_ops __start_rio_route_ops[]; 42extern struct rio_switch_ops __start_rio_switch_ops[];
43extern struct rio_route_ops __end_rio_route_ops[]; 43extern struct rio_switch_ops __end_rio_switch_ops[];
44 44
45/* Helpers internal to the RIO core code */ 45/* Helpers internal to the RIO core code */
46#define DECLARE_RIO_ROUTE_SECTION(section, name, vid, did, add_hook, get_hook, clr_hook) \ 46#define DECLARE_RIO_SWITCH_SECTION(section, name, vid, did, init_hook) \
47 static const struct rio_route_ops __rio_route_##name __used \ 47 static const struct rio_switch_ops __rio_switch_##name __used \
48 __section(section) = { vid, did, add_hook, get_hook, clr_hook }; 48 __section(section) = { vid, did, init_hook };
49 49
50/** 50/**
51 * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations 51 * DECLARE_RIO_SWITCH_INIT - Registers switch initialization routine
52 * @vid: RIO vendor ID 52 * @vid: RIO vendor ID
53 * @did: RIO device ID 53 * @did: RIO device ID
54 * @add_hook: Callback that adds a route entry 54 * @init_hook: Callback that performs switch-specific initialization
55 * @get_hook: Callback that gets a route entry
56 * 55 *
57 * Manipulating switch route tables in RIO is switch specific. This 56 * Manipulating switch route tables and error management in RIO
58 * registers a switch by vendor and device ID with two callbacks for 57 * is switch specific. This registers a switch by vendor and device ID with
59 * modifying and retrieving route entries in a switch. A &struct 58 * initialization callback for setting up switch operations and (if required)
60 * rio_route_ops is initialized with the ops and placed into a 59 * hardware initialization. A &struct rio_switch_ops is initialized with
61 * RIO-specific kernel section. 60 * pointer to the init routine and placed into a RIO-specific kernel section.
62 */ 61 */
63#define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook, clr_hook) \ 62#define DECLARE_RIO_SWITCH_INIT(vid, did, init_hook) \
64 DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, vid##did, \ 63 DECLARE_RIO_SWITCH_SECTION(.rio_switch_ops, vid##did, \
65 vid, did, add_hook, get_hook, clr_hook) 64 vid, did, init_hook)
66 65
67#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16)) 66#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
68#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16)) 67#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
69
70/*
71 * RapidIO Error Management
72 */
73extern struct rio_em_ops __start_rio_em_ops[];
74extern struct rio_em_ops __end_rio_em_ops[];
75
76/* Helpers internal to the RIO core code */
77#define DECLARE_RIO_EM_SECTION(section, name, vid, did, init_hook, em_hook) \
78 static const struct rio_em_ops __rio_em_##name __used \
79 __section(section) = { vid, did, init_hook, em_hook };
80
81/**
82 * DECLARE_RIO_EM_OPS - Registers switch EM operations
83 * @vid: RIO vendor ID
84 * @did: RIO device ID
85 * @init_hook: Callback that initializes device specific EM
86 * @em_hook: Callback that handles device specific EM
87 *
88 * A &struct rio_em_ops is initialized with the ops and placed into a
89 * RIO-specific kernel section.
90 */
91#define DECLARE_RIO_EM_OPS(vid, did, init_hook, em_hook) \
92 DECLARE_RIO_EM_SECTION(.rio_em_ops, vid##did, \
93 vid, did, init_hook, em_hook)
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c
index 7e3d03283dec..46e6630dacd3 100644
--- a/drivers/rapidio/switches/idtcps.c
+++ b/drivers/rapidio/switches/idtcps.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * IDT CPS RapidIO switches support 2 * IDT CPS RapidIO switches support
3 * 3 *
4 * Copyright 2009 Integrated Device Technology, Inc. 4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Alexandre Bounine <alexandre.bounine@idt.com>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
@@ -81,9 +82,21 @@ idtcps_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
81 return 0; 82 return 0;
82} 83}
83 84
84DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS6Q, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 85static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
85DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS8, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 86{
86DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS10Q, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 87 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
87DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS12, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 88 rdev->rswitch->add_entry = idtcps_route_add_entry;
88DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS16, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 89 rdev->rswitch->get_entry = idtcps_route_get_entry;
89DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDT70K200, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table); 90 rdev->rswitch->clr_table = idtcps_route_clr_table;
91 rdev->rswitch->em_init = NULL;
92 rdev->rswitch->em_handle = NULL;
93
94 return 0;
95}
96
97DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS6Q, idtcps_switch_init);
98DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS8, idtcps_switch_init);
99DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS10Q, idtcps_switch_init);
100DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS12, idtcps_switch_init);
101DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS16, idtcps_switch_init);
102DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDT70K200, idtcps_switch_init);
diff --git a/drivers/rapidio/switches/tsi500.c b/drivers/rapidio/switches/tsi500.c
index ae553bb41089..65b865d64d34 100644
--- a/drivers/rapidio/switches/tsi500.c
+++ b/drivers/rapidio/switches/tsi500.c
@@ -1,6 +1,10 @@
1/* 1/*
2 * RapidIO Tsi500 switch support 2 * RapidIO Tsi500 switch support
3 * 3 *
4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Alexandre Bounine <alexandre.bounine@idt.com>
6 * - Modified switch operations initialization.
7 *
4 * Copyright 2005 MontaVista Software, Inc. 8 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org> 9 * Matt Porter <mporter@kernel.crashing.org>
6 * 10 *
@@ -57,4 +61,16 @@ tsi500_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 tab
57 return ret; 61 return ret;
58} 62}
59 63
60DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_route_add_entry, tsi500_route_get_entry, NULL); 64static int tsi500_switch_init(struct rio_dev *rdev, int do_enum)
65{
66 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
67 rdev->rswitch->add_entry = tsi500_route_add_entry;
68 rdev->rswitch->get_entry = tsi500_route_get_entry;
69 rdev->rswitch->clr_table = NULL;
70 rdev->rswitch->em_init = NULL;
71 rdev->rswitch->em_handle = NULL;
72
73 return 0;
74}
75
76DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_switch_init);
diff --git a/drivers/rapidio/switches/tsi568.c b/drivers/rapidio/switches/tsi568.c
index 905cf9cb09cc..322840d43832 100644
--- a/drivers/rapidio/switches/tsi568.c
+++ b/drivers/rapidio/switches/tsi568.c
@@ -2,6 +2,10 @@
2 * RapidIO Tsi568 switch support 2 * RapidIO Tsi568 switch support
3 * 3 *
4 * Copyright 2009-2010 Integrated Device Technology, Inc. 4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Alexandre Bounine <alexandre.bounine@idt.com>
6 * - Added EM support
7 * - Modified switch operations initialization.
8 *
5 * Copyright 2005 MontaVista Software, Inc. 9 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org> 10 * Matt Porter <mporter@kernel.crashing.org>
7 * 11 *
@@ -106,8 +110,6 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
106 return 0; 110 return 0;
107} 111}
108 112
109DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table);
110
111static int 113static int
112tsi568_em_init(struct rio_dev *rdev) 114tsi568_em_init(struct rio_dev *rdev)
113{ 115{
@@ -127,4 +129,16 @@ tsi568_em_init(struct rio_dev *rdev)
127 return 0; 129 return 0;
128} 130}
129 131
130DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_em_init, NULL); 132static int tsi568_switch_init(struct rio_dev *rdev, int do_enum)
133{
134 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
135 rdev->rswitch->add_entry = tsi568_route_add_entry;
136 rdev->rswitch->get_entry = tsi568_route_get_entry;
137 rdev->rswitch->clr_table = tsi568_route_clr_table;
138 rdev->rswitch->em_init = tsi568_em_init;
139 rdev->rswitch->em_handle = NULL;
140
141 return 0;
142}
143
144DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_switch_init);
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c
index 23040b92ea76..2e902d3e1abe 100644
--- a/drivers/rapidio/switches/tsi57x.c
+++ b/drivers/rapidio/switches/tsi57x.c
@@ -1,7 +1,11 @@
1/* 1/*
2 * RapidIO Tsi57x switch family support 2 * RapidIO Tsi57x switch family support
3 * 3 *
4 * Copyright 2009 Integrated Device Technology, Inc. 4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Alexandre Bounine <alexandre.bounine@idt.com>
6 * - Added EM support
7 * - Modified switch operations initialization.
8 *
5 * Copyright 2005 MontaVista Software, Inc. 9 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org> 10 * Matt Porter <mporter@kernel.crashing.org>
7 * 11 *
@@ -108,11 +112,6 @@ tsi57x_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
108 return 0; 112 return 0;
109} 113}
110 114
111DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
112DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
113DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
114DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
115
116static int 115static int
117tsi57x_em_init(struct rio_dev *rdev) 116tsi57x_em_init(struct rio_dev *rdev)
118{ 117{
@@ -253,7 +252,19 @@ exit_es:
253 return 0; 252 return 0;
254} 253}
255 254
256DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_em_init, tsi57x_em_handler); 255static int tsi57x_switch_init(struct rio_dev *rdev, int do_enum)
257DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_em_init, tsi57x_em_handler); 256{
258DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_em_init, tsi57x_em_handler); 257 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
259DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_em_init, tsi57x_em_handler); 258 rdev->rswitch->add_entry = tsi57x_route_add_entry;
259 rdev->rswitch->get_entry = tsi57x_route_get_entry;
260 rdev->rswitch->clr_table = tsi57x_route_clr_table;
261 rdev->rswitch->em_init = tsi57x_em_init;
262 rdev->rswitch->em_handle = tsi57x_em_handler;
263
264 return 0;
265}
266
267DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_switch_init);
268DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_switch_init);
269DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_switch_init);
270DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_switch_init);