This patch adds BCMA Fallback SPROM registration depending on each board.
It can be easily adapted to new boards which require other BCMA Fallback SPROMs.

However, bcma/sprom.c wrongly detects there's a SPROM present, and never checks 
fallback SPROM. That's why I added "err = bcma_fill_sprom_with_fallback(bus, 
&bus->sprom);" at the end of "bcma_sprom_get" (drivers/bcma/sprom.c). Any 
suggestions on how to do this correctly?

"struct ssb_sprom bcm43225_bcma_sprom" has been extract from Broadcom's GPL 
code .bin files.
https://github.com/Noltari/SPROM_Map (Developed with jogo's help ;D).

Signed-off-by: Álvaro Fernández Rojas <nolt...@gmail.com>

Index: 
target/linux/brcm63xx/patches-3.3/804-963281T_TEF-BCM43225-BCMA-Fallback-SPROM.patch
===================================================================
--- 
target/linux/brcm63xx/patches-3.3/804-963281T_TEF-BCM43225-BCMA-Fallback-SPROM.patch
        (revisión: 0)
+++ 
target/linux/brcm63xx/patches-3.3/804-963281T_TEF-BCM43225-BCMA-Fallback-SPROM.patch
        (revisión: 0)
@@ -0,0 +1,200 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
++++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -12,6 +12,7 @@
+ #include <linux/string.h>
+ #include <linux/platform_device.h>
+ #include <linux/ssb/ssb.h>
++#include <linux/bcma/bcma.h>
+ #include <linux/gpio_keys.h>
+ #include <linux/input.h>
+ #include <linux/export.h>
+@@ -303,6 +304,7 @@ static struct board_info __initdata boar
+ static struct board_info __initdata board_963281T_TEF = {
+       .name                           = "963281T_TEF",
+       .expected_cpu_id                = 0x6328,
++      .bcma_fallback_sprom    = 43225,
+ 
+       .has_uart0                      = 1,
+       .has_pci                        = 1,
+@@ -2807,6 +2809,130 @@ int bcm63xx_get_fallback_sprom(struct ss
+ }
+ #endif
+ 
++#ifdef CONFIG_BCMA
++struct ssb_sprom* bcm63xx_bcma_sprom;
++EXPORT_SYMBOL(bcm63xx_bcma_sprom);
++int bcm63xx_get_bcma_fallback_sprom(struct bcma_bus *bus, struct ssb_sprom 
*out)
++{
++      if (bus->hosttype == BCMA_HOSTTYPE_PCI) {
++              memcpy(out, bcm63xx_bcma_sprom, sizeof(struct ssb_sprom));
++              return 0;
++      }
++      else {
++              printk(KERN_ERR PFX "unable to fill BCMA SPROM for given 
bustype.\n");
++              return -EINVAL;
++      }
++}
++
++struct ssb_sprom bcm43225_bcma_sprom = {
++      .revision                       = 0x8,
++      .board_rev                      = 0x1230,
++      .txpid2g[0]                     = 0x0,
++      .txpid2g[1]                     = 0x80,
++      .txpid2g[2]                     = 0x2,
++      .txpid2g[3]                     = 0x0,
++      .txpid5gl[0]                    = 0x0,
++      .txpid5gl[1]                    = 0x18,
++      .txpid5gl[2]                    = 0x0,
++      .txpid5gl[3]                    = 0x0,
++      .txpid5g[0]                     = 0x0,
++      .txpid5g[1]                     = 0x0,
++      .txpid5g[2]                     = 0x30,
++      .txpid5g[3]                     = 0x1f,
++      .txpid5gh[0]                    = 0x0,
++      .txpid5gh[1]                    = 0x0,
++      .txpid5gh[2]                    = 0xff,
++      .txpid5gh[3]                    = 0xff,
++      .boardflags_lo                  = 0x200,
++      .boardflags_hi                  = 0x0,
++      .boardflags2_lo                 = 0x1000,
++      .boardflags2_hi                 = 0x0,
++      .country_code                   = 0x0,
++      .core_pwr_info[0].itssi_2g      = 0x20,
++      .core_pwr_info[0].maxpwr_2g     = 0x4e,
++      .core_pwr_info[0].pa_2g[0]      = 0xfeb9,
++      .core_pwr_info[0].pa_2g[1]      = 0x16be,
++      .core_pwr_info[0].pa_2g[2]      = 0xfa97,
++      .core_pwr_info[0].itssi_5g      = 0xff,
++      .core_pwr_info[0].maxpwr_5g     = 0xff,
++      .core_pwr_info[0].maxpwr_5gh    = 0xff,
++      .core_pwr_info[0].maxpwr_5gl    = 0xff,
++      .core_pwr_info[0].pa_5gl[0]     = 0xffff,
++      .core_pwr_info[0].pa_5gl[1]     = 0xffff,
++      .core_pwr_info[0].pa_5gl[2]     = 0xffff,
++      .core_pwr_info[0].pa_5g[0]      = 0xffff,
++      .core_pwr_info[0].pa_5g[1]      = 0xffff,
++      .core_pwr_info[0].pa_5g[2]      = 0xffff,
++      .core_pwr_info[0].pa_5gh[0]     = 0xffff,
++      .core_pwr_info[0].pa_5gh[1]     = 0xffff,
++      .core_pwr_info[0].pa_5gh[2]     = 0xffff,
++      .core_pwr_info[1].itssi_2g      = 0x20,
++      .core_pwr_info[1].maxpwr_2g     = 0x4e,
++      .core_pwr_info[1].pa_2g[0]      = 0xfe9b,
++      .core_pwr_info[1].pa_2g[1]      = 0x1632,
++      .core_pwr_info[1].pa_2g[2]      = 0xfa9b,
++      .core_pwr_info[1].itssi_5g      = 0xff,
++      .core_pwr_info[1].maxpwr_5g     = 0xff,
++      .core_pwr_info[1].maxpwr_5gh    = 0xff,
++      .core_pwr_info[1].maxpwr_5gl    = 0xff,
++      .core_pwr_info[1].pa_5gl[0]     = 0xffff,
++      .core_pwr_info[1].pa_5gl[1]     = 0xffff,
++      .core_pwr_info[1].pa_5gl[2]     = 0xffff,
++      .core_pwr_info[1].pa_5g[0]      = 0xffff,
++      .core_pwr_info[1].pa_5g[1]      = 0xffff,
++      .core_pwr_info[1].pa_5g[2]      = 0xffff,
++      .core_pwr_info[1].pa_5gh[0]     = 0xffff,
++      .core_pwr_info[1].pa_5gh[1]     = 0xffff,
++      .core_pwr_info[1].pa_5gh[2]     = 0xffff,
++      .core_pwr_info[2].itssi_2g      = 0xff,
++      .core_pwr_info[2].maxpwr_2g     = 0xff,
++      .core_pwr_info[2].pa_2g[0]      = 0xffff,
++      .core_pwr_info[2].pa_2g[1]      = 0xffff,
++      .core_pwr_info[2].pa_2g[2]      = 0xffff,
++      .core_pwr_info[2].itssi_5g      = 0xff,
++      .core_pwr_info[2].maxpwr_5g     = 0xff,
++      .core_pwr_info[2].maxpwr_5gh    = 0xff,
++      .core_pwr_info[2].maxpwr_5gl    = 0xff,
++      .core_pwr_info[2].pa_5gl[0]     = 0xffff,
++      .core_pwr_info[2].pa_5gl[1]     = 0xffff,
++      .core_pwr_info[2].pa_5gl[2]     = 0xffff,
++      .core_pwr_info[2].pa_5g[0]      = 0xffff,
++      .core_pwr_info[2].pa_5g[1]      = 0xffff,
++      .core_pwr_info[2].pa_5g[2]      = 0xffff,
++      .core_pwr_info[2].pa_5gh[0]     = 0xffff,
++      .core_pwr_info[2].pa_5gh[1]     = 0xffff,
++      .core_pwr_info[2].pa_5gh[2]     = 0xffff,
++      .core_pwr_info[3].itssi_2g      = 0xff,
++      .core_pwr_info[3].maxpwr_2g     = 0xff,
++      .core_pwr_info[3].pa_2g[0]      = 0xffff,
++      .core_pwr_info[3].pa_2g[1]      = 0xffff,
++      .core_pwr_info[3].pa_2g[2]      = 0xffff,
++      .core_pwr_info[3].itssi_5g      = 0xff,
++      .core_pwr_info[3].maxpwr_5g     = 0xff,
++      .core_pwr_info[3].maxpwr_5gh    = 0xff,
++      .core_pwr_info[3].maxpwr_5gl    = 0xff,
++      .core_pwr_info[3].pa_5gl[0]     = 0xffff,
++      .core_pwr_info[3].pa_5gl[1]     = 0xffff,
++      .core_pwr_info[3].pa_5gl[2]     = 0xffff,
++      .core_pwr_info[3].pa_5g[0]      = 0xffff,
++      .core_pwr_info[3].pa_5g[1]      = 0xffff,
++      .core_pwr_info[3].pa_5g[2]      = 0xffff,
++      .core_pwr_info[3].pa_5gh[0]     = 0xffff,
++      .core_pwr_info[3].pa_5gh[1]     = 0xffff,
++      .core_pwr_info[3].pa_5gh[2]     = 0xffff,
++      .fem.ghz2.tssipos               = 0x1,
++      .fem.ghz2.extpa_gain            = 0x2,
++      .fem.ghz2.pdet_range            = 0x4,
++      .fem.ghz2.tr_iso                = 0x3,
++      .fem.ghz2.antswlut              = 0x0,
++      .fem.ghz5.tssipos               = 0x1,
++      .fem.ghz5.extpa_gain            = 0x3,
++      .fem.ghz5.pdet_range            = 0x1f,
++      .fem.ghz5.tr_iso                = 0x7,
++      .fem.ghz5.antswlut              = 0x1f,
++};
++#endif
++
+ /*
+  * return board name for /proc/cpuinfo
+  */
+@@ -3049,9 +3175,30 @@ int __init board_register_devices(void)
+               memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
+               if (ssb_arch_register_fallback_sprom(
+                               &bcm63xx_get_fallback_sprom) < 0)
+-                      pr_err(PFX "failed to register fallback SPROM\n");
++                      pr_err(PFX "failed to register SSB fallback SPROM\n");
++      }
++#endif
++
++#ifdef CONFIG_BCMA
++      switch (board.bcma_fallback_sprom) {
++              case 43225:
++                      bcm63xx_bcma_sprom = (struct ssb_sprom*) 
&bcm43225_bcma_sprom;
++                      //memcpy(bcm63xx_bcma_sprom, bcm43225_bcma_sprom, 
sizeof(struct ssb_sprom));
++                      break;
++              default:
++                      break;
++      }
++      if (bcm63xx_bcma_sprom &&
++              !board.has_caldata &&
++              !bcm63xx_nvram_get_mac_address(bcm63xx_bcma_sprom->il0mac)) {
++              memcpy(bcm63xx_bcma_sprom->et0mac, bcm63xx_bcma_sprom->il0mac, 
ETH_ALEN);
++              memcpy(bcm63xx_bcma_sprom->et1mac, bcm63xx_bcma_sprom->il0mac, 
ETH_ALEN);
++              if (bcma_arch_register_fallback_sprom(
++                      &bcm63xx_get_bcma_fallback_sprom) < 0)
++                      pr_err(PFX "failed to register BCMA fallback SPROM\n");
+       }
+ #endif
++
+       bcm63xx_hsspi_register();
+ 
+       bcm63xx_spi_register();
+--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
++++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+@@ -26,6 +26,7 @@ struct ath9k_caldata {
+ struct board_info {
+       u8              name[16];
+       unsigned int    expected_cpu_id;
++      u16     bcma_fallback_sprom;
+ 
+       /* enabled feature/device */
+       unsigned int    has_enet0:1;
+--- a/drivers/bcma/sprom.c
++++ b/drivers/bcma/sprom.c
+@@ -596,5 +596,6 @@ int bcma_sprom_get(struct bcma_bus *bus)
+ 
+ out:
+       kfree(sprom);
++      err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
+       return err;
+ }
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to