realtek.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * drivers/net/phy/realtek.c
  3. *
  4. * Driver for Realtek PHYs
  5. *
  6. * Author: Johnson Leung <r58129@freescale.com>
  7. *
  8. * Copyright (c) 2004 Freescale Semiconductor, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. */
  16. #include <linux/phy.h>
  17. #define RTL821x_PHYSR 0x11
  18. #define RTL821x_PHYSR_DUPLEX 0x2000
  19. #define RTL821x_PHYSR_SPEED 0xc000
  20. #define RTL821x_INER 0x12
  21. #define RTL821x_INER_INIT 0x6400
  22. #define RTL821x_INSR 0x13
  23. MODULE_DESCRIPTION("Realtek PHY driver");
  24. MODULE_AUTHOR("Johnson Leung");
  25. MODULE_LICENSE("GPL");
  26. static int rtl821x_ack_interrupt(struct phy_device *phydev)
  27. {
  28. int err;
  29. err = phy_read(phydev, RTL821x_INSR);
  30. return (err < 0) ? err : 0;
  31. }
  32. static int rtl821x_config_intr(struct phy_device *phydev)
  33. {
  34. int err;
  35. if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
  36. err = phy_write(phydev, RTL821x_INER,
  37. RTL821x_INER_INIT);
  38. else
  39. err = phy_write(phydev, RTL821x_INER, 0);
  40. return err;
  41. }
  42. /* RTL8211B */
  43. static struct phy_driver rtl821x_driver = {
  44. .phy_id = 0x001cc912,
  45. .name = "RTL821x Gigabit Ethernet",
  46. .phy_id_mask = 0x001fffff,
  47. .features = PHY_GBIT_FEATURES,
  48. .flags = PHY_HAS_INTERRUPT,
  49. .config_aneg = &genphy_config_aneg,
  50. .read_status = &genphy_read_status,
  51. .ack_interrupt = &rtl821x_ack_interrupt,
  52. .config_intr = &rtl821x_config_intr,
  53. .driver = { .owner = THIS_MODULE,},
  54. };
  55. static int __init realtek_init(void)
  56. {
  57. int ret;
  58. ret = phy_driver_register(&rtl821x_driver);
  59. return ret;
  60. }
  61. static void __exit realtek_exit(void)
  62. {
  63. phy_driver_unregister(&rtl821x_driver);
  64. }
  65. module_init(realtek_init);
  66. module_exit(realtek_exit);