tsi500.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * RapidIO Tsi500 switch support
  3. *
  4. * Copyright 2005 MontaVista Software, Inc.
  5. * Matt Porter <mporter@kernel.crashing.org>
  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. #include <linux/rio.h>
  13. #include <linux/rio_drv.h>
  14. #include <linux/rio_ids.h>
  15. #include "../rio.h"
  16. static int
  17. tsi500_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 route_port)
  18. {
  19. int i;
  20. u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
  21. u32 result;
  22. if (table == 0xff) {
  23. rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
  24. result &= ~(0xf << (4*(route_destid & 0x7)));
  25. for (i=0;i<4;i++)
  26. rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*i), result | (route_port << (4*(route_destid & 0x7))));
  27. }
  28. else {
  29. rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
  30. result &= ~(0xf << (4*(route_destid & 0x7)));
  31. rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*table), result | (route_port << (4*(route_destid & 0x7))));
  32. }
  33. return 0;
  34. }
  35. static int
  36. tsi500_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 *route_port)
  37. {
  38. int ret = 0;
  39. u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
  40. u32 result;
  41. if (table == 0xff)
  42. rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
  43. else
  44. rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
  45. result &= 0xf << (4*(route_destid & 0x7));
  46. *route_port = result >> (4*(route_destid & 0x7));
  47. if (*route_port > 3)
  48. ret = -1;
  49. return ret;
  50. }
  51. DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_route_add_entry, tsi500_route_get_entry);