032-05-MIPS-BCM47xx-Read-board-info-for-all-bcma-buses.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. From 12e1ab54dcd414c3579cfd26be9d9c9e1cab92ad Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Tue, 12 May 2015 13:05:18 +0200
  4. Subject: [PATCH] MIPS: BCM47xx: Read board info for all bcma buses
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Extra bcma buses may be totally different models, see following dump:
  9. boardtype=0x0646
  10. pci/1/1/boardtype=0x0545
  11. pci/2/1/boardtype=0x62b
  12. We need to detect them properly to allow drivers apply some board
  13. specific hacks.
  14. [ralf@linux-mips.org: folded in Rafal's fix.]
  15. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  16. Cc: linux-mips@linux-mips.org
  17. Cc: Hauke Mehrtens <hauke@hauke-m.de>
  18. Patchwork: https://patchwork.linux-mips.org/patch/10028/
  19. Patchwork: https://patchwork.linux-mips.org/patch/10048/
  20. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  21. ---
  22. arch/mips/bcm47xx/setup.c | 3 --
  23. arch/mips/bcm47xx/sprom.c | 44 ++++++++++++++--------------
  24. arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 4 ---
  25. 3 files changed, 22 insertions(+), 29 deletions(-)
  26. --- a/arch/mips/bcm47xx/setup.c
  27. +++ b/arch/mips/bcm47xx/setup.c
  28. @@ -206,9 +206,6 @@ void __init bcm47xx_bus_setup(void)
  29. err = bcma_host_soc_init(&bcm47xx_bus.bcma);
  30. if (err)
  31. panic("Failed to initialize BCMA bus (err %d)", err);
  32. -
  33. - bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo,
  34. - NULL);
  35. }
  36. #endif
  37. --- a/arch/mips/bcm47xx/sprom.c
  38. +++ b/arch/mips/bcm47xx/sprom.c
  39. @@ -640,19 +640,6 @@ void bcm47xx_fill_ssb_boardinfo(struct s
  40. }
  41. #endif
  42. -#ifdef CONFIG_BCM47XX_BCMA
  43. -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
  44. - const char *prefix)
  45. -{
  46. - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
  47. - true);
  48. - if (!boardinfo->vendor)
  49. - boardinfo->vendor = SSB_BOARDVENDOR_BCM;
  50. -
  51. - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
  52. -}
  53. -#endif
  54. -
  55. #if defined(CONFIG_BCM47XX_SSB)
  56. static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
  57. {
  58. @@ -707,33 +694,46 @@ static void bcm47xx_sprom_apply_prefix_a
  59. static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
  60. {
  61. - char prefix[10];
  62. + struct bcma_boardinfo *binfo = &bus->boardinfo;
  63. struct bcma_device *core;
  64. + char buf[10];
  65. + char *prefix;
  66. + bool fallback = false;
  67. switch (bus->hosttype) {
  68. case BCMA_HOSTTYPE_PCI:
  69. memset(out, 0, sizeof(struct ssb_sprom));
  70. - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
  71. + snprintf(buf, sizeof(buf), "pci/%u/%u/",
  72. bus->host_pci->bus->number + 1,
  73. PCI_SLOT(bus->host_pci->devfn));
  74. - bcm47xx_sprom_apply_prefix_alias(prefix, sizeof(prefix));
  75. - bcm47xx_fill_sprom(out, prefix, false);
  76. - return 0;
  77. + bcm47xx_sprom_apply_prefix_alias(buf, sizeof(buf));
  78. + prefix = buf;
  79. + break;
  80. case BCMA_HOSTTYPE_SOC:
  81. memset(out, 0, sizeof(struct ssb_sprom));
  82. core = bcma_find_core(bus, BCMA_CORE_80211);
  83. if (core) {
  84. - snprintf(prefix, sizeof(prefix), "sb/%u/",
  85. + snprintf(buf, sizeof(buf), "sb/%u/",
  86. core->core_index);
  87. - bcm47xx_fill_sprom(out, prefix, true);
  88. + prefix = buf;
  89. + fallback = true;
  90. } else {
  91. - bcm47xx_fill_sprom(out, NULL, false);
  92. + prefix = NULL;
  93. }
  94. - return 0;
  95. + break;
  96. default:
  97. pr_warn("Unable to fill SPROM for given bustype.\n");
  98. return -EINVAL;
  99. }
  100. +
  101. + nvram_read_u16(prefix, NULL, "boardvendor", &binfo->vendor, 0, true);
  102. + if (!binfo->vendor)
  103. + binfo->vendor = SSB_BOARDVENDOR_BCM;
  104. + nvram_read_u16(prefix, NULL, "boardtype", &binfo->type, 0, true);
  105. +
  106. + bcm47xx_fill_sprom(out, prefix, fallback);
  107. +
  108. + return 0;
  109. }
  110. #endif
  111. --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
  112. +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
  113. @@ -52,10 +52,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom
  114. void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
  115. const char *prefix);
  116. #endif
  117. -#ifdef CONFIG_BCM47XX_BCMA
  118. -void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
  119. - const char *prefix);
  120. -#endif
  121. void bcm47xx_set_system_type(u16 chip_id);