mvswitch.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Marvell 88E6060 switch driver
  3. * Copyright (c) 2008 Felix Fietkau <nbd@nbd.name>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License v2 as published by the
  7. * Free Software Foundation
  8. */
  9. #ifndef __MVSWITCH_H
  10. #define __MVSWITCH_H
  11. #define MV_HEADER_SIZE 2
  12. #define MV_HEADER_PORTS_M 0x001f
  13. #define MV_HEADER_PORTS_S 0
  14. #define MV_HEADER_VLAN_M 0xf000
  15. #define MV_HEADER_VLAN_S 12
  16. #define MV_TRAILER_SIZE 4
  17. #define MV_TRAILER_PORTS_M 0x1f
  18. #define MV_TRAILER_PORTS_S 16
  19. #define MV_TRAILER_FLAGS_S 24
  20. #define MV_TRAILER_OVERRIDE 0x80
  21. #define MV_PORTS 5
  22. #define MV_WANPORT 4
  23. #define MV_CPUPORT 5
  24. #define MV_BASE 0x10
  25. #define MV_PHYPORT_BASE (MV_BASE + 0x0)
  26. #define MV_PHYPORT(_n) (MV_PHYPORT_BASE + (_n))
  27. #define MV_SWITCHPORT_BASE (MV_BASE + 0x8)
  28. #define MV_SWITCHPORT(_n) (MV_SWITCHPORT_BASE + (_n))
  29. #define MV_SWITCHREGS (MV_BASE + 0xf)
  30. enum {
  31. MV_PHY_CONTROL = 0x00,
  32. MV_PHY_STATUS = 0x01,
  33. MV_PHY_IDENT0 = 0x02,
  34. MV_PHY_IDENT1 = 0x03,
  35. MV_PHY_ANEG = 0x04,
  36. MV_PHY_LINK_ABILITY = 0x05,
  37. MV_PHY_ANEG_EXPAND = 0x06,
  38. MV_PHY_XMIT_NEXTP = 0x07,
  39. MV_PHY_LINK_NEXTP = 0x08,
  40. MV_PHY_CONTROL1 = 0x10,
  41. MV_PHY_STATUS1 = 0x11,
  42. MV_PHY_INTR_EN = 0x12,
  43. MV_PHY_INTR_STATUS = 0x13,
  44. MV_PHY_INTR_PORT = 0x14,
  45. MV_PHY_RECV_COUNTER = 0x16,
  46. MV_PHY_LED_PARALLEL = 0x16,
  47. MV_PHY_LED_STREAM = 0x17,
  48. MV_PHY_LED_CTRL = 0x18,
  49. MV_PHY_LED_OVERRIDE = 0x19,
  50. MV_PHY_VCT_CTRL = 0x1a,
  51. MV_PHY_VCT_STATUS = 0x1b,
  52. MV_PHY_CONTROL2 = 0x1e
  53. };
  54. #define MV_PHYREG(_type, _port) MV_PHYPORT(_port), MV_PHY_##_type
  55. enum {
  56. MV_PORT_STATUS = 0x00,
  57. MV_PORT_IDENT = 0x03,
  58. MV_PORT_CONTROL = 0x04,
  59. MV_PORT_VLANMAP = 0x06,
  60. MV_PORT_ASSOC = 0x0b,
  61. MV_PORT_RXCOUNT = 0x10,
  62. MV_PORT_TXCOUNT = 0x11,
  63. };
  64. #define MV_PORTREG(_type, _port) MV_SWITCHPORT(_port), MV_PORT_##_type
  65. enum {
  66. MV_PORTCTRL_BLOCK = (1 << 0),
  67. MV_PORTCTRL_LEARN = (2 << 0),
  68. MV_PORTCTRL_ENABLED = (3 << 0),
  69. MV_PORTCTRL_VLANTUN = (1 << 7), /* Enforce VLANs on packets */
  70. MV_PORTCTRL_RXTR = (1 << 8), /* Enable Marvell packet trailer for ingress */
  71. MV_PORTCTRL_HEADER = (1 << 11), /* Enable Marvell packet header mode for port */
  72. MV_PORTCTRL_TXTR = (1 << 14), /* Enable Marvell packet trailer for egress */
  73. MV_PORTCTRL_FORCEFL = (1 << 15), /* force flow control */
  74. };
  75. #define MV_PORTVLAN_ID(_n) (((_n) & 0xf) << 12)
  76. #define MV_PORTVLAN_PORTS(_n) ((_n) & 0x3f)
  77. #define MV_PORTASSOC_PORTS(_n) ((_n) & 0x1f)
  78. #define MV_PORTASSOC_MONITOR (1 << 15)
  79. enum {
  80. MV_SWITCH_MAC0 = 0x01,
  81. MV_SWITCH_MAC1 = 0x02,
  82. MV_SWITCH_MAC2 = 0x03,
  83. MV_SWITCH_CTRL = 0x04,
  84. MV_SWITCH_ATU_CTRL = 0x0a,
  85. MV_SWITCH_ATU_OP = 0x0b,
  86. MV_SWITCH_ATU_DATA = 0x0c,
  87. MV_SWITCH_ATU_MAC0 = 0x0d,
  88. MV_SWITCH_ATU_MAC1 = 0x0e,
  89. MV_SWITCH_ATU_MAC2 = 0x0f,
  90. };
  91. #define MV_SWITCHREG(_type) MV_SWITCHREGS, MV_SWITCH_##_type
  92. enum {
  93. MV_SWITCHCTL_EEIE = (1 << 0), /* EEPROM interrupt enable */
  94. MV_SWITCHCTL_PHYIE = (1 << 1), /* PHY interrupt enable */
  95. MV_SWITCHCTL_ATUDONE= (1 << 2), /* ATU done interrupt enable */
  96. MV_SWITCHCTL_ATUIE = (1 << 3), /* ATU interrupt enable */
  97. MV_SWITCHCTL_CTRMODE= (1 << 8), /* statistics for rx and tx errors */
  98. MV_SWITCHCTL_RELOAD = (1 << 9), /* reload registers from eeprom */
  99. MV_SWITCHCTL_MSIZE = (1 << 10), /* increase maximum frame size */
  100. MV_SWITCHCTL_DROP = (1 << 13), /* discard frames with excessive collisions */
  101. };
  102. enum {
  103. #define MV_ATUCTL_AGETIME_MIN 16
  104. #define MV_ATUCTL_AGETIME_MAX 4080
  105. #define MV_ATUCTL_AGETIME(_n) ((((_n) / 16) & 0xff) << 4)
  106. MV_ATUCTL_ATU_256 = (0 << 12),
  107. MV_ATUCTL_ATU_512 = (1 << 12),
  108. MV_ATUCTL_ATU_1K = (2 << 12),
  109. MV_ATUCTL_ATUMASK = (3 << 12),
  110. MV_ATUCTL_NO_LEARN = (1 << 14),
  111. MV_ATUCTL_RESET = (1 << 15),
  112. };
  113. enum {
  114. #define MV_ATUOP_DBNUM(_n) ((_n) & 0x0f)
  115. MV_ATUOP_NOOP = (0 << 12),
  116. MV_ATUOP_FLUSH_ALL = (1 << 12),
  117. MV_ATUOP_FLUSH_U = (2 << 12),
  118. MV_ATUOP_LOAD_DB = (3 << 12),
  119. MV_ATUOP_GET_NEXT = (4 << 12),
  120. MV_ATUOP_FLUSH_DB = (5 << 12),
  121. MV_ATUOP_FLUSH_DB_UU= (6 << 12),
  122. MV_ATUOP_INPROGRESS = (1 << 15),
  123. };
  124. #define MV_IDENT_MASK 0xfff0
  125. #define MV_IDENT_VALUE 0x0600
  126. #endif