smsc.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * SMSC PHY drivers
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. *
  19. * Base code from drivers/net/phy/davicom.c
  20. * Copyright 2010-2011 Freescale Semiconductor, Inc.
  21. * author Andy Fleming
  22. *
  23. * Some code get from linux kenrel
  24. * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
  25. *
  26. */
  27. #include <miiphy.h>
  28. static int smsc_parse_status(struct phy_device *phydev)
  29. {
  30. int mii_reg;
  31. mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
  32. if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
  33. phydev->speed = SPEED_100;
  34. else
  35. phydev->speed = SPEED_10;
  36. if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
  37. phydev->duplex = DUPLEX_FULL;
  38. else
  39. phydev->duplex = DUPLEX_HALF;
  40. return 0;
  41. }
  42. static int smsc_startup(struct phy_device *phydev)
  43. {
  44. genphy_update_link(phydev);
  45. smsc_parse_status(phydev);
  46. return 0;
  47. }
  48. static struct phy_driver lan8700_driver = {
  49. .name = "SMSC LAN8700",
  50. .uid = 0x0007c0c0,
  51. .mask = 0xffff0,
  52. .features = PHY_BASIC_FEATURES,
  53. .config = &genphy_config_aneg,
  54. .startup = &smsc_startup,
  55. .shutdown = &genphy_shutdown,
  56. };
  57. static struct phy_driver lan911x_driver = {
  58. .name = "SMSC LAN911x Internal PHY",
  59. .uid = 0x0007c0d0,
  60. .mask = 0xffff0,
  61. .features = PHY_BASIC_FEATURES,
  62. .config = &genphy_config_aneg,
  63. .startup = &smsc_startup,
  64. .shutdown = &genphy_shutdown,
  65. };
  66. static struct phy_driver lan8710_driver = {
  67. .name = "SMSC LAN8710/LAN8720",
  68. .uid = 0x0007c0f0,
  69. .mask = 0xffff0,
  70. .features = PHY_GBIT_FEATURES,
  71. .config = &genphy_config_aneg,
  72. .startup = &smsc_startup,
  73. .shutdown = &genphy_shutdown,
  74. };
  75. int phy_smsc_init(void)
  76. {
  77. phy_register(&lan8710_driver);
  78. phy_register(&lan911x_driver);
  79. phy_register(&lan8700_driver);
  80. return 0;
  81. }