2 * RapidIO Tsi500 switch support
4 * Copyright 2009-2010 Integrated Device Technology, Inc.
5 * Alexandre Bounine <alexandre.bounine@idt.com>
6 * - Modified switch operations initialization.
8 * Copyright 2005 MontaVista Software, Inc.
9 * Matt Porter <mporter@kernel.crashing.org>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
17 #include <linux/rio.h>
18 #include <linux/rio_drv.h>
19 #include <linux/rio_ids.h>
23 tsi500_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 route_port)
26 u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
30 rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
31 result &= ~(0xf << (4*(route_destid & 0x7)));
33 rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*i), result | (route_port << (4*(route_destid & 0x7))));
36 rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
37 result &= ~(0xf << (4*(route_destid & 0x7)));
38 rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*table), result | (route_port << (4*(route_destid & 0x7))));
45 tsi500_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 *route_port)
48 u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
52 rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
54 rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
56 result &= 0xf << (4*(route_destid & 0x7));
57 *route_port = result >> (4*(route_destid & 0x7));
64 static int tsi500_switch_init(struct rio_dev *rdev, int do_enum)
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;
76 DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_switch_init);