From 247299bfa0b5b18a98a721cdcbf4f5af4ff78a51 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Mon, 9 Sep 2013 17:31:53 +0000
Subject: [PATCH] rt2x00: merge an rt2800 initialization order fix

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37922
---
 .../mac80211/patches/300-pending_work.patch   |  2 +-
 .../patches/301-pending_work-rt2x00.patch     | 64 +++++++++++++------
 .../610-rt2x00-fix-rt3352-ext-pa.patch        |  6 +-
 .../611-rt2x00-rf_vals-rt3352-xtal20.patch    | 10 +--
 .../patches/615-rt2x00-fix_20mhz_clk.patch    |  2 +-
 .../patches/616-rt2x00-support-rt5350.patch   | 12 ++--
 ...9-rt2x00-change-led-polarity-from-OF.patch |  2 +-
 7 files changed, 62 insertions(+), 36 deletions(-)

diff --git a/package/kernel/mac80211/patches/300-pending_work.patch b/package/kernel/mac80211/patches/300-pending_work.patch
index ca232a0e53..de70867c6b 100644
--- a/package/kernel/mac80211/patches/300-pending_work.patch
+++ b/package/kernel/mac80211/patches/300-pending_work.patch
@@ -2983,7 +2983,7 @@
  	 *init dbgp flags before all
 --- a/drivers/net/wireless/rtlwifi/ps.c
 +++ b/drivers/net/wireless/rtlwifi/ps.c
-@@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw
+@@ -269,6 +269,7 @@ void rtl_ips_nic_on(struct ieee80211_hw 
  
  	spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags);
  }
diff --git a/package/kernel/mac80211/patches/301-pending_work-rt2x00.patch b/package/kernel/mac80211/patches/301-pending_work-rt2x00.patch
index 0d8039185c..353ef74762 100644
--- a/package/kernel/mac80211/patches/301-pending_work-rt2x00.patch
+++ b/package/kernel/mac80211/patches/301-pending_work-rt2x00.patch
@@ -2727,7 +2727,33 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	case RT5390:
  		rt2800_init_rfcsr_5390(rt2x00dev);
  		break;
