031-11-MIPS-BCM47xx-Simplify-handling-SPROM-revisions.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 590605c6bc31d5cbfcb3844ef98eb10ff7ce24c3 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Sun, 21 Jun 2015 15:25:49 +0200
  4. Subject: [PATCH] MIPS: BCM47xx: Simplify handling SPROM revisions
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. After the big SPROM cleanup moving code to the bcm47xx_sprom_fill_auto
  9. we ended up with few tiny functions, two of them being identical. Let's
  10. get rid of these [12]-liners.
  11. This also stops extracting higher SPROM revisions as revision 1. Now we
  12. have that function nicely handling revisions we don't need it.
  13. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  14. Cc: linux-mips@linux-mips.org
  15. Cc: Hauke Mehrtens <hauke@hauke-m.de>
  16. Patchwork: https://patchwork.linux-mips.org/patch/10569/
  17. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  18. ---
  19. arch/mips/bcm47xx/sprom.c | 53 ++++++++---------------------------------------
  20. 1 file changed, 9 insertions(+), 44 deletions(-)
  21. --- a/arch/mips/bcm47xx/sprom.c
  22. +++ b/arch/mips/bcm47xx/sprom.c
  23. @@ -200,6 +200,9 @@ static void bcm47xx_sprom_fill_auto(stru
  24. const char *pre = prefix;
  25. bool fb = fallback;
  26. + /* Broadcom extracts it for rev 8+ but it was found on 2 and 4 too */
  27. + ENTRY(0xfffffffe, u16, pre, "devid", dev_id, 0, fallback);
  28. +
  29. ENTRY(0xfffffffe, u16, pre, "boardrev", board_rev, 0, true);
  30. ENTRY(0xfffffffe, u32, pre, "boardflags", boardflags, 0, fb);
  31. ENTRY(0xfffffff0, u32, pre, "boardflags2", boardflags2, 0, fb);
  32. @@ -412,27 +415,6 @@ static void bcm47xx_sprom_fill_auto(stru
  33. }
  34. #undef ENTRY /* It's specififc, uses local variable, don't use it (again). */
  35. -static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
  36. - const char *prefix, bool fallback)
  37. -{
  38. - nvram_read_u16(prefix, NULL, "devid", &sprom->dev_id, 0, fallback);
  39. - nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback);
  40. -}
  41. -
  42. -static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix,
  43. - bool fallback)
  44. -{
  45. - nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
  46. - &sprom->leddc_off_time, fallback);
  47. -}
  48. -
  49. -static void bcm47xx_fill_sprom_r4589(struct ssb_sprom *sprom,
  50. - const char *prefix, bool fallback)
  51. -{
  52. - nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
  53. - &sprom->leddc_off_time, fallback);
  54. -}
  55. -
  56. static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom,
  57. const char *prefix, bool fallback)
  58. {
  59. @@ -589,39 +571,22 @@ void bcm47xx_fill_sprom(struct ssb_sprom
  60. nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0, fallback);
  61. + /* Entries requiring custom functions */
  62. + nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback);
  63. + if (sprom->revision >= 3)
  64. + nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
  65. + &sprom->leddc_off_time, fallback);
  66. +
  67. switch (sprom->revision) {
  68. - case 1:
  69. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  70. - break;
  71. - case 2:
  72. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  73. - break;
  74. - case 3:
  75. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  76. - bcm47xx_fill_sprom_r3(sprom, prefix, fallback);
  77. - break;
  78. case 4:
  79. case 5:
  80. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  81. - bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
  82. bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
  83. bcm47xx_fill_sprom_path_r45(sprom, prefix, fallback);
  84. break;
  85. case 8:
  86. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  87. - bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
  88. - bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
  89. - break;
  90. case 9:
  91. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  92. - bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
  93. bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
  94. break;
  95. - default:
  96. - pr_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
  97. - sprom->revision);
  98. - sprom->revision = 1;
  99. - bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
  100. }
  101. bcm47xx_sprom_fill_auto(sprom, prefix, fallback);