bcm63xx.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Driver for Broadcom 63xx SOCs integrated PHYs
  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
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include "bcm-phy-lib.h"
  10. #include <linux/module.h>
  11. #include <linux/phy.h>
  12. #define MII_BCM63XX_IR 0x1a /* interrupt register */
  13. #define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
  14. #define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
  15. #define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
  16. #define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
  17. #define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
  18. MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
  19. MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
  20. MODULE_LICENSE("GPL");
  21. static int bcm63xx_config_init(struct phy_device *phydev)
  22. {
  23. int reg, err;
  24. reg = phy_read(phydev, MII_BCM63XX_IR);
  25. if (reg < 0)
  26. return reg;
  27. /* Mask interrupts globally. */
  28. reg |= MII_BCM63XX_IR_GMASK;
  29. err = phy_write(phydev, MII_BCM63XX_IR, reg);
  30. if (err < 0)
  31. return err;
  32. /* Unmask events we are interested in */
  33. reg = ~(MII_BCM63XX_IR_DUPLEX |
  34. MII_BCM63XX_IR_SPEED |
  35. MII_BCM63XX_IR_LINK) |
  36. MII_BCM63XX_IR_EN;
  37. return phy_write(phydev, MII_BCM63XX_IR, reg);
  38. }
  39. static struct phy_driver bcm63xx_driver[] = {
  40. {
  41. .phy_id = 0x00406000,
  42. .phy_id_mask = 0xfffffc00,
  43. .name = "Broadcom BCM63XX (1)",
  44. /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
  45. .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
  46. .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
  47. .config_init = bcm63xx_config_init,
  48. .config_aneg = genphy_config_aneg,
  49. .read_status = genphy_read_status,
  50. .ack_interrupt = bcm_phy_ack_intr,
  51. .config_intr = bcm_phy_config_intr,
  52. }, {
  53. /* same phy as above, with just a different OUI */
  54. .phy_id = 0x002bdc00,
  55. .phy_id_mask = 0xfffffc00,
  56. .name = "Broadcom BCM63XX (2)",
  57. .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
  58. .flags = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
  59. .config_init = bcm63xx_config_init,
  60. .config_aneg = genphy_config_aneg,
  61. .read_status = genphy_read_status,
  62. .ack_interrupt = bcm_phy_ack_intr,
  63. .config_intr = bcm_phy_config_intr,
  64. } };
  65. module_phy_driver(bcm63xx_driver);
  66. static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
  67. { 0x00406000, 0xfffffc00 },
  68. { 0x002bdc00, 0xfffffc00 },
  69. { }
  70. };
  71. MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);