071-v5.12-0001-net-dsa-bcm_sf2-support-BCM4908-s-integrated-switch.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. From 73b7a6047971aa6ce4a70fc4901964d14f077171 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  3. Date: Wed, 6 Jan 2021 22:32:02 +0100
  4. Subject: [PATCH] net: dsa: bcm_sf2: support BCM4908's integrated switch
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. BCM4908 family SoCs come with integrated Starfighter 2 switch. Its
  9. registers layout it a mix of BCM7278 and BCM7445. It has 5 integrated
  10. PHYs and 8 ports. It also supports RGMII and SerDes.
  11. Signed-off-by: Rafał Miłecki <[email protected]>
  12. Acked-by: Florian Fainelli <[email protected]>
  13. Link: https://lore.kernel.org/r/[email protected]
  14. Signed-off-by: Jakub Kicinski <[email protected]>
  15. ---
  16. drivers/net/dsa/b53/b53_common.c | 14 +++++++++++++
  17. drivers/net/dsa/b53/b53_priv.h | 1 +
  18. drivers/net/dsa/bcm_sf2.c | 36 +++++++++++++++++++++++++++++---
  19. drivers/net/dsa/bcm_sf2_regs.h | 1 +
  20. 4 files changed, 49 insertions(+), 3 deletions(-)
  21. --- a/drivers/net/dsa/b53/b53_common.c
  22. +++ b/drivers/net/dsa/b53/b53_common.c
  23. @@ -2278,6 +2278,22 @@ static const struct b53_chip_data b53_sw
  24. .jumbo_pm_reg = B53_JUMBO_PORT_MASK,
  25. .jumbo_size_reg = B53_JUMBO_MAX_SIZE,
  26. },
  27. + /* Starfighter 2 */
  28. + {
  29. + .chip_id = BCM4908_DEVICE_ID,
  30. + .dev_name = "BCM4908",
  31. + .vlans = 4096,
  32. + .enabled_ports = 0x1bf,
  33. +#if 0
  34. + .arl_bins = 4,
  35. + .arl_buckets = 256,
  36. +#endif
  37. + .cpu_port = 8, /* TODO: ports 4, 5, 8 */
  38. + .vta_regs = B53_VTA_REGS,
  39. + .duplex_reg = B53_DUPLEX_STAT_GE,
  40. + .jumbo_pm_reg = B53_JUMBO_PORT_MASK,
  41. + .jumbo_size_reg = B53_JUMBO_MAX_SIZE,
  42. + },
  43. {
  44. .chip_id = BCM7445_DEVICE_ID,
  45. .dev_name = "BCM7445",
  46. --- a/drivers/net/dsa/b53/b53_priv.h
  47. +++ b/drivers/net/dsa/b53/b53_priv.h
  48. @@ -64,6 +64,7 @@ struct b53_io_ops {
  49. #define B53_INVALID_LANE 0xff
  50. enum {
  51. + BCM4908_DEVICE_ID = 0x4908,
  52. BCM5325_DEVICE_ID = 0x25,
  53. BCM5365_DEVICE_ID = 0x65,
  54. BCM5389_DEVICE_ID = 0x89,
  55. --- a/drivers/net/dsa/bcm_sf2.c
  56. +++ b/drivers/net/dsa/bcm_sf2.c
  57. @@ -61,7 +61,8 @@ static void bcm_sf2_imp_setup(struct dsa
  58. b53_brcm_hdr_setup(ds, port);
  59. if (port == 8) {
  60. - if (priv->type == BCM7445_DEVICE_ID)
  61. + if (priv->type == BCM4908_DEVICE_ID ||
  62. + priv->type == BCM7445_DEVICE_ID)
  63. offset = CORE_STS_OVERRIDE_IMP;
  64. else
  65. offset = CORE_STS_OVERRIDE_IMP2;
  66. @@ -541,7 +542,8 @@ static void bcm_sf2_sw_mac_config(struct
  67. if (port == core_readl(priv, CORE_IMP0_PRT_ID))
  68. return;
  69. - if (priv->type == BCM7445_DEVICE_ID)
  70. + if (priv->type == BCM4908_DEVICE_ID ||
  71. + priv->type == BCM7445_DEVICE_ID)
  72. offset = CORE_STS_OVERRIDE_GMIIP_PORT(port);
  73. else
  74. offset = CORE_STS_OVERRIDE_GMIIP2_PORT(port);
  75. @@ -983,6 +985,30 @@ struct bcm_sf2_of_data {
  76. unsigned int num_cfp_rules;
  77. };
  78. +static const u16 bcm_sf2_4908_reg_offsets[] = {
  79. + [REG_SWITCH_CNTRL] = 0x00,
  80. + [REG_SWITCH_STATUS] = 0x04,
  81. + [REG_DIR_DATA_WRITE] = 0x08,
  82. + [REG_DIR_DATA_READ] = 0x0c,
  83. + [REG_SWITCH_REVISION] = 0x10,
  84. + [REG_PHY_REVISION] = 0x14,
  85. + [REG_SPHY_CNTRL] = 0x24,
  86. + [REG_CROSSBAR] = 0xc8,
  87. + [REG_RGMII_0_CNTRL] = 0xe0,
  88. + [REG_RGMII_1_CNTRL] = 0xec,
  89. + [REG_RGMII_2_CNTRL] = 0xf8,
  90. + [REG_LED_0_CNTRL] = 0x40,
  91. + [REG_LED_1_CNTRL] = 0x4c,
  92. + [REG_LED_2_CNTRL] = 0x58,
  93. +};
  94. +
  95. +static const struct bcm_sf2_of_data bcm_sf2_4908_data = {
  96. + .type = BCM4908_DEVICE_ID,
  97. + .core_reg_align = 0,
  98. + .reg_offsets = bcm_sf2_4908_reg_offsets,
  99. + .num_cfp_rules = 0, /* FIXME */
  100. +};
  101. +
  102. /* Register offsets for the SWITCH_REG_* block */
  103. static const u16 bcm_sf2_7445_reg_offsets[] = {
  104. [REG_SWITCH_CNTRL] = 0x00,
  105. @@ -1031,6 +1057,9 @@ static const struct bcm_sf2_of_data bcm_
  106. };
  107. static const struct of_device_id bcm_sf2_of_match[] = {
  108. + { .compatible = "brcm,bcm4908-switch",
  109. + .data = &bcm_sf2_4908_data
  110. + },
  111. { .compatible = "brcm,bcm7445-switch-v4.0",
  112. .data = &bcm_sf2_7445_data
  113. },
  114. --- a/drivers/net/dsa/bcm_sf2_regs.h
  115. +++ b/drivers/net/dsa/bcm_sf2_regs.h
  116. @@ -17,6 +17,7 @@ enum bcm_sf2_reg_offs {
  117. REG_SWITCH_REVISION,
  118. REG_PHY_REVISION,
  119. REG_SPHY_CNTRL,
  120. + REG_CROSSBAR,
  121. REG_RGMII_0_CNTRL,
  122. REG_RGMII_1_CNTRL,
  123. REG_RGMII_2_CNTRL,