773-bgmac-add-srab-switch.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From 3cb240533ab787899dc7f17aa7d6c5b4810e2e58 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Fri, 7 Jul 2017 17:26:01 +0200
  4. Subject: bcm53xx: bgmac: use srab switch driver
  5. use the srab switch driver on these SoCs.
  6. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  7. ---
  8. drivers/net/ethernet/broadcom/bgmac-bcma.c | 1 +
  9. drivers/net/ethernet/broadcom/bgmac.c | 24 ++++++++++++++++++++++++
  10. drivers/net/ethernet/broadcom/bgmac.h | 4 ++++
  11. 3 files changed, 29 insertions(+)
  12. --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
  13. +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
  14. @@ -268,6 +268,7 @@ static int bgmac_probe(struct bcma_devic
  15. bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
  16. bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
  17. bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
  18. + bgmac->feature_flags |= BGMAC_FEAT_SRAB;
  19. break;
  20. default:
  21. bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
  22. --- a/drivers/net/ethernet/broadcom/bgmac.c
  23. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  24. @@ -12,6 +12,7 @@
  25. #include <linux/bcma/bcma.h>
  26. #include <linux/etherdevice.h>
  27. #include <linux/interrupt.h>
  28. +#include <linux/platform_data/b53.h>
  29. #include <linux/bcm47xx_nvram.h>
  30. #include <linux/phy.h>
  31. #include <linux/phy_fixed.h>
  32. @@ -1410,6 +1411,17 @@ static const struct ethtool_ops bgmac_et
  33. .set_link_ksettings = phy_ethtool_set_link_ksettings,
  34. };
  35. +static struct b53_platform_data bgmac_b53_pdata = {
  36. +};
  37. +
  38. +static struct platform_device bgmac_b53_dev = {
  39. + .name = "b53-srab-switch",
  40. + .id = -1,
  41. + .dev = {
  42. + .platform_data = &bgmac_b53_pdata,
  43. + },
  44. +};
  45. +
  46. /**************************************************
  47. * MII
  48. **************************************************/
  49. @@ -1539,6 +1551,14 @@ int bgmac_enet_probe(struct bgmac *bgmac
  50. net_dev->hw_features = net_dev->features;
  51. net_dev->vlan_features = net_dev->features;
  52. + if ((bgmac->feature_flags & BGMAC_FEAT_SRAB) && !bgmac_b53_pdata.regs) {
  53. + bgmac_b53_pdata.regs = ioremap_nocache(0x18007000, 0x1000);
  54. +
  55. + err = platform_device_register(&bgmac_b53_dev);
  56. + if (!err)
  57. + bgmac->b53_device = &bgmac_b53_dev;
  58. + }
  59. +
  60. err = register_netdev(bgmac->net_dev);
  61. if (err) {
  62. dev_err(bgmac->dev, "Cannot register net device\n");
  63. @@ -1561,6 +1581,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
  64. void bgmac_enet_remove(struct bgmac *bgmac)
  65. {
  66. + if (bgmac->b53_device)
  67. + platform_device_unregister(&bgmac_b53_dev);
  68. + bgmac->b53_device = NULL;
  69. +
  70. unregister_netdev(bgmac->net_dev);
  71. phy_disconnect(bgmac->net_dev->phydev);
  72. netif_napi_del(&bgmac->napi);
  73. --- a/drivers/net/ethernet/broadcom/bgmac.h
  74. +++ b/drivers/net/ethernet/broadcom/bgmac.h
  75. @@ -427,6 +427,7 @@
  76. #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
  77. #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
  78. #define BGMAC_FEAT_IDM_MASK BIT(20)
  79. +#define BGMAC_FEAT_SRAB BIT(21)
  80. struct bgmac_slot_info {
  81. union {
  82. @@ -532,6 +533,9 @@ struct bgmac {
  83. void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask,
  84. u32 set);
  85. int (*phy_connect)(struct bgmac *bgmac);
  86. +
  87. + /* platform device for associated switch */
  88. + struct platform_device *b53_device;
  89. };
  90. struct bgmac *bgmac_alloc(struct device *dev);