mv88e6123.c 3.4 KB

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