-@@ -5456,15 +6711,15 @@ int rt2800_enable_radio(struct rt2x00_de
+@@ -5404,19 +6659,20 @@ int rt2800_enable_radio(struct rt2x00_de
+ 		     rt2800_init_registers(rt2x00dev)))
+ 		return -EIO;
+ 
++	if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev)))
++		return -EIO;
++
+ 	/*
+ 	 * Send signal to firmware during boot time.
+ 	 */
+ 	rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
+ 	rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
+-	if (rt2x00_is_usb(rt2x00dev)) {
++	if (rt2x00_is_usb(rt2x00dev))
+ 		rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
+-		rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
+-	}
++	rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0);
+ 	msleep(1);
+ 
+-	if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) ||
+-		     rt2800_wait_bbp_ready(rt2x00dev)))
++	if (unlikely(rt2800_wait_bbp_ready(rt2x00dev)))
+ 		return -EIO;
+ 
+ 	rt2800_init_bbp(rt2x00dev);
+@@ -5456,15 +6712,15 @@ int rt2800_enable_radio(struct rt2x00_de
  	/*
  	 * Initialize LED control
  	 */
@@ -2746,7 +2772,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	rt2800_mcu_request(rt2x00dev, MCU_LED_LED_POLARITY, 0xff,
  			   word & 0xff, (word >> 8) & 0xff);
  
-@@ -5560,6 +6815,34 @@ int rt2800_read_eeprom_efuse(struct rt2x
+@@ -5560,6 +6816,34 @@ int rt2800_read_eeprom_efuse(struct rt2x
  }
  EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
  
@@ -2781,7 +2807,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
  {
  	struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
-@@ -5578,18 +6861,18 @@ static int rt2800_validate_eeprom(struct
+@@ -5578,18 +6862,18 @@ static int rt2800_validate_eeprom(struct
  	/*
  	 * Start validation of the data that has been read.
  	 */
@@ -2803,7 +2829,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  		rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word);
  	} else if (rt2x00_rt(rt2x00dev, RT2860) ||
  		   rt2x00_rt(rt2x00dev, RT2872)) {
-@@ -5598,10 +6881,10 @@ static int rt2800_validate_eeprom(struct
+@@ -5598,10 +6882,10 @@ static int rt2800_validate_eeprom(struct
  		 */
  		if (rt2x00_get_field16(word, EEPROM_NIC_CONF0_RXPATH) > 2)
  			rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RXPATH, 2);
@@ -2816,7 +2842,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	if (word == 0xffff) {
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_HW_RADIO, 0);
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC, 0);
-@@ -5618,24 +6901,24 @@ static int rt2800_validate_eeprom(struct
+@@ -5618,24 +6902,24 @@ static int rt2800_validate_eeprom(struct
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_INTERNAL_TX_ALC, 0);
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_BT_COEXIST, 0);
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF1_DAC_TEST, 0);
@@ -2848,7 +2874,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  		rt2x00_eeprom_dbg(rt2x00dev, "Led Mode: 0x%04x\n", word);
  	}
  
-@@ -5644,56 +6927,61 @@ static int rt2800_validate_eeprom(struct
+@@ -5644,56 +6928,61 @@ static int rt2800_validate_eeprom(struct
  	 * lna0 as correct value. Note that EEPROM_LNA
  	 * is never validated.
  	 */
@@ -2941,7 +2967,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  
  	return 0;
  }
-@@ -5707,7 +6995,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5707,7 +6996,7 @@ static int rt2800_init_eeprom(struct rt2
  	/*
  	 * Read EEPROM word for configuration.
  	 */
@@ -2950,7 +2976,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  
  	/*
  	 * Identify RF chipset by EEPROM value
-@@ -5717,7 +7005,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5717,7 +7006,7 @@ static int rt2800_init_eeprom(struct rt2
  	if (rt2x00_rt(rt2x00dev, RT3290) ||
  	    rt2x00_rt(rt2x00dev, RT5390) ||
  	    rt2x00_rt(rt2x00dev, RT5392))
@@ -2959,7 +2985,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	else
  		rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
  
-@@ -5731,6 +7019,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5731,6 +7020,7 @@ static int rt2800_init_eeprom(struct rt2
  	case RF3021:
  	case RF3022:
  	case RF3052:
@@ -2967,7 +2993,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	case RF3290:
  	case RF3320:
  	case RF3322:
-@@ -5757,7 +7046,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5757,7 +7047,7 @@ static int rt2800_init_eeprom(struct rt2
  	rt2x00dev->default_ant.rx_chain_num =
  	    rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
  
@@ -2976,7 +3002,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  
  	if (rt2x00_rt(rt2x00dev, RT3070) ||
  	    rt2x00_rt(rt2x00dev, RT3090) ||
-@@ -5810,7 +7099,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5810,7 +7100,7 @@ static int rt2800_init_eeprom(struct rt2
  	/*
  	 * Read frequency offset and RF programming sequence.
  	 */
@@ -2985,7 +3011,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
  
  	/*
-@@ -5827,7 +7116,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -5827,7 +7117,7 @@ static int rt2800_init_eeprom(struct rt2
  	/*
  	 * Check if support EIRP tx power limit feature.
  	 */
@@ -2994,7 +3020,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  
  	if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) <
  					EIRP_MAX_TX_POWER_LIMIT)
-@@ -6109,12 +7398,79 @@ static const struct rf_channel rf_vals_5
+@@ -6109,12 +7399,79 @@ static const struct rf_channel rf_vals_5
  	{196, 83, 0, 12, 1},
  };
  
@@ -3074,7 +3100,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	unsigned int i;
  	u16 eeprom;
  	u32 reg;
-@@ -6149,7 +7505,7 @@ static int rt2800_probe_hw_mode(struct r
+@@ -6149,7 +7506,7 @@ static int rt2800_probe_hw_mode(struct r
  
  	SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
  	SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
@@ -3083,7 +3109,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  						   EEPROM_MAC_ADDR_0));
  
  	/*
-@@ -6165,7 +7521,7 @@ static int rt2800_probe_hw_mode(struct r
+@@ -6165,7 +7522,7 @@ static int rt2800_probe_hw_mode(struct r
  	rt2x00dev->hw->max_report_rates = 7;
  	rt2x00dev->hw->max_rate_tries = 1;
  
@@ -3092,7 +3118,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  
  	/*
  	 * Initialize hw_mode information.
-@@ -6200,6 +7556,10 @@ static int rt2800_probe_hw_mode(struct r
+@@ -6200,6 +7557,10 @@ static int rt2800_probe_hw_mode(struct r
  		spec->supported_bands |= SUPPORT_BAND_5GHZ;
  		spec->num_channels = ARRAY_SIZE(rf_vals_3x);
  		spec->channels = rf_vals_3x;
@@ -3103,7 +3129,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	} else if (rt2x00_rf(rt2x00dev, RF5592)) {
  		spec->supported_bands |= SUPPORT_BAND_5GHZ;
  
-@@ -6265,21 +7625,40 @@ static int rt2800_probe_hw_mode(struct r
+@@ -6265,21 +7626,40 @@ static int rt2800_probe_hw_mode(struct r
  
  	spec->channels_info = info;
  
@@ -3148,7 +3174,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  		}
  	}
  
-@@ -6290,6 +7669,7 @@ static int rt2800_probe_hw_mode(struct r
+@@ -6290,6 +7670,7 @@ static int rt2800_probe_hw_mode(struct r
  	case RF3022:
  	case RF3320:
  	case RF3052:
@@ -3156,7 +3182,7 @@ Contains the following changes from wireless-testing/master-2013-08-26:
  	case RF3290:
  	case RF5360:
  	case RF5370:
-@@ -6328,6 +7708,7 @@ static int rt2800_probe_rt(struct rt2x00
+@@ -6328,6 +7709,7 @@ static int rt2800_probe_rt(struct rt2x00
  	case RT3352:
  	case RT3390:
  	case RT3572:
diff --git a/package/kernel/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch b/package/kernel/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch
index e2cd4d0198..c0829d74fb 100644
--- a/package/kernel/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch
+++ b/package/kernel/mac80211/patches/610-rt2x00-fix-rt3352-ext-pa.patch
@@ -110,7 +110,7 @@
  	rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
  	rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
  	rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
-@@ -7003,6 +7029,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7004,6 +7030,7 @@ static int rt2800_init_eeprom(struct rt2
  	 * RT53xx: defined in "EEPROM_CHIP_ID" field
  	 */
  	if (rt2x00_rt(rt2x00dev, RT3290) ||
@@ -118,7 +118,7 @@
  	    rt2x00_rt(rt2x00dev, RT5390) ||
  	    rt2x00_rt(rt2x00dev, RT5392))
  		rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
-@@ -7093,7 +7120,8 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7094,7 +7121,8 @@ static int rt2800_init_eeprom(struct rt2
  	/*
  	 * Detect if this device has Bluetooth co-existence.
  	 */
@@ -128,7 +128,7 @@
  		__set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
  
  	/*
-@@ -7122,6 +7150,22 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7123,6 +7151,22 @@ static int rt2800_init_eeprom(struct rt2
  					EIRP_MAX_TX_POWER_LIMIT)
  		__set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
  
diff --git a/package/kernel/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch b/package/kernel/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch
index 4fc1e0a01b..212b31ee96 100644
--- a/package/kernel/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch
+++ b/package/kernel/mac80211/patches/611-rt2x00-rf_vals-rt3352-xtal20.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
-@@ -7508,6 +7508,27 @@ static const struct rf_channel rf_vals_3
+@@ -7509,6 +7509,27 @@ static const struct rf_channel rf_vals_3
  	{173, 0x61, 0, 9},
  };
  
@@ -28,7 +28,7 @@
  static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
  {
  	struct hw_mode_spec *spec = &rt2x00dev->spec;
-@@ -7588,7 +7609,6 @@ static int rt2800_probe_hw_mode(struct r
+@@ -7589,7 +7610,6 @@ static int rt2800_probe_hw_mode(struct r
  		   rt2x00_rf(rt2x00dev, RF3022) ||
  		   rt2x00_rf(rt2x00dev, RF3290) ||
  		   rt2x00_rf(rt2x00dev, RF3320) ||
@@ -36,7 +36,7 @@
  		   rt2x00_rf(rt2x00dev, RF5360) ||
  		   rt2x00_rf(rt2x00dev, RF5370) ||
  		   rt2x00_rf(rt2x00dev, RF5372) ||
-@@ -7596,6 +7616,12 @@ static int rt2800_probe_hw_mode(struct r
+@@ -7597,6 +7617,12 @@ static int rt2800_probe_hw_mode(struct r
  		   rt2x00_rf(rt2x00dev, RF5392)) {
  		spec->num_channels = 14;
  		spec->channels = rf_vals_3x;
@@ -49,7 +49,7 @@
  	} else if (rt2x00_rf(rt2x00dev, RF3052)) {
  		spec->supported_bands |= SUPPORT_BAND_5GHZ;
  		spec->num_channels = ARRAY_SIZE(rf_vals_3x);
-@@ -7768,6 +7794,19 @@ static int rt2800_probe_rt(struct rt2x00
+@@ -7769,6 +7795,19 @@ static int rt2800_probe_rt(struct rt2x00
  	return 0;
  }
  
@@ -69,7 +69,7 @@
  int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
  {
  	int retval;
-@@ -7797,6 +7836,15 @@ int rt2800_probe_hw(struct rt2x00_dev *r
+@@ -7798,6 +7837,15 @@ int rt2800_probe_hw(struct rt2x00_dev *r
  	rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
  
  	/*
diff --git a/package/kernel/mac80211/patches/615-rt2x00-fix_20mhz_clk.patch b/package/kernel/mac80211/patches/615-rt2x00-fix_20mhz_clk.patch
index 1110394e8c..1873b6295e 100644
--- a/package/kernel/mac80211/patches/615-rt2x00-fix_20mhz_clk.patch
+++ b/package/kernel/mac80211/patches/615-rt2x00-fix_20mhz_clk.patch
@@ -8,7 +8,7 @@
  
  #include "rt2x00.h"
  #include "rt2800lib.h"
-@@ -7796,13 +7797,14 @@ static int rt2800_probe_rt(struct rt2x00
+@@ -7797,13 +7798,14 @@ static int rt2800_probe_rt(struct rt2x00
  
  int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
  {
diff --git a/package/kernel/mac80211/patches/616-rt2x00-support-rt5350.patch b/package/kernel/mac80211/patches/616-rt2x00-support-rt5350.patch
index 223d46a8e3..6acc70eaa2 100644
--- a/package/kernel/mac80211/patches/616-rt2x00-support-rt5350.patch
+++ b/package/kernel/mac80211/patches/616-rt2x00-support-rt5350.patch
@@ -212,7 +212,7 @@
  	case RT5390:
  		rt2800_init_rfcsr_5390(rt2x00dev);
  		break;
-@@ -6901,6 +7005,12 @@ static int rt2800_validate_eeprom(struct
+@@ -6902,6 +7006,12 @@ static int rt2800_validate_eeprom(struct
  		rt2x00_set_field16(&word, EEPROM_NIC_CONF0_RF_TYPE, RF2820);
  		rt2800_eeprom_write(rt2x00dev, EEPROM_NIC_CONF0, word);
  		rt2x00_eeprom_dbg(rt2x00dev, "Antenna: 0x%04x\n", word);
@@ -225,7 +225,7 @@
  	} else if (rt2x00_rt(rt2x00dev, RT2860) ||
  		   rt2x00_rt(rt2x00dev, RT2872)) {
  		/*
-@@ -7034,6 +7144,8 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7035,6 +7145,8 @@ static int rt2800_init_eeprom(struct rt2
  	    rt2x00_rt(rt2x00dev, RT5390) ||
  	    rt2x00_rt(rt2x00dev, RT5392))
  		rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
@@ -234,7 +234,7 @@
  	else
  		rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE);
  
-@@ -7051,6 +7163,7 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7052,6 +7164,7 @@ static int rt2800_init_eeprom(struct rt2
  	case RF3290:
  	case RF3320:
  	case RF3322:
@@ -242,7 +242,7 @@
  	case RF5360:
  	case RF5370:
  	case RF5372:
-@@ -7617,7 +7730,8 @@ static int rt2800_probe_hw_mode(struct r
+@@ -7618,7 +7731,8 @@ static int rt2800_probe_hw_mode(struct r
  		   rt2x00_rf(rt2x00dev, RF5392)) {
  		spec->num_channels = 14;
  		spec->channels = rf_vals_3x;
@@ -252,7 +252,7 @@
  		spec->num_channels = 14;
  		if (spec->clk_is_20mhz)
  			spec->channels = rf_vals_xtal20mhz_3x;
-@@ -7742,6 +7856,7 @@ static int rt2800_probe_hw_mode(struct r
+@@ -7743,6 +7857,7 @@ static int rt2800_probe_hw_mode(struct r
  	case RF3052:
  	case RF3053:
  	case RF3290:
@@ -260,7 +260,7 @@
  	case RF5360:
  	case RF5370:
  	case RF5372:
-@@ -7780,6 +7895,7 @@ static int rt2800_probe_rt(struct rt2x00
+@@ -7781,6 +7896,7 @@ static int rt2800_probe_rt(struct rt2x00
  	case RT3390:
  	case RT3572:
  	case RT3593:
diff --git a/package/kernel/mac80211/patches/619-rt2x00-change-led-polarity-from-OF.patch b/package/kernel/mac80211/patches/619-rt2x00-change-led-polarity-from-OF.patch
index 05d5f119a8..a81d6c96fd 100644
--- a/package/kernel/mac80211/patches/619-rt2x00-change-led-polarity-from-OF.patch
+++ b/package/kernel/mac80211/patches/619-rt2x00-change-led-polarity-from-OF.patch
@@ -8,7 +8,7 @@
  
  #include "rt2x00.h"
  #include "rt2800lib.h"
-@@ -7252,6 +7253,17 @@ static int rt2800_init_eeprom(struct rt2
+@@ -7253,6 +7254,17 @@ static int rt2800_init_eeprom(struct rt2
  	rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
  	rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
  
-- 
GitLab