mv88e6171.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* net/dsa/mv88e6171.c - Marvell 88e6171 switch chip support
  2. * Copyright (c) 2008-2009 Marvell Semiconductor
  3. * Copyright (c) 2014 Claudio Leite <leitec@staticky.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #include <linux/delay.h>
  11. #include <linux/jiffies.h>
  12. #include <linux/list.h>
  13. #include <linux/module.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/phy.h>
  16. #include <net/dsa.h>
  17. #include "mv88e6xxx.h"
  18. static const struct mv88e6xxx_info mv88e6171_table[] = {
  19. {
  20. .prod_num = PORT_SWITCH_ID_PROD_NUM_6171,
  21. .family = MV88E6XXX_FAMILY_6351,
  22. .name = "Marvell 88E6171",
  23. .num_databases = 4096,
  24. .num_ports = 7,
  25. }, {
  26. .prod_num = PORT_SWITCH_ID_PROD_NUM_6175,
  27. .family = MV88E6XXX_FAMILY_6351,
  28. .name = "Marvell 88E6175",
  29. .num_databases = 4096,
  30. .num_ports = 7,
  31. }, {
  32. .prod_num = PORT_SWITCH_ID_PROD_NUM_6350,
  33. .family = MV88E6XXX_FAMILY_6351,
  34. .name = "Marvell 88E6350",
  35. .num_databases = 4096,
  36. .num_ports = 7,
  37. }, {
  38. .prod_num = PORT_SWITCH_ID_PROD_NUM_6351,
  39. .family = MV88E6XXX_FAMILY_6351,
  40. .name = "Marvell 88E6351",
  41. .num_databases = 4096,
  42. .num_ports = 7,
  43. }
  44. };
  45. static const char *mv88e6171_drv_probe(struct device *dsa_dev,
  46. struct device *host_dev, int sw_addr,
  47. void **priv)
  48. {
  49. return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
  50. mv88e6171_table,
  51. ARRAY_SIZE(mv88e6171_table));
  52. }
  53. static int mv88e6171_setup_global(struct dsa_switch *ds)
  54. {
  55. u32 upstream_port = dsa_upstream_port(ds);
  56. int ret;
  57. u32 reg;
  58. ret = mv88e6xxx_setup_global(ds);
  59. if (ret)
  60. return ret;
  61. /* Discard packets with excessive collisions, mask all
  62. * interrupt sources, enable PPU.
  63. */
  64. ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL,
  65. GLOBAL_CONTROL_PPU_ENABLE |
  66. GLOBAL_CONTROL_DISCARD_EXCESS);
  67. if (ret)
  68. return ret;
  69. /* Configure the upstream port, and configure the upstream
  70. * port as the port to which ingress and egress monitor frames
  71. * are to be sent.
  72. */
  73. reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
  74. upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
  75. upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
  76. upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
  77. ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
  78. if (ret)
  79. return ret;
  80. /* Disable remote management for now, and set the switch's
  81. * DSA device number.
  82. */
  83. return mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_CONTROL_2,
  84. ds->index & 0x1f);
  85. }
  86. static int mv88e6171_setup(struct dsa_switch *ds)
  87. {
  88. int ret;
  89. ret = mv88e6xxx_setup_common(ds);
  90. if (ret < 0)
  91. return ret;
  92. ret = mv88e6xxx_switch_reset(ds, true);
  93. if (ret < 0)
  94. return ret;
  95. ret = mv88e6171_setup_global(ds);
  96. if (ret < 0)
  97. return ret;
  98. return mv88e6xxx_setup_ports(ds);
  99. }
  100. struct dsa_switch_driver mv88e6171_switch_driver = {
  101. .tag_protocol = DSA_TAG_PROTO_EDSA,
  102. .probe = mv88e6171_drv_probe,
  103. .setup = mv88e6171_setup,
  104. .set_addr = mv88e6xxx_set_addr_indirect,
  105. .phy_read = mv88e6xxx_phy_read_indirect,
  106. .phy_write = mv88e6xxx_phy_write_indirect,
  107. .get_strings = mv88e6xxx_get_strings,
  108. .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
  109. .get_sset_count = mv88e6xxx_get_sset_count,
  110. .adjust_link = mv88e6xxx_adjust_link,
  111. #ifdef CONFIG_NET_DSA_HWMON
  112. .get_temp = mv88e6xxx_get_temp,
  113. #endif
  114. .get_regs_len = mv88e6xxx_get_regs_len,
  115. .get_regs = mv88e6xxx_get_regs,
  116. .port_bridge_join = mv88e6xxx_port_bridge_join,
  117. .port_bridge_leave = mv88e6xxx_port_bridge_leave,
  118. .port_stp_state_set = mv88e6xxx_port_stp_state_set,
  119. .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
  120. .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
  121. .port_vlan_add = mv88e6xxx_port_vlan_add,
  122. .port_vlan_del = mv88e6xxx_port_vlan_del,
  123. .port_vlan_dump = mv88e6xxx_port_vlan_dump,
  124. .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
  125. .port_fdb_add = mv88e6xxx_port_fdb_add,
  126. .port_fdb_del = mv88e6xxx_port_fdb_del,
  127. .port_fdb_dump = mv88e6xxx_port_fdb_dump,
  128. };
  129. MODULE_ALIAS("platform:mv88e6171");
  130. MODULE_ALIAS("platform:mv88e6175");
  131. MODULE_ALIAS("platform:mv88e6350");
  132. MODULE_ALIAS("platform:mv88e6351");