mv88e6123.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * net/dsa/mv88e6123_61_65.c - Marvell 88e6123/6161/6165 switch chip support
  3. * Copyright (c) 2008-2009 Marvell Semiconductor
  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 mv88e6123_table[] = {
  19. { PORT_SWITCH_ID_6123, "Marvell 88E6123" },
  20. { PORT_SWITCH_ID_6123_A1, "Marvell 88E6123 (A1)" },
  21. { PORT_SWITCH_ID_6123_A2, "Marvell 88E6123 (A2)" },
  22. { PORT_SWITCH_ID_6161, "Marvell 88E6161" },
  23. { PORT_SWITCH_ID_6161_A1, "Marvell 88E6161 (A1)" },
  24. { PORT_SWITCH_ID_6161_A2, "Marvell 88E6161 (A2)" },
  25. { PORT_SWITCH_ID_6165, "Marvell 88E6165" },
  26. { PORT_SWITCH_ID_6165_A1, "Marvell 88E6165 (A1)" },
  27. { PORT_SWITCH_ID_6165_A2, "Marvell 88e6165 (A2)" },
  28. };
  29. static char *mv88e6123_probe(struct device *dsa_dev, struct device *host_dev,
  30. int sw_addr, void **priv)
  31. {
  32. return mv88e6xxx_drv_probe(dsa_dev, host_dev, sw_addr, priv,
  33. mv88e6123_table,
  34. ARRAY_SIZE(mv88e6123_table));
  35. }
  36. static int mv88e6123_setup_global(struct dsa_switch *ds)
  37. {
  38. u32 upstream_port = dsa_upstream_port(ds);
  39. int ret;
  40. u32 reg;
  41. ret = mv88e6xxx_setup_global(ds);
  42. if (ret)
  43. return ret;
  44. /* Disable the PHY polling unit (since there won't be any
  45. * external PHYs to poll), don't discard packets with
  46. * excessive collisions, and mask all interrupt sources.
  47. */
  48. REG_WRITE(REG_GLOBAL, GLOBAL_CONTROL, 0x0000);
  49. /* Configure the upstream port, and configure the upstream
  50. * port as the port to which ingress and egress monitor frames
  51. * are to be sent.
  52. */
  53. reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
  54. upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
  55. upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT;
  56. REG_WRITE(REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
  57. /* Disable remote management for now, and set the switch's
  58. * DSA device number.
  59. */
  60. REG_WRITE(REG_GLOBAL, GLOBAL_CONTROL_2, ds->index & 0x1f);
  61. return 0;
  62. }
  63. static int mv88e6123_setup(struct dsa_switch *ds)
  64. {
  65. struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
  66. int ret;
  67. ps->ds = ds;
  68. ret = mv88e6xxx_setup_common(ds);
  69. if (ret < 0)
  70. return ret;
  71. switch (ps->id) {
  72. case PORT_SWITCH_ID_6123:
  73. ps->num_ports = 3;
  74. break;
  75. case PORT_SWITCH_ID_6161:
  76. case PORT_SWITCH_ID_6165:
  77. ps->num_ports = 6;
  78. break;
  79. default:
  80. return -ENODEV;
  81. }
  82. ret = mv88e6xxx_switch_reset(ds, false);
  83. if (ret < 0)
  84. return ret;
  85. ret = mv88e6123_setup_global(ds);
  86. if (ret < 0)
  87. return ret;
  88. return mv88e6xxx_setup_ports(ds);
  89. }
  90. struct dsa_switch_driver mv88e6123_switch_driver = {
  91. .tag_protocol = DSA_TAG_PROTO_EDSA,
  92. .probe = mv88e6123_probe,
  93. .setup = mv88e6123_setup,
  94. .set_addr = mv88e6xxx_set_addr_indirect,
  95. .phy_read = mv88e6xxx_phy_read,
  96. .phy_write = mv88e6xxx_phy_write,
  97. .get_strings = mv88e6xxx_get_strings,
  98. .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
  99. .get_sset_count = mv88e6xxx_get_sset_count,
  100. .adjust_link = mv88e6xxx_adjust_link,
  101. #ifdef CONFIG_NET_DSA_HWMON
  102. .get_temp = mv88e6xxx_get_temp,
  103. #endif
  104. .get_regs_len = mv88e6xxx_get_regs_len,
  105. .get_regs = mv88e6xxx_get_regs,
  106. };
  107. MODULE_ALIAS("platform:mv88e6123");
  108. MODULE_ALIAS("platform:mv88e6161");
  109. MODULE_ALIAS("platform:mv88e6165");