mac80211: rt2x00: reorder patches and prepare for MT7620 external PA
[openwrt/staging/chunkeey.git] / package / kernel / mac80211 / patches / 020-20-rt2x00-reverse-external-PA-capability-flag-logic.patch
1 From 1f242a3de702d5a19c479685d35b050837122724 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 10 Apr 2017 15:29:45 +0200
4 Subject: [PATCH] rt2x00: reverse external PA capability flag logic
5
6 Consequently refer to external PA instead of inverting the logic and
7 use an internal PA capability flag which is a bit confusing.
8 Currently this is used for Rt3352 only, but MT7620A also allows for an
9 external PA which will be supported by a follow up patch.
10
11 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
12 Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15 drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 40 +++++++++++++-------------
16 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 4 +--
17 2 files changed, 22 insertions(+), 22 deletions(-)
18
19 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
20 index 201b12ed90c6..ba06ac2d876d 100644
21 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
22 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
23 @@ -7014,9 +7014,9 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
24
25 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
26 {
27 - int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
28 + int tx0_ext_pa = test_bit(CAPABILITY_EXTERNAL_PA_TX0,
29 &rt2x00dev->cap_flags);
30 - int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
31 + int tx1_ext_pa = test_bit(CAPABILITY_EXTERNAL_PA_TX1,
32 &rt2x00dev->cap_flags);
33 u8 rfcsr;
34
35 @@ -7056,9 +7056,9 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
36 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
37 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
38 rfcsr = 0x01;
39 - if (!tx0_int_pa)
40 + if (tx0_ext_pa)
41 rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
42 - if (!tx1_int_pa)
43 + if (tx1_ext_pa)
44 rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
45 rt2800_rfcsr_write(rt2x00dev, 34, rfcsr);
46 rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
47 @@ -7068,13 +7068,13 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
48 rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
49 rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
50 rfcsr = 0x52;
51 - if (tx0_int_pa) {
52 + if (!tx0_ext_pa) {
53 rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
54 rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
55 }
56 rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
57 rfcsr = 0x52;
58 - if (tx1_int_pa) {
59 + if (!tx1_ext_pa) {
60 rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
61 rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
62 }
63 @@ -7087,19 +7087,19 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
64 rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
65 rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
66 rfcsr = 0x2d;
67 - if (!tx0_int_pa)
68 + if (tx0_ext_pa)
69 rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
70 - if (!tx1_int_pa)
71 + if (tx1_ext_pa)
72 rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
73 rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
74 - rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
75 - rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
76 - rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
77 - rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
78 - rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
79 - rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
80 - rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
81 - rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
82 + rt2800_rfcsr_write(rt2x00dev, 51, (tx0_ext_pa ? 0x52 : 0x7f));
83 + rt2800_rfcsr_write(rt2x00dev, 52, (tx0_ext_pa ? 0xc0 : 0x00));
84 + rt2800_rfcsr_write(rt2x00dev, 53, (tx0_ext_pa ? 0xd2 : 0x52));
85 + rt2800_rfcsr_write(rt2x00dev, 54, (tx0_ext_pa ? 0xc0 : 0x1b));
86 + rt2800_rfcsr_write(rt2x00dev, 55, (tx1_ext_pa ? 0x52 : 0x7f));
87 + rt2800_rfcsr_write(rt2x00dev, 56, (tx1_ext_pa ? 0xc0 : 0x00));
88 + rt2800_rfcsr_write(rt2x00dev, 57, (tx0_ext_pa ? 0x49 : 0x52));
89 + rt2800_rfcsr_write(rt2x00dev, 58, (tx1_ext_pa ? 0xc0 : 0x1b));
90 rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
91 rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
92 rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
93 @@ -8782,13 +8782,13 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
94 rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
95
96 if (rt2x00_rt(rt2x00dev, RT3352)) {
97 - if (!rt2x00_get_field16(eeprom,
98 + if (rt2x00_get_field16(eeprom,
99 EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
100 - __set_bit(CAPABILITY_INTERNAL_PA_TX0,
101 + __set_bit(CAPABILITY_EXTERNAL_PA_TX0,
102 &rt2x00dev->cap_flags);
103 - if (!rt2x00_get_field16(eeprom,
104 + if (rt2x00_get_field16(eeprom,
105 EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
106 - __set_bit(CAPABILITY_INTERNAL_PA_TX1,
107 + __set_bit(CAPABILITY_EXTERNAL_PA_TX1,
108 &rt2x00dev->cap_flags);
109 }
110
111 diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
112 index 8fdd2f9726ee..1bc353eafe37 100644
113 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
114 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
115 @@ -719,8 +719,8 @@ enum rt2x00_capability_flags {
116 CAPABILITY_DOUBLE_ANTENNA,
117 CAPABILITY_BT_COEXIST,
118 CAPABILITY_VCO_RECALIBRATION,
119 - CAPABILITY_INTERNAL_PA_TX0,
120 - CAPABILITY_INTERNAL_PA_TX1,
121 + CAPABILITY_EXTERNAL_PA_TX0,
122 + CAPABILITY_EXTERNAL_PA_TX1,
123 };
124
125 /*
126 --
127 2.12.2
128