idtcps.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * IDT CPS RapidIO switches support
  3. *
  4. * Copyright 2009 Integrated Device Technology, Inc.
  5. *
  6. * 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. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/rio.h>
  12. #include <linux/rio_drv.h>
  13. #include <linux/rio_ids.h>
  14. #include "../rio.h"
  15. #define CPS_NO_ROUTE 0xdf
  16. static int
  17. idtcps_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
  18. u16 table, u16 route_destid, u8 route_port)
  19. {
  20. u32 result;
  21. if (table == RIO_GLOBAL_TABLE) {
  22. rio_mport_write_config_32(mport, destid, hopcount,
  23. RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid);
  24. rio_mport_read_config_32(mport, destid, hopcount,
  25. RIO_STD_RTE_CONF_PORT_SEL_CSR, &result);
  26. result = (0xffffff00 & result) | (u32)route_port;
  27. rio_mport_write_config_32(mport, destid, hopcount,
  28. RIO_STD_RTE_CONF_PORT_SEL_CSR, result);
  29. }
  30. return 0;
  31. }
  32. static int
  33. idtcps_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
  34. u16 table, u16 route_destid, u8 *route_port)
  35. {
  36. u32 result;
  37. if (table == RIO_GLOBAL_TABLE) {
  38. rio_mport_write_config_32(mport, destid, hopcount,
  39. RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid);
  40. rio_mport_read_config_32(mport, destid, hopcount,
  41. RIO_STD_RTE_CONF_PORT_SEL_CSR, &result);
  42. if (CPS_NO_ROUTE == (u8)result)
  43. result = RIO_INVALID_ROUTE;
  44. *route_port = (u8)result;
  45. }
  46. return 0;
  47. }
  48. static int
  49. idtcps_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
  50. u16 table)
  51. {
  52. u32 i;
  53. if (table == RIO_GLOBAL_TABLE) {
  54. for (i = 0x80000000; i <= 0x800000ff;) {
  55. rio_mport_write_config_32(mport, destid, hopcount,
  56. RIO_STD_RTE_CONF_DESTID_SEL_CSR, i);
  57. rio_mport_write_config_32(mport, destid, hopcount,
  58. RIO_STD_RTE_CONF_PORT_SEL_CSR,
  59. (RIO_INVALID_ROUTE << 24) |
  60. (RIO_INVALID_ROUTE << 16) |
  61. (RIO_INVALID_ROUTE << 8) | RIO_INVALID_ROUTE);
  62. i += 4;
  63. }
  64. }
  65. return 0;
  66. }
  67. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS6Q, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);
  68. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS8, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);
  69. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS10Q, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);
  70. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS12, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);
  71. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDTCPS16, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);
  72. DECLARE_RIO_ROUTE_OPS(RIO_VID_IDT, RIO_DID_IDT70K200, idtcps_route_add_entry, idtcps_route_get_entry, idtcps_route_clr_table);