209-b44-register-adm-switch.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From b36f694256f41bc71571f467646d015dda128d14 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <[email protected]>
  3. Date: Sat, 9 Nov 2013 17:03:59 +0100
  4. Subject: [PATCH 210/210] b44: register adm switch
  5. ---
  6. drivers/net/ethernet/broadcom/b44.c | 57 +++++++++++++++++++++++++++++++++++
  7. drivers/net/ethernet/broadcom/b44.h | 3 ++
  8. 2 files changed, 60 insertions(+)
  9. --- a/drivers/net/ethernet/broadcom/b44.c
  10. +++ b/drivers/net/ethernet/broadcom/b44.c
  11. @@ -31,6 +31,8 @@
  12. #include <linux/ssb/ssb.h>
  13. #include <linux/slab.h>
  14. #include <linux/phy.h>
  15. +#include <linux/platform_device.h>
  16. +#include <linux/platform_data/adm6996-gpio.h>
  17. #include <linux/uaccess.h>
  18. #include <asm/io.h>
  19. @@ -2248,6 +2250,69 @@ static void b44_adjust_link(struct net_d
  20. }
  21. }
  22. +#ifdef CONFIG_BCM47XX
  23. +static int b44_register_adm_switch(struct b44 *bp)
  24. +{
  25. + int gpio;
  26. + struct platform_device *pdev;
  27. + struct adm6996_gpio_platform_data adm_data = {0};
  28. + struct platform_device_info info = {0};
  29. +
  30. + adm_data.model = ADM6996L;
  31. + gpio = bcm47xx_nvram_gpio_pin("adm_eecs");
  32. + if (gpio >= 0)
  33. + adm_data.eecs = gpio;
  34. + else
  35. + adm_data.eecs = 2;
  36. +
  37. + gpio = bcm47xx_nvram_gpio_pin("adm_eesk");
  38. + if (gpio >= 0)
  39. + adm_data.eesk = gpio;
  40. + else
  41. + adm_data.eesk = 3;
  42. +
  43. + gpio = bcm47xx_nvram_gpio_pin("adm_eedi");
  44. + if (gpio >= 0)
  45. + adm_data.eedi = gpio;
  46. + else
  47. + adm_data.eedi = 4;
  48. +
  49. + /*
  50. + * We ignore the "adm_rc" GPIO here. The driver does not use it,
  51. + * and it conflicts with the Reset button GPIO on the Linksys WRT54GSv1.
  52. + */
  53. +
  54. + info.parent = bp->sdev->dev;
  55. + info.name = "adm6996_gpio";
  56. + info.id = -1;
  57. + info.data = &adm_data;
  58. + info.size_data = sizeof(adm_data);
  59. +
  60. + if (!bp->adm_switch) {
  61. + pdev = platform_device_register_full(&info);
  62. + if (IS_ERR(pdev))
  63. + return PTR_ERR(pdev);
  64. +
  65. + bp->adm_switch = pdev;
  66. + }
  67. + return 0;
  68. +}
  69. +static void b44_unregister_adm_switch(struct b44 *bp)
  70. +{
  71. + if (bp->adm_switch)
  72. + platform_device_unregister(bp->adm_switch);
  73. +}
  74. +#else
  75. +static int b44_register_adm_switch(struct b44 *bp)
  76. +{
  77. + return 0;
  78. +}
  79. +static void b44_unregister_adm_switch(struct b44 *bp)
  80. +{
  81. +
  82. +}
  83. +#endif /* CONFIG_BCM47XX */
  84. +
  85. static int b44_register_phy_one(struct b44 *bp)
  86. {
  87. struct mii_bus *mii_bus;
  88. @@ -2283,6 +2348,9 @@ static int b44_register_phy_one(struct b
  89. if (!mdiobus_is_registered_device(bp->mii_bus, bp->phy_addr) &&
  90. (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
  91. + if (sprom->boardflags_lo & B44_BOARDFLAG_ADM)
  92. + b44_register_adm_switch(bp);
  93. +
  94. dev_info(sdev->dev,
  95. "could not find PHY at %i, use fixed one\n",
  96. bp->phy_addr);
  97. @@ -2477,6 +2545,7 @@ static void b44_remove_one(struct ssb_de
  98. unregister_netdev(dev);
  99. if (bp->flags & B44_FLAG_EXTERNAL_PHY)
  100. b44_unregister_phy_one(bp);
  101. + b44_unregister_adm_switch(bp);
  102. ssb_device_disable(sdev, 0);
  103. ssb_bus_may_powerdown(sdev->bus);
  104. netif_napi_del(&bp->napi);
  105. --- a/drivers/net/ethernet/broadcom/b44.h
  106. +++ b/drivers/net/ethernet/broadcom/b44.h
  107. @@ -408,6 +408,9 @@ struct b44 {
  108. struct mii_bus *mii_bus;
  109. int old_link;
  110. struct mii_if_info mii_if;
  111. +
  112. + /* platform device for associated switch */
  113. + struct platform_device *adm_switch;
  114. };
  115. #endif /* _B44_H */