mv88e6171.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_switch_id mv88e6171_table[] = {
  19. { PORT_SWITCH_ID_6171, "Marvell 88E6171" },
  20. { PORT_SWITCH_ID_6175, "Marvell 88E6175" },
  21. { PORT_SWITCH_ID_6350, "Marvell 88E6350" },
  22. { PORT_SWITCH_ID_6351, "Marvell 88E6351" },
  23. };
  24. static char *mv88e6171_probe(struct device *host_dev, int sw_addr)
  25. {
  26. return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table,
  27. ARRAY_SIZE(mv88e6171_table));
  28. }
  29. static int mv88e6171_setup_global(struct dsa_switch *ds)
  30. {
  31. u32 upstream_port = dsa_upstream_port(ds);
  32. int ret;
  33. u32 reg;
  34. ret = mv88e6xxx_setup_global(ds);
  35. if (ret)
  36. return ret;
  37. /* Discard packets with excessive collisions, mask all
  38. * interrupt sources, enable PPU.
  39. */
  40. REG_WRITE(REG_GLOBAL, GLOBAL_CONTROL,
  41. GLOBAL_CONTROL_PPU_ENABLE | GLOBAL_CONTROL_DISCARD_EXCESS);
  42. /* Configure the upstream port, and configure the upstream
  43. * port as the port to which ingress and egress monitor frames
  44. * are to be sent.
  45. */
  46. reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
  47. upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
  48. upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
  49. upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
  50. REG_WRITE(REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
  51. /* Disable remote management for now, and set the switch's
  52. * DSA device number.
  53. */
  54. REG_WRITE(REG_GLOBAL, GLOBAL_CONTROL_2, ds->index & 0x1f);
  55. return 0;
  56. }
  57. static int mv88e6171_setup(struct dsa_switch *ds)
  58. {
  59. struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
  60. int ret;
  61. ret = mv88e6xxx_setup_common(ds);
  62. if (ret < 0)
  63. return ret;
  64. ps->num_ports = 7;
  65. ret = mv88e6xxx_switch_reset(ds, true);
  66. if (ret < 0)
  67. return ret;
  68. ret = mv88e6171_setup_global(ds);
  69. if (ret < 0)
  70. return ret;
  71. return mv88e6xxx_setup_ports(ds);
  72. }
  73. struct dsa_switch_driver mv88e6171_switch_driver = {
  74. .tag_protocol = DSA_TAG_PROTO_EDSA,
  75. .priv_size = sizeof(struct mv88e6xxx_priv_state),
  76. .probe = mv88e6171_probe,
  77. .setup = mv88e6171_setup,
  78. .set_addr = mv88e6xxx_set_addr_indirect,
  79. .phy_read = mv88e6xxx_phy_read_indirect,
  80. .phy_write = mv88e6xxx_phy_write_indirect,
  81. .get_strings = mv88e6xxx_get_strings,
  82. .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
  83. .get_sset_count = mv88e6xxx_get_sset_count,
  84. .adjust_link = mv88e6xxx_adjust_link,
  85. #ifdef CONFIG_NET_DSA_HWMON
  86. .get_temp = mv88e6xxx_get_temp,
  87. #endif
  88. .get_regs_len = mv88e6xxx_get_regs_len,
  89. .get_regs = mv88e6xxx_get_regs,
  90. .port_join_bridge = mv88e6xxx_port_bridge_join,
  91. .port_leave_bridge = mv88e6xxx_port_bridge_leave,
  92. .port_stp_update = mv88e6xxx_port_stp_update,
  93. .port_pvid_get = mv88e6xxx_port_pvid_get,
  94. .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
  95. .port_vlan_add = mv88e6xxx_port_vlan_add,
  96. .port_vlan_del = mv88e6xxx_port_vlan_del,
  97. .vlan_getnext = mv88e6xxx_vlan_getnext,
  98. .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
  99. .port_fdb_add = mv88e6xxx_port_fdb_add,
  100. .port_fdb_del = mv88e6xxx_port_fdb_del,
  101. .port_fdb_dump = mv88e6xxx_port_fdb_dump,
  102. };
  103. MODULE_ALIAS("platform:mv88e6171");
  104. MODULE_ALIAS("platform:mv88e6175");
  105. MODULE_ALIAS("platform:mv88e6350");
  106. MODULE_ALIAS("platform:mv88e6351");