1
0

810-bcma-ssb-fallback-sprom.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. From e4d708702e6c98f2111e33201a264d6788564cb2 Mon Sep 17 00:00:00 2001
  2. From: libreCMC community <openwrt-devel@lists.openwrt.org>
  3. Date: Fri, 12 May 2023 11:08:43 +0200
  4. Subject: [PATCH] ssb_sprom: add generic kernel support for Broadcom Fallback SPROMs
  5. ---
  6. drivers/bcma/Kconfig | 4 ++++
  7. drivers/bcma/Makefile | 1 +
  8. drivers/bcma/bcma_private.h | 4 ++++
  9. drivers/bcma/main.c | 8 ++++++++
  10. drivers/bcma/sprom.c | 23 ++++++++++++++---------
  11. drivers/ssb/Kconfig | 5 +++++
  12. drivers/ssb/Makefile | 1 +
  13. drivers/ssb/main.c | 8 ++++++++
  14. drivers/ssb/sprom.c | 12 +++++++++++-
  15. drivers/ssb/ssb_private.h | 4 ++++
  16. 10 files changed, 60 insertions(+), 10 deletions(-)
  17. --- a/drivers/bcma/Kconfig
  18. +++ b/drivers/bcma/Kconfig
  19. @@ -18,6 +18,10 @@ config BCMA_BLOCKIO
  20. bool
  21. default y
  22. +config BCMA_FALLBACK_SPROM
  23. + bool
  24. + default y
  25. +
  26. config BCMA_HOST_PCI_POSSIBLE
  27. bool
  28. depends on PCI = y
  29. --- a/drivers/bcma/Makefile
  30. +++ b/drivers/bcma/Makefile
  31. @@ -11,6 +11,7 @@ bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE)
  32. bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
  33. bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
  34. bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
  35. +bcma-$(CONFIG_BCMA_FALLBACK_SPROM) += fallback-sprom.o
  36. bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
  37. bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
  38. obj-$(CONFIG_BCMA) += bcma.o
  39. --- a/drivers/bcma/bcma_private.h
  40. +++ b/drivers/bcma/bcma_private.h
  41. @@ -38,6 +38,10 @@ int bcma_bus_resume(struct bcma_bus *bus
  42. void bcma_detect_chip(struct bcma_bus *bus);
  43. int bcma_bus_scan(struct bcma_bus *bus);
  44. +/* fallback-sprom.c */
  45. +int __init bcma_fbs_register(void);
  46. +int bcma_get_fallback_sprom(struct bcma_bus *dev, struct ssb_sprom *out);
  47. +
  48. /* sprom.c */
  49. int bcma_sprom_get(struct bcma_bus *bus);
  50. --- a/drivers/bcma/main.c
  51. +++ b/drivers/bcma/main.c
  52. @@ -668,6 +668,14 @@ static int __init bcma_modinit(void)
  53. {
  54. int err;
  55. +#ifdef CONFIG_BCMA_FALLBACK_SPROM
  56. + err = bcma_fbs_register();
  57. + if (err) {
  58. + pr_err("Fallback SPROM initialization failed\n");
  59. + err = 0;
  60. + }
  61. +#endif /* CONFIG_BCMA_FALLBACK_SPROM */
  62. +
  63. err = bcma_init_bus_register();
  64. if (err)
  65. return err;
  66. --- a/drivers/bcma/sprom.c
  67. +++ b/drivers/bcma/sprom.c
  68. @@ -51,21 +51,26 @@ static int bcma_fill_sprom_with_fallback
  69. {
  70. int err;
  71. - if (!get_fallback_sprom) {
  72. + if (get_fallback_sprom)
  73. + err = get_fallback_sprom(bus, out);
  74. +
  75. +#ifdef CONFIG_BCMA_FALLBACK_SPROM
  76. + if (!get_fallback_sprom || err)
  77. + err = bcma_get_fallback_sprom(bus, out);
  78. +#else
  79. + if (!get_fallback_sprom)
  80. err = -ENOENT;
  81. - goto fail;
  82. - }
  83. +#endif /* CONFIG_BCMA_FALLBACK_SPROM */
  84. - err = get_fallback_sprom(bus, out);
  85. - if (err)
  86. - goto fail;
  87. + if (err) {
  88. + bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err);
  89. + return err;
  90. + }
  91. bcma_debug(bus, "Using SPROM revision %d provided by platform.\n",
  92. bus->sprom.revision);
  93. +
  94. return 0;
  95. -fail:
  96. - bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err);
  97. - return err;
  98. }
  99. /**************************************************
  100. --- a/drivers/ssb/Kconfig
  101. +++ b/drivers/ssb/Kconfig
  102. @@ -25,6 +25,11 @@ if SSB
  103. config SSB_SPROM
  104. bool
  105. +config SSB_FALLBACK_SPROM
  106. + bool
  107. + depends on SSB_PCIHOST
  108. + default y
  109. +
  110. # Support for Block-I/O. SELECT this from the driver that needs it.
  111. config SSB_BLOCKIO
  112. bool
  113. --- a/drivers/ssb/Makefile
  114. +++ b/drivers/ssb/Makefile
  115. @@ -2,6 +2,7 @@
  116. # core
  117. ssb-y += main.o scan.o
  118. ssb-$(CONFIG_SSB_EMBEDDED) += embedded.o
  119. +ssb-$(CONFIG_SSB_FALLBACK_SPROM) += fallback-sprom.o
  120. ssb-$(CONFIG_SSB_SPROM) += sprom.o
  121. # host support
  122. --- a/drivers/ssb/main.c
  123. +++ b/drivers/ssb/main.c
  124. @@ -1287,6 +1287,14 @@ static int __init ssb_modinit(void)
  125. {
  126. int err;
  127. +#ifdef CONFIG_SSB_FALLBACK_SPROM
  128. + err = ssb_fbs_register();
  129. + if (err) {
  130. + pr_err("Fallback SPROM initialization failed\n");
  131. + err = 0;
  132. + }
  133. +#endif /* CONFIG_SSB_FALLBACK_SPROM */
  134. +
  135. /* See the comment at the ssb_is_early_boot definition */
  136. ssb_is_early_boot = 0;
  137. err = bus_register(&ssb_bustype);
  138. --- a/drivers/ssb/sprom.c
  139. +++ b/drivers/ssb/sprom.c
  140. @@ -180,10 +180,20 @@ int ssb_arch_register_fallback_sprom(int
  141. int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
  142. {
  143. + int err;
  144. +
  145. + if (get_fallback_sprom)
  146. + err = get_fallback_sprom(bus, out);
  147. +
  148. +#ifdef CONFIG_SSB_FALLBACK_SPROM
  149. + if (!get_fallback_sprom || err)
  150. + err = ssb_get_fallback_sprom(bus, out);
  151. +#else
  152. if (!get_fallback_sprom)
  153. return -ENOENT;
  154. +#endif /* CONFIG_SSB_FALLBACK_SPROM */
  155. - return get_fallback_sprom(bus, out);
  156. + return err;
  157. }
  158. /* https://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */
  159. --- a/drivers/ssb/ssb_private.h
  160. +++ b/drivers/ssb/ssb_private.h
  161. @@ -143,6 +143,10 @@ extern int ssb_bus_scan(struct ssb_bus *
  162. extern void ssb_iounmap(struct ssb_bus *ssb);
  163. +/* fallback-sprom.c */
  164. +int __init ssb_fbs_register(void);
  165. +int ssb_get_fallback_sprom(struct ssb_bus *dev, struct ssb_sprom *out);
  166. +
  167. /* sprom.c */
  168. extern
  169. ssize_t ssb_attr_sprom_show(struct ssb_bus *bus, char *buf,