356-MIPS-BCM63XX-move-fallback-sprom-support-into-its-ow.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. From cc025e749a1fece61a6cc0d64bbe7b12472259cc Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Tue, 29 Jul 2014 21:31:12 +0200
  4. Subject: [PATCH 01/10] MIPS: BCM63XX: move fallback sprom support into its own
  5. unit
  6. In preparation for enhancing it, move it into its own file. Require a
  7. mac address to be passed as the argument to always "reserve" the mac
  8. regardless of the inclusion state of SSB.
  9. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  10. ---
  11. arch/mips/bcm63xx/Makefile | 2 +-
  12. arch/mips/bcm63xx/boards/board_common.c | 53 ++--------------
  13. arch/mips/bcm63xx/sprom.c | 70 ++++++++++++++++++++++
  14. .../asm/mach-bcm63xx/bcm63xx_fallback_sprom.h | 6 ++
  15. 4 files changed, 83 insertions(+), 48 deletions(-)
  16. create mode 100644 arch/mips/bcm63xx/sprom.c
  17. create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
  18. --- a/arch/mips/bcm63xx/Makefile
  19. +++ b/arch/mips/bcm63xx/Makefile
  20. @@ -2,7 +2,7 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o
  21. setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
  22. dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
  23. dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
  24. - usb-common.o
  25. + usb-common.o sprom.o
  26. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  27. obj-y += boards/
  28. --- a/arch/mips/bcm63xx/boards/board_common.c
  29. +++ b/arch/mips/bcm63xx/boards/board_common.c
  30. @@ -43,44 +43,6 @@
  31. static struct board_info board;
  32. /*
  33. - * Register a sane SPROMv2 to make the on-board
  34. - * bcm4318 WLAN work
  35. - */
  36. -#ifdef CONFIG_SSB_PCIHOST
  37. -static struct ssb_sprom bcm63xx_sprom = {
  38. - .revision = 0x02,
  39. - .board_rev = 0x17,
  40. - .country_code = 0x0,
  41. - .ant_available_bg = 0x3,
  42. - .pa0b0 = 0x15ae,
  43. - .pa0b1 = 0xfa85,
  44. - .pa0b2 = 0xfe8d,
  45. - .pa1b0 = 0xffff,
  46. - .pa1b1 = 0xffff,
  47. - .pa1b2 = 0xffff,
  48. - .gpio0 = 0xff,
  49. - .gpio1 = 0xff,
  50. - .gpio2 = 0xff,
  51. - .gpio3 = 0xff,
  52. - .maxpwr_bg = 0x004c,
  53. - .itssi_bg = 0x00,
  54. - .boardflags_lo = 0x2848,
  55. - .boardflags_hi = 0x0000,
  56. -};
  57. -
  58. -int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  59. -{
  60. - if (bus->bustype == SSB_BUSTYPE_PCI) {
  61. - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  62. - return 0;
  63. - } else {
  64. - printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
  65. - return -EINVAL;
  66. - }
  67. -}
  68. -#endif
  69. -
  70. -/*
  71. * return board name for /proc/cpuinfo
  72. */
  73. const char *board_get_name(void)
  74. @@ -195,6 +157,7 @@ int __init board_register_devices(void)
  75. int button_count = 0;
  76. int led_count = 0;
  77. int usbh_ports = 0;
  78. + u8 mac[ETH_ALEN];
  79. if (board.has_uart0)
  80. bcm63xx_uart_register(0);
  81. @@ -239,15 +202,10 @@ int __init board_register_devices(void)
  82. /* Generate MAC address for WLAN and register our SPROM,
  83. * do this after registering enet devices
  84. */
  85. -#ifdef CONFIG_SSB_PCIHOST
  86. - if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
  87. - memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  88. - memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  89. - if (ssb_arch_register_fallback_sprom(
  90. - &bcm63xx_get_fallback_sprom) < 0)
  91. - pr_err(PFX "failed to register fallback SPROM\n");
  92. - }
  93. -#endif
  94. +
  95. + if (board_get_mac_address(mac) ||
  96. + bcm63xx_register_fallback_sprom(mac))
  97. + pr_err(PFX "failed to register fallback SPROM\n");
  98. bcm63xx_spi_register();
  99. --- /dev/null
  100. +++ b/arch/mips/bcm63xx/sprom.c
  101. @@ -0,0 +1,70 @@
  102. +/*
  103. + * This file is subject to the terms and conditions of the GNU General Public
  104. + * License. See the file "COPYING" in the main directory of this archive
  105. + * for more details.
  106. + *
  107. + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  108. + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
  109. + */
  110. +
  111. +#include <linux/init.h>
  112. +#include <linux/kernel.h>
  113. +#include <linux/string.h>
  114. +#include <linux/platform_device.h>
  115. +#include <linux/ssb/ssb.h>
  116. +#include <bcm63xx_fallback_sprom.h>
  117. +#include <board_bcm963xx.h>
  118. +
  119. +#define PFX "sprom: "
  120. +
  121. +/*
  122. + * Register a sane SPROMv2 to make the on-board
  123. + * bcm4318 WLAN work
  124. + */
  125. +#ifdef CONFIG_SSB_PCIHOST
  126. +static struct ssb_sprom bcm63xx_sprom = {
  127. + .revision = 0x02,
  128. + .board_rev = 0x17,
  129. + .country_code = 0x0,
  130. + .ant_available_bg = 0x3,
  131. + .pa0b0 = 0x15ae,
  132. + .pa0b1 = 0xfa85,
  133. + .pa0b2 = 0xfe8d,
  134. + .pa1b0 = 0xffff,
  135. + .pa1b1 = 0xffff,
  136. + .pa1b2 = 0xffff,
  137. + .gpio0 = 0xff,
  138. + .gpio1 = 0xff,
  139. + .gpio2 = 0xff,
  140. + .gpio3 = 0xff,
  141. + .maxpwr_bg = 0x004c,
  142. + .itssi_bg = 0x00,
  143. + .boardflags_lo = 0x2848,
  144. + .boardflags_hi = 0x0000,
  145. +};
  146. +
  147. +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  148. +{
  149. + if (bus->bustype == SSB_BUSTYPE_PCI) {
  150. + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  151. + return 0;
  152. + } else {
  153. + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
  154. + return -EINVAL;
  155. + }
  156. +}
  157. +#endif
  158. +
  159. +int __init bcm63xx_register_fallback_sprom(u8 *mac)
  160. +{
  161. + int ret = 0;
  162. +
  163. +#ifdef CONFIG_SSB_PCIHOST
  164. + memcpy(bcm63xx_sprom.il0mac, mac, ETH_ALEN);
  165. + memcpy(bcm63xx_sprom.et0mac, mac, ETH_ALEN);
  166. + memcpy(bcm63xx_sprom.et1mac, mac, ETH_ALEN);
  167. +
  168. + ret = ssb_arch_register_fallback_sprom(&bcm63xx_get_fallback_sprom);
  169. +#endif
  170. + return ret;
  171. +}
  172. --- /dev/null
  173. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h
  174. @@ -0,0 +1,6 @@
  175. +#ifndef __BCM63XX_FALLBACK_SPROM
  176. +#define __BCM63XX_FALLBACK_SPROM
  177. +
  178. +int bcm63xx_register_fallback_sprom(u8 *mac);
  179. +
  180. +#endif