tsi57x.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * RapidIO Tsi57x switch family support
  3. *
  4. * Copyright 2009 Integrated Device Technology, Inc.
  5. * Copyright 2005 MontaVista Software, Inc.
  6. * Matt Porter <mporter@kernel.crashing.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/rio.h>
  14. #include <linux/rio_drv.h>
  15. #include <linux/rio_ids.h>
  16. #include <linux/delay.h>
  17. #include "../rio.h"
  18. /* Global (broadcast) route registers */
  19. #define SPBC_ROUTE_CFG_DESTID 0x10070
  20. #define SPBC_ROUTE_CFG_PORT 0x10074
  21. /* Per port route registers */
  22. #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n)
  23. #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n)
  24. static int
  25. tsi57x_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
  26. u16 table, u16 route_destid, u8 route_port)
  27. {
  28. if (table == RIO_GLOBAL_TABLE) {
  29. rio_mport_write_config_32(mport, destid, hopcount,
  30. SPBC_ROUTE_CFG_DESTID, route_destid);
  31. rio_mport_write_config_32(mport, destid, hopcount,
  32. SPBC_ROUTE_CFG_PORT, route_port);
  33. } else {
  34. rio_mport_write_config_32(mport, destid, hopcount,
  35. SPP_ROUTE_CFG_DESTID(table), route_destid);
  36. rio_mport_write_config_32(mport, destid, hopcount,
  37. SPP_ROUTE_CFG_PORT(table), route_port);
  38. }
  39. udelay(10);
  40. return 0;
  41. }
  42. static int
  43. tsi57x_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
  44. u16 table, u16 route_destid, u8 *route_port)
  45. {
  46. int ret = 0;
  47. u32 result;
  48. if (table == RIO_GLOBAL_TABLE) {
  49. /* Use local RT of the ingress port to avoid possible
  50. race condition */
  51. rio_mport_read_config_32(mport, destid, hopcount,
  52. RIO_SWP_INFO_CAR, &result);
  53. table = (result & RIO_SWP_INFO_PORT_NUM_MASK);
  54. }
  55. rio_mport_write_config_32(mport, destid, hopcount,
  56. SPP_ROUTE_CFG_DESTID(table), route_destid);
  57. rio_mport_read_config_32(mport, destid, hopcount,
  58. SPP_ROUTE_CFG_PORT(table), &result);
  59. *route_port = (u8)result;
  60. if (*route_port > 15)
  61. ret = -1;
  62. return ret;
  63. }
  64. static int
  65. tsi57x_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
  66. u16 table)
  67. {
  68. u32 route_idx;
  69. u32 lut_size;
  70. lut_size = (mport->sys_size) ? 0x1ff : 0xff;
  71. if (table == RIO_GLOBAL_TABLE) {
  72. rio_mport_write_config_32(mport, destid, hopcount,
  73. SPBC_ROUTE_CFG_DESTID, 0x80000000);
  74. for (route_idx = 0; route_idx <= lut_size; route_idx++)
  75. rio_mport_write_config_32(mport, destid, hopcount,
  76. SPBC_ROUTE_CFG_PORT,
  77. RIO_INVALID_ROUTE);
  78. } else {
  79. rio_mport_write_config_32(mport, destid, hopcount,
  80. SPP_ROUTE_CFG_DESTID(table), 0x80000000);
  81. for (route_idx = 0; route_idx <= lut_size; route_idx++)
  82. rio_mport_write_config_32(mport, destid, hopcount,
  83. SPP_ROUTE_CFG_PORT(table) , RIO_INVALID_ROUTE);
  84. }
  85. return 0;
  86. }
  87. DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI572, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
  88. DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI574, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
  89. DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI577, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);
  90. DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI578, tsi57x_route_add_entry, tsi57x_route_get_entry, tsi57x_route_clr_table);