362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. From 03feb9db77fba3eef3d83e17a87a56979659b248 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Tue, 29 Jul 2014 22:48:26 +0200
  4. Subject: [PATCH 07/10] MIPS: BCM63XX: also register a fallback sprom for bcma
  5. Similar to SSB, register a fallback sprom handler for BCMA.
  6. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  7. ---
  8. arch/mips/bcm63xx/boards/Kconfig | 1 +
  9. arch/mips/bcm63xx/sprom.c | 40 +++++++++++++++++++++++++++++++++++-----
  10. 2 files changed, 36 insertions(+), 5 deletions(-)
  11. --- a/arch/mips/bcm63xx/boards/Kconfig
  12. +++ b/arch/mips/bcm63xx/boards/Kconfig
  13. @@ -4,6 +4,7 @@ menu "Board support"
  14. config BOARD_BCM963XX
  15. bool "Generic Broadcom 963xx boards"
  16. select SSB
  17. + select BCMA
  18. default y
  19. help
  20. --- a/arch/mips/bcm63xx/sprom.c
  21. +++ b/arch/mips/bcm63xx/sprom.c
  22. @@ -12,6 +12,7 @@
  23. #include <linux/string.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/ssb/ssb.h>
  26. +#include <linux/bcma/bcma.h>
  27. #include <bcm63xx_fallback_sprom.h>
  28. #include <board_bcm963xx.h>
  29. @@ -21,7 +22,7 @@
  30. * Register a sane SPROMv2 to make the on-board
  31. * bcm4318 WLAN work
  32. */
  33. -#ifdef CONFIG_SSB_PCIHOST
  34. +#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
  35. static __initconst struct ssb_sprom bcm63xx_default_sprom = {
  36. .revision = 0x02,
  37. .board_rev = 0x17,
  38. @@ -43,7 +44,7 @@ static __initconst struct ssb_sprom bcm6
  39. .boardflags_hi = 0x0000,
  40. };
  41. -
  42. +#if defined (CONFIG_SSB_PCIHOST)
  43. static __initconst u16 bcm4306_sprom[] = {
  44. 0x4001, 0x0000, 0x0453, 0x14e4, 0x4320, 0x8000, 0x0002, 0x0002,
  45. 0x1000, 0x1800, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff,
  46. @@ -158,10 +159,12 @@ static __initconst u16 bcm43222_sprom[]
  47. 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
  48. 0xffff, 0xffff, 0xffff, 0x0008,
  49. };
  50. +#endif /* CONFIG_SSB_PCIHOST */
  51. static struct ssb_sprom bcm63xx_sprom;
  52. -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  53. +#if defined(CONFIG_SSB_PCIHOST)
  54. +int bcm63xx_get_fallback_ssb_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  55. {
  56. if (bus->bustype == SSB_BUSTYPE_PCI) {
  57. memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  58. @@ -171,6 +174,20 @@ int bcm63xx_get_fallback_sprom(struct ss
  59. return -EINVAL;
  60. }
  61. }
  62. +#endif
  63. +
  64. +#if defined(CONFIG_BCMA_HOST_PCI)
  65. +int bcm63xx_get_fallback_bcma_sprom(struct bcma_bus *bus, struct ssb_sprom *out)
  66. +{
  67. + if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
  68. + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  69. + return 0;
  70. + } else {
  71. + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
  72. + return -EINVAL;
  73. + }
  74. +}
  75. +#endif
  76. /* FIXME: use lib_sprom after submission upstream */
  77. @@ -654,10 +671,11 @@ int __init bcm63xx_register_fallback_spr
  78. {
  79. int ret = 0;
  80. -#ifdef CONFIG_SSB_PCIHOST
  81. +#if defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI)
  82. u16 size = 0;
  83. switch (data->type) {
  84. +#if defined(CONFIG_SSB_PCIHOST)
  85. case SPROM_BCM4306:
  86. memcpy(&template_sprom, &bcm4306_sprom, sizeof(bcm4306_sprom));
  87. size = ARRAY_SIZE(bcm4306_sprom);
  88. @@ -678,6 +696,7 @@ int __init bcm63xx_register_fallback_spr
  89. memcpy(&template_sprom, &bcm43222_sprom, sizeof(bcm43222_sprom));
  90. size = ARRAY_SIZE(bcm43222_sprom);
  91. break;
  92. +#endif
  93. case SPROM_DEFAULT:
  94. memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom,
  95. sizeof(bcm63xx_sprom));
  96. @@ -692,8 +711,19 @@ int __init bcm63xx_register_fallback_spr
  97. memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN);
  98. memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN);
  99. memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN);
  100. +#endif /* defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI) */
  101. +
  102. +#if defined(CONFIG_SSB_PCIHOST)
  103. + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_ssb_sprom);
  104. + if (ret)
  105. + return ret;
  106. +
  107. +#endif
  108. - ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
  109. +#if defined(CONFIG_BCMA_HOST_PCI)
  110. + ret = bcma_arch_register_fallback_sprom(bcm63xx_get_fallback_bcma_sprom);
  111. + if (ret)
  112. + return ret;
  113. #endif
  114. return ret;
  115. }