From 8879e209111192c5e9752d7bd203cf7582693328 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Thu, 3 May 2012 14:40:03 +0200
Subject: [PATCH 58/72] BCM63XX: allow providing fixup data in board data

---
 arch/mips/bcm63xx/boards/board_bcm963xx.c           |    9 ++++++++-
 arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h |   10 ++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -33,6 +33,7 @@
 #include <bcm63xx_dev_usb_ohci.h>
 #include <bcm63xx_dev_usb_usbd.h>
 #include <board_bcm963xx.h>
+#include <pci_ath9k_fixup.h>
 
 #include <uapi/linux/bcm933xx_hcs.h>
 #include <uapi/linux/bcm963xx_tag.h>
@@ -958,6 +959,7 @@ int __init board_register_devices(void)
 {
 	int button_count = 0;
 	int led_count = 0;
+	int i;
 
 	if (board.has_uart0)
 		bcm63xx_uart_register(0);
@@ -996,7 +998,8 @@ int __init board_register_devices(void)
 	 * do this after registering enet devices
 	 */
 #ifdef CONFIG_SSB_PCIHOST
-	if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
+	if (!board.has_caldata &&
+	    !bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
 		memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
 		memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
 		if (ssb_arch_register_fallback_sprom(
@@ -1043,5 +1046,9 @@ int __init board_register_devices(void)
 		platform_device_register(&bcm63xx_gpio_keys_device);
 	}
 
+	/* register any fixups */
+	for (i = 0; i < board.has_caldata; i++)
+		pci_enable_ath9k_fixup(board.caldata[i].slot, board.caldata[i].caldata_offset);
+
 	return 0;
 }
--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
@@ -8,6 +8,7 @@
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_usb_usbd.h>
 #include <bcm63xx_dev_dsp.h>
+#include <pci_ath9k_fixup.h>
 
 /*
  * flash mapping
@@ -15,6 +16,11 @@
 #define BCM963XX_CFE_VERSION_OFFSET	0x570
 #define BCM963XX_NVRAM_OFFSET		0x580
 
+struct ath9k_caldata {
+	unsigned int	slot;
+	u32		caldata_offset;
+};
+
 /*
  * board definition
  */
@@ -34,6 +40,10 @@ struct board_info {
 	unsigned int	has_dsp:1;
 	unsigned int	has_uart0:1;
 	unsigned int	has_uart1:1;
+	unsigned int	has_caldata:2;
+
+	/* wifi calibration data config */
+	struct ath9k_caldata caldata[2];
 
 	/* ethernet config */
 	struct bcm63xx_enet_platform_data enet0;