1
0

074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From c25b23b8a387e7d31f7a74af8e37b61e9e6ebb21 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Fri, 20 Mar 2015 23:14:31 +0100
  4. Subject: [PATCH] bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. On ARM SoCs with bgmac Ethernet hardware we don't have any normal PHY.
  9. There is always a switch attached but it's not even controlled over MDIO
  10. like in case of MIPS devices.
  11. We need a fixed PHY to be able to send/receive packets from the switch.
  12. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  13. Signed-off-by: David S. Miller <davem@davemloft.net>
  14. ---
  15. drivers/net/ethernet/broadcom/bgmac.c | 34 ++++++++++++++++++++++++++++++++++
  16. 1 file changed, 34 insertions(+)
  17. --- a/drivers/net/ethernet/broadcom/bgmac.c
  18. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  19. @@ -14,6 +14,7 @@
  20. #include <linux/etherdevice.h>
  21. #include <linux/mii.h>
  22. #include <linux/phy.h>
  23. +#include <linux/phy_fixed.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/dma-mapping.h>
  26. #include <bcm47xx_nvram.h>
  27. @@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net
  28. }
  29. }
  30. +static int bgmac_fixed_phy_register(struct bgmac *bgmac)
  31. +{
  32. + struct fixed_phy_status fphy_status = {
  33. + .link = 1,
  34. + .speed = SPEED_1000,
  35. + .duplex = DUPLEX_FULL,
  36. + };
  37. + struct phy_device *phy_dev;
  38. + int err;
  39. +
  40. + phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
  41. + if (!phy_dev || IS_ERR(phy_dev)) {
  42. + bgmac_err(bgmac, "Failed to register fixed PHY device\n");
  43. + return -ENODEV;
  44. + }
  45. +
  46. + err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
  47. + PHY_INTERFACE_MODE_MII);
  48. + if (err) {
  49. + bgmac_err(bgmac, "Connecting PHY failed\n");
  50. + return err;
  51. + }
  52. +
  53. + bgmac->phy_dev = phy_dev;
  54. +
  55. + return err;
  56. +}
  57. +
  58. static int bgmac_mii_register(struct bgmac *bgmac)
  59. {
  60. + struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
  61. struct mii_bus *mii_bus;
  62. struct phy_device *phy_dev;
  63. char bus_id[MII_BUS_ID_SIZE + 3];
  64. int i, err = 0;
  65. + if (ci->id == BCMA_CHIP_ID_BCM4707 ||
  66. + ci->id == BCMA_CHIP_ID_BCM53018)
  67. + return bgmac_fixed_phy_register(bgmac);
  68. +
  69. mii_bus = mdiobus_alloc();
  70. if (!mii_bus)
  71. return -ENOMEM;