tsi500.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * RapidIO Tsi500 switch support
  3. *
  4. * Copyright 2009-2010 Integrated Device Technology, Inc.
  5. * Alexandre Bounine <alexandre.bounine@idt.com>
  6. * - Modified switch operations initialization.
  7. *
  8. * Copyright 2005 MontaVista Software, Inc.
  9. * Matt Porter <mporter@kernel.crashing.org>
  10. *
  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.
  15. */
  16. #include <linux/rio.h>
  17. #include <linux/rio_drv.h>
  18. #include <linux/rio_ids.h>
  19. #include "../rio.h"
  20. static int
  21. tsi500_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 route_port)
  22. {
  23. int i;
  24. u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
  25. u32 result;
  26. if (table == 0xff) {
  27. rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
  28. result &= ~(0xf << (4*(route_destid & 0x7)));
  29. for (i=0;i<4;i++)
  30. rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*i), result | (route_port << (4*(route_destid & 0x7))));
  31. }
  32. else {
  33. rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
  34. result &= ~(0xf << (4*(route_destid & 0x7)));
  35. rio_mport_write_config_32(mport, destid, hopcount, offset + (0x20000*table), result | (route_port << (4*(route_destid & 0x7))));
  36. }
  37. return 0;
  38. }
  39. static int
  40. tsi500_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 *route_port)
  41. {
  42. int ret = 0;
  43. u32 offset = 0x10000 + 0xa00 + ((route_destid / 2)&~0x3);
  44. u32 result;
  45. if (table == 0xff)
  46. rio_mport_read_config_32(mport, destid, hopcount, offset, &result);
  47. else
  48. rio_mport_read_config_32(mport, destid, hopcount, offset + (0x20000*table), &result);
  49. result &= 0xf << (4*(route_destid & 0x7));
  50. *route_port = result >> (4*(route_destid & 0x7));
  51. if (*route_port > 3)
  52. ret = -1;
  53. return ret;
  54. }
  55. static int tsi500_switch_init(struct rio_dev *rdev, int do_enum)
  56. {
  57. pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
  58. rdev->rswitch->add_entry = tsi500_route_add_entry;
  59. rdev->rswitch->get_entry = tsi500_route_get_entry;
  60. rdev->rswitch->clr_table = NULL;
  61. rdev->rswitch->set_domain = NULL;
  62. rdev->rswitch->get_domain = NULL;
  63. rdev->rswitch->em_init = NULL;
  64. rdev->rswitch->em_handle = NULL;
  65. return 0;
  66. }
  67. DECLARE_RIO_SWITCH_INIT(RIO_VID_TUNDRA, RIO_DID_TSI500, tsi500_switch_init);