2
0

071-v4.9-0001-net-bgmac-support-Ethernet-core-on-BCM53573-SoCs.patch 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. From 1cb94db3d1bfe0075bde78fb2989f17e0a8a3936 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Wed, 17 Aug 2016 23:00:30 +0200
  4. Subject: [PATCH] net: bgmac: support Ethernet core on BCM53573 SoCs
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. BCM53573 is a new series of Broadcom's SoCs. It's based on ARM and can
  9. be found in two packages (versions): BCM53573 and BCM47189. It shares
  10. some code with the Northstar family, but also requires some new quirks.
  11. First of all there can be up to 2 Ethernet cores on this SoC. If that is
  12. the case, they are connected to two different switch ports allowing some
  13. more complex/optimized setups. It seems the second unit doesn't come
  14. fully configured and requires some IRQ quirk.
  15. Other than that only the first core is connected to the PHY. For the
  16. second one we have to register fixed PHY (similarly to the Northstar),
  17. otherwise generic PHY driver would get some invalid info.
  18. This has been successfully tested on Tenda AC9 (BCM47189B0).
  19. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  20. Signed-off-by: David S. Miller <davem@davemloft.net>
  21. ---
  22. drivers/net/ethernet/broadcom/bgmac-bcma.c | 19 ++++++++++++++++++-
  23. drivers/net/ethernet/broadcom/bgmac.c | 25 +++++++++++++++++++++++++
  24. drivers/net/ethernet/broadcom/bgmac.h | 19 +++++++++++++++++++
  25. include/linux/bcma/bcma.h | 3 +++
  26. include/linux/bcma/bcma_regs.h | 1 +
  27. 5 files changed, 66 insertions(+), 1 deletion(-)
  28. --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
  29. +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
  30. @@ -92,6 +92,7 @@ MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl
  31. /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
  32. static int bgmac_probe(struct bcma_device *core)
  33. {
  34. + struct bcma_chipinfo *ci = &core->bus->chipinfo;
  35. struct ssb_sprom *sprom = &core->bus->sprom;
  36. struct mii_bus *mii_bus;
  37. struct bgmac *bgmac;
  38. @@ -157,7 +158,8 @@ static int bgmac_probe(struct bcma_devic
  39. dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
  40. bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
  41. - if (!bgmac_is_bcm4707_family(core)) {
  42. + if (!bgmac_is_bcm4707_family(core) &&
  43. + !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) {
  44. mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
  45. if (IS_ERR(mii_bus)) {
  46. err = PTR_ERR(mii_bus);
  47. @@ -230,6 +232,21 @@ static int bgmac_probe(struct bcma_devic
  48. bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
  49. bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
  50. break;
  51. + case BCMA_CHIP_ID_BCM53573:
  52. + bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
  53. + bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
  54. + if (ci->pkg == BCMA_PKG_ID_BCM47189)
  55. + bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
  56. + if (core->core_unit == 0) {
  57. + bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
  58. + if (ci->pkg == BCMA_PKG_ID_BCM47189)
  59. + bgmac->feature_flags |=
  60. + BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
  61. + } else if (core->core_unit == 1) {
  62. + bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
  63. + bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
  64. + }
  65. + break;
  66. default:
  67. bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
  68. bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
  69. --- a/drivers/net/ethernet/broadcom/bgmac.c
  70. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  71. @@ -943,6 +943,27 @@ static void bgmac_chip_reset(struct bgma
  72. bgmac_cco_ctl_maskset(bgmac, 1, ~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
  73. BGMAC_CHIPCTL_1_SW_TYPE_MASK),
  74. sw_type);
  75. + } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE) {
  76. + u32 sw_type = BGMAC_CHIPCTL_4_IF_TYPE_MII |
  77. + BGMAC_CHIPCTL_4_SW_TYPE_EPHY;
  78. + u8 et_swtype = 0;
  79. + char buf[4];
  80. +
  81. + if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
  82. + if (kstrtou8(buf, 0, &et_swtype))
  83. + dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
  84. + buf);
  85. + sw_type = (et_swtype & 0x0f) << 12;
  86. + } else if (bgmac->feature_flags & BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII) {
  87. + sw_type = BGMAC_CHIPCTL_4_IF_TYPE_RGMII |
  88. + BGMAC_CHIPCTL_4_SW_TYPE_RGMII;
  89. + }
  90. + bgmac_cco_ctl_maskset(bgmac, 4, ~(BGMAC_CHIPCTL_4_IF_TYPE_MASK |
  91. + BGMAC_CHIPCTL_4_SW_TYPE_MASK),
  92. + sw_type);
  93. + } else if (bgmac->feature_flags & BGMAC_FEAT_CC7_IF_TYPE_RGMII) {
  94. + bgmac_cco_ctl_maskset(bgmac, 7, ~BGMAC_CHIPCTL_7_IF_TYPE_MASK,
  95. + BGMAC_CHIPCTL_7_IF_TYPE_RGMII);
  96. }
  97. if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw)
  98. @@ -1486,6 +1507,10 @@ int bgmac_enet_probe(struct bgmac *info)
  99. */
  100. bgmac_clk_enable(bgmac, 0);
  101. + /* This seems to be fixing IRQ by assigning OOB #6 to the core */
  102. + if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6)
  103. + bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86);
  104. +
  105. bgmac_chip_reset(bgmac);
  106. err = bgmac_dma_alloc(bgmac);
  107. --- a/drivers/net/ethernet/broadcom/bgmac.h
  108. +++ b/drivers/net/ethernet/broadcom/bgmac.h
  109. @@ -369,6 +369,21 @@
  110. #define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
  111. #define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000
  112. +#define BGMAC_CHIPCTL_4_IF_TYPE_MASK 0x00003000
  113. +#define BGMAC_CHIPCTL_4_IF_TYPE_RMII 0x00000000
  114. +#define BGMAC_CHIPCTL_4_IF_TYPE_MII 0x00001000
  115. +#define BGMAC_CHIPCTL_4_IF_TYPE_RGMII 0x00002000
  116. +#define BGMAC_CHIPCTL_4_SW_TYPE_MASK 0x0000C000
  117. +#define BGMAC_CHIPCTL_4_SW_TYPE_EPHY 0x00000000
  118. +#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYMII 0x00004000
  119. +#define BGMAC_CHIPCTL_4_SW_TYPE_EPHYRMII 0x00008000
  120. +#define BGMAC_CHIPCTL_4_SW_TYPE_RGMII 0x0000C000
  121. +
  122. +#define BGMAC_CHIPCTL_7_IF_TYPE_MASK 0x000000C0
  123. +#define BGMAC_CHIPCTL_7_IF_TYPE_RMII 0x00000000
  124. +#define BGMAC_CHIPCTL_7_IF_TYPE_MII 0x00000040
  125. +#define BGMAC_CHIPCTL_7_IF_TYPE_RGMII 0x00000080
  126. +
  127. #define BGMAC_WEIGHT 64
  128. #define ETHER_MAX_LEN 1518
  129. @@ -390,6 +405,10 @@
  130. #define BGMAC_FEAT_NO_CLR_MIB BIT(13)
  131. #define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14)
  132. #define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15)
  133. +#define BGMAC_FEAT_IRQ_ID_OOB_6 BIT(16)
  134. +#define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17)
  135. +#define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18)
  136. +#define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19)
  137. struct bgmac_slot_info {
  138. union {
  139. --- a/include/linux/bcma/bcma_regs.h
  140. +++ b/include/linux/bcma/bcma_regs.h
  141. @@ -23,6 +23,7 @@
  142. #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
  143. /* Agent registers (common for every core) */
  144. +#define BCMA_OOB_SEL_OUT_A30 0x0100
  145. #define BCMA_IOCTL 0x0408 /* IO control */
  146. #define BCMA_IOCTL_CLK 0x0001
  147. #define BCMA_IOCTL_FGC 0x0002