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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From b36f694256f41bc71571f467646d015dda128d14 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  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 <asm/uaccess.h>
  18. #include <asm/io.h>
  19. @@ -2240,6 +2242,70 @@ 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. + gpio = bcm47xx_nvram_gpio_pin("adm_rc");
  50. + if (gpio >= 0)
  51. + adm_data.eerc = gpio;
  52. + else
  53. + adm_data.eerc = 5;
  54. +
  55. + info.parent = bp->sdev->dev;
  56. + info.name = "adm6996_gpio";
  57. + info.id = -1;
  58. + info.data = &adm_data;
  59. + info.size_data = sizeof(adm_data);
  60. +
  61. + if (!bp->adm_switch) {
  62. + pdev = platform_device_register_full(&info);
  63. + if (IS_ERR(pdev))
  64. + return PTR_ERR(pdev);
  65. +
  66. + bp->adm_switch = pdev;
  67. + }
  68. + return 0;
  69. +}
  70. +static void b44_unregister_adm_switch(struct b44 *bp)
  71. +{
  72. + if (bp->adm_switch)
  73. + platform_device_unregister(bp->adm_switch);
  74. +}
  75. +#else
  76. +static int b44_register_adm_switch(struct b44 *bp)
  77. +{
  78. + return 0;
  79. +}
  80. +static void b44_unregister_adm_switch(struct b44 *bp)
  81. +{
  82. +
  83. +}
  84. +#endif /* CONFIG_BCM47XX */
  85. +
  86. static int b44_register_phy_one(struct b44 *bp)
  87. {
  88. struct mii_bus *mii_bus;
  89. @@ -2283,6 +2349,9 @@ static int b44_register_phy_one(struct b
  90. if (!bp->mii_bus->phy_map[bp->phy_addr] &&
  91. (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
  92. + if (sprom->boardflags_lo & B44_BOARDFLAG_ADM)
  93. + b44_register_adm_switch(bp);
  94. +
  95. dev_info(sdev->dev,
  96. "could not find PHY at %i, use fixed one\n",
  97. bp->phy_addr);
  98. @@ -2479,6 +2548,7 @@ static void b44_remove_one(struct ssb_de
  99. unregister_netdev(dev);
  100. if (bp->flags & B44_FLAG_EXTERNAL_PHY)
  101. b44_unregister_phy_one(bp);
  102. + b44_unregister_adm_switch(bp);
  103. ssb_device_disable(sdev, 0);
  104. ssb_bus_may_powerdown(sdev->bus);
  105. netif_napi_del(&bp->napi);
  106. --- a/drivers/net/ethernet/broadcom/b44.h
  107. +++ b/drivers/net/ethernet/broadcom/b44.h
  108. @@ -408,6 +408,9 @@ struct b44 {
  109. struct mii_bus *mii_bus;
  110. int old_link;
  111. struct mii_if_info mii_if;
  112. +
  113. + /* platform device for associated switch */
  114. + struct platform_device *adm_switch;
  115. };
  116. #endif /* _B44_H */