030-04-MIPS-BCM47XX-Move-SPROM-fallback-code-into-sprom.c.patch 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. From a59da8fb3b2a1f2df5f871464e43cd5b6ca6ceb1 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Tue, 28 Oct 2014 12:52:02 +0100
  4. Subject: [PATCH 157/158] MIPS: BCM47XX: Move SPROM fallback code into sprom.c
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This is some general cleanup as well as preparing sprom.c to become a
  9. standalone driver. We will need this for bcm53xx ARM arch support.
  10. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  11. Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
  12. Cc: linux-mips@linux-mips.org
  13. Patchwork: https://patchwork.linux-mips.org/patch/8232/
  14. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  15. ---
  16. arch/mips/bcm47xx/bcm47xx_private.h | 3 ++
  17. arch/mips/bcm47xx/setup.c | 58 ++-----------------------------
  18. arch/mips/bcm47xx/sprom.c | 68 +++++++++++++++++++++++++++++++++++++
  19. 3 files changed, 73 insertions(+), 56 deletions(-)
  20. --- a/arch/mips/bcm47xx/bcm47xx_private.h
  21. +++ b/arch/mips/bcm47xx/bcm47xx_private.h
  22. @@ -6,6 +6,9 @@
  23. /* prom.c */
  24. void __init bcm47xx_prom_highmem_init(void);
  25. +/* sprom.c */
  26. +void bcm47xx_sprom_register_fallbacks(void);
  27. +
  28. /* buttons.c */
  29. int __init bcm47xx_buttons_register(void);
  30. --- a/arch/mips/bcm47xx/setup.c
  31. +++ b/arch/mips/bcm47xx/setup.c
  32. @@ -102,23 +102,6 @@ static void bcm47xx_machine_halt(void)
  33. }
  34. #ifdef CONFIG_BCM47XX_SSB
  35. -static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
  36. -{
  37. - char prefix[10];
  38. -
  39. - if (bus->bustype == SSB_BUSTYPE_PCI) {
  40. - memset(out, 0, sizeof(struct ssb_sprom));
  41. - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
  42. - bus->host_pci->bus->number + 1,
  43. - PCI_SLOT(bus->host_pci->devfn));
  44. - bcm47xx_fill_sprom(out, prefix, false);
  45. - return 0;
  46. - } else {
  47. - printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
  48. - return -EINVAL;
  49. - }
  50. -}
  51. -
  52. static int bcm47xx_get_invariants(struct ssb_bus *bus,
  53. struct ssb_init_invariants *iv)
  54. {
  55. @@ -144,11 +127,6 @@ static void __init bcm47xx_register_ssb(
  56. char buf[100];
  57. struct ssb_mipscore *mcore;
  58. - err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
  59. - if (err)
  60. - printk(KERN_WARNING "bcm47xx: someone else already registered"
  61. - " a ssb SPROM callback handler (err %d)\n", err);
  62. -
  63. err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
  64. bcm47xx_get_invariants);
  65. if (err)
  66. @@ -171,44 +149,10 @@ static void __init bcm47xx_register_ssb(
  67. #endif
  68. #ifdef CONFIG_BCM47XX_BCMA
  69. -static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
  70. -{
  71. - char prefix[10];
  72. - struct bcma_device *core;
  73. -
  74. - switch (bus->hosttype) {
  75. - case BCMA_HOSTTYPE_PCI:
  76. - memset(out, 0, sizeof(struct ssb_sprom));
  77. - snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
  78. - bus->host_pci->bus->number + 1,
  79. - PCI_SLOT(bus->host_pci->devfn));
  80. - bcm47xx_fill_sprom(out, prefix, false);
  81. - return 0;
  82. - case BCMA_HOSTTYPE_SOC:
  83. - memset(out, 0, sizeof(struct ssb_sprom));
  84. - core = bcma_find_core(bus, BCMA_CORE_80211);
  85. - if (core) {
  86. - snprintf(prefix, sizeof(prefix), "sb/%u/",
  87. - core->core_index);
  88. - bcm47xx_fill_sprom(out, prefix, true);
  89. - } else {
  90. - bcm47xx_fill_sprom(out, NULL, false);
  91. - }
  92. - return 0;
  93. - default:
  94. - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
  95. - return -EINVAL;
  96. - }
  97. -}
  98. -
  99. static void __init bcm47xx_register_bcma(void)
  100. {
  101. int err;
  102. - err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma);
  103. - if (err)
  104. - pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err);
  105. -
  106. err = bcma_host_soc_register(&bcm47xx_bus.bcma);
  107. if (err)
  108. panic("Failed to register BCMA bus (err %d)", err);
  109. @@ -229,6 +173,7 @@ void __init plat_mem_setup(void)
  110. printk(KERN_INFO "bcm47xx: using bcma bus\n");
  111. #ifdef CONFIG_BCM47XX_BCMA
  112. bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
  113. + bcm47xx_sprom_register_fallbacks();
  114. bcm47xx_register_bcma();
  115. bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id);
  116. #ifdef CONFIG_HIGHMEM
  117. @@ -239,6 +184,7 @@ void __init plat_mem_setup(void)
  118. printk(KERN_INFO "bcm47xx: using ssb bus\n");
  119. #ifdef CONFIG_BCM47XX_SSB
  120. bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
  121. + bcm47xx_sprom_register_fallbacks();
  122. bcm47xx_register_ssb();
  123. bcm47xx_set_system_type(bcm47xx_bus.ssb.chip_id);
  124. #endif
  125. --- a/arch/mips/bcm47xx/sprom.c
  126. +++ b/arch/mips/bcm47xx/sprom.c
  127. @@ -801,3 +801,71 @@ void bcm47xx_fill_bcma_boardinfo(struct
  128. nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
  129. }
  130. #endif
  131. +
  132. +#if defined(CONFIG_BCM47XX_SSB)
  133. +static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
  134. +{
  135. + char prefix[10];
  136. +
  137. + if (bus->bustype == SSB_BUSTYPE_PCI) {
  138. + memset(out, 0, sizeof(struct ssb_sprom));
  139. + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
  140. + bus->host_pci->bus->number + 1,
  141. + PCI_SLOT(bus->host_pci->devfn));
  142. + bcm47xx_fill_sprom(out, prefix, false);
  143. + return 0;
  144. + } else {
  145. + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
  146. + return -EINVAL;
  147. + }
  148. +}
  149. +#endif
  150. +
  151. +#if defined(CONFIG_BCM47XX_BCMA)
  152. +static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
  153. +{
  154. + char prefix[10];
  155. + struct bcma_device *core;
  156. +
  157. + switch (bus->hosttype) {
  158. + case BCMA_HOSTTYPE_PCI:
  159. + memset(out, 0, sizeof(struct ssb_sprom));
  160. + snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
  161. + bus->host_pci->bus->number + 1,
  162. + PCI_SLOT(bus->host_pci->devfn));
  163. + bcm47xx_fill_sprom(out, prefix, false);
  164. + return 0;
  165. + case BCMA_HOSTTYPE_SOC:
  166. + memset(out, 0, sizeof(struct ssb_sprom));
  167. + core = bcma_find_core(bus, BCMA_CORE_80211);
  168. + if (core) {
  169. + snprintf(prefix, sizeof(prefix), "sb/%u/",
  170. + core->core_index);
  171. + bcm47xx_fill_sprom(out, prefix, true);
  172. + } else {
  173. + bcm47xx_fill_sprom(out, NULL, false);
  174. + }
  175. + return 0;
  176. + default:
  177. + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
  178. + return -EINVAL;
  179. + }
  180. +}
  181. +#endif
  182. +
  183. +/*
  184. + * On bcm47xx we need to register SPROM fallback handler very early, so we can't
  185. + * use anything like platform device / driver for this.
  186. + */
  187. +void bcm47xx_sprom_register_fallbacks(void)
  188. +{
  189. +#if defined(CONFIG_BCM47XX_SSB)
  190. + if (ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb))
  191. + pr_warn("Failed to registered ssb SPROM handler\n");
  192. +#endif
  193. +
  194. +#if defined(CONFIG_BCM47XX_BCMA)
  195. + if (bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma))
  196. + pr_warn("Failed to registered bcma SPROM handler\n");
  197. +#endif
  198. +}