070-v4.6-0001-bgmac-add-helper-checking-for-BCM4707-BCM53018-chip-.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 387b75f8b31437792e8334390fdf5cf060d1e3da Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Tue, 2 Feb 2016 07:47:14 +0100
  4. Subject: [PATCH] bgmac: add helper checking for BCM4707 / BCM53018 chip id
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Chipsets with BCM4707 / BCM53018 ID require special handling at a few
  9. places in the code. It's likely there will be more IDs to check in the
  10. future. To simplify it add this trivial helper.
  11. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  12. Signed-off-by: David S. Miller <davem@davemloft.net>
  13. ---
  14. drivers/net/ethernet/broadcom/bgmac.c | 30 ++++++++++++++++--------------
  15. 1 file changed, 16 insertions(+), 14 deletions(-)
  16. --- a/drivers/net/ethernet/broadcom/bgmac.c
  17. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  18. @@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac
  19. };
  20. MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
  21. +static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
  22. +{
  23. + switch (bgmac->core->bus->chipinfo.id) {
  24. + case BCMA_CHIP_ID_BCM4707:
  25. + case BCMA_CHIP_ID_BCM53018:
  26. + return true;
  27. + default:
  28. + return false;
  29. + }
  30. +}
  31. +
  32. static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
  33. u32 value, int timeout)
  34. {
  35. @@ -991,11 +1002,9 @@ static void bgmac_mac_speed(struct bgmac
  36. static void bgmac_miiconfig(struct bgmac *bgmac)
  37. {
  38. struct bcma_device *core = bgmac->core;
  39. - struct bcma_chipinfo *ci = &core->bus->chipinfo;
  40. u8 imode;
  41. - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
  42. - ci->id == BCMA_CHIP_ID_BCM53018) {
  43. + if (bgmac_is_bcm4707_family(bgmac)) {
  44. bcma_awrite32(core, BCMA_IOCTL,
  45. bcma_aread32(core, BCMA_IOCTL) | 0x40 |
  46. BGMAC_BCMA_IOCTL_SW_CLKEN);
  47. @@ -1059,9 +1068,7 @@ static void bgmac_chip_reset(struct bgma
  48. }
  49. /* Request Misc PLL for corerev > 2 */
  50. - if (core->id.rev > 2 &&
  51. - ci->id != BCMA_CHIP_ID_BCM4707 &&
  52. - ci->id != BCMA_CHIP_ID_BCM53018) {
  53. + if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
  54. bgmac_set(bgmac, BCMA_CLKCTLST,
  55. BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
  56. bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
  57. @@ -1197,8 +1204,7 @@ static void bgmac_enable(struct bgmac *b
  58. break;
  59. }
  60. - if (ci->id != BCMA_CHIP_ID_BCM4707 &&
  61. - ci->id != BCMA_CHIP_ID_BCM53018) {
  62. + if (!bgmac_is_bcm4707_family(bgmac)) {
  63. rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
  64. rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
  65. bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
  66. @@ -1477,14 +1483,12 @@ static int bgmac_fixed_phy_register(stru
  67. static int bgmac_mii_register(struct bgmac *bgmac)
  68. {
  69. - struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
  70. struct mii_bus *mii_bus;
  71. struct phy_device *phy_dev;
  72. char bus_id[MII_BUS_ID_SIZE + 3];
  73. int i, err = 0;
  74. - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
  75. - ci->id == BCMA_CHIP_ID_BCM53018)
  76. + if (bgmac_is_bcm4707_family(bgmac))
  77. return bgmac_fixed_phy_register(bgmac);
  78. mii_bus = mdiobus_alloc();
  79. @@ -1555,7 +1559,6 @@ static void bgmac_mii_unregister(struct
  80. /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
  81. static int bgmac_probe(struct bcma_device *core)
  82. {
  83. - struct bcma_chipinfo *ci = &core->bus->chipinfo;
  84. struct net_device *net_dev;
  85. struct bgmac *bgmac;
  86. struct ssb_sprom *sprom = &core->bus->sprom;
  87. @@ -1641,8 +1644,7 @@ static int bgmac_probe(struct bcma_devic
  88. bgmac_chip_reset(bgmac);
  89. /* For Northstar, we have to take all GMAC core out of reset */
  90. - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
  91. - ci->id == BCMA_CHIP_ID_BCM53018) {
  92. + if (bgmac_is_bcm4707_family(bgmac)) {
  93. struct bcma_device *ns_core;
  94. int ns_gmac;