kernel: add missing config symbols for 4.9
[openwrt/staging/yousong.git] / package / kernel / mac80211 / patches / 611-rt2x00-rf_vals-rt3352-xtal20.patch
1 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
3 @@ -36,6 +36,7 @@
4 #include <linux/kernel.h>
5 #include <linux/module.h>
6 #include <linux/slab.h>
7 +#include <linux/clk.h>
8
9 #include "rt2x00.h"
10 #include "rt2800lib.h"
11 @@ -8183,6 +8184,27 @@ static const struct rf_channel rf_vals_5
12 {196, 83, 0, 12, 1},
13 };
14
15 +/*
16 + * RF value list for rt3xxx with Xtal20MHz
17 + * Supports: 2.4 GHz (all) (RF3322)
18 + */
19 +static const struct rf_channel rf_vals_xtal20mhz_3x[] = {
20 + {1, 0xE2, 2, 0x14},
21 + {2, 0xE3, 2, 0x14},
22 + {3, 0xE4, 2, 0x14},
23 + {4, 0xE5, 2, 0x14},
24 + {5, 0xE6, 2, 0x14},
25 + {6, 0xE7, 2, 0x14},
26 + {7, 0xE8, 2, 0x14},
27 + {8, 0xE9, 2, 0x14},
28 + {9, 0xEA, 2, 0x14},
29 + {10, 0xEB, 2, 0x14},
30 + {11, 0xEC, 2, 0x14},
31 + {12, 0xED, 2, 0x14},
32 + {13, 0xEE, 2, 0x14},
33 + {14, 0xF0, 2, 0x18},
34 +};
35 +
36 static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
37 {
38 struct hw_mode_spec *spec = &rt2x00dev->spec;
39 @@ -8273,7 +8295,10 @@ static int rt2800_probe_hw_mode(struct r
40 case RF5390:
41 case RF5392:
42 spec->num_channels = 14;
43 - spec->channels = rf_vals_3x;
44 + if (spec->clk_is_20mhz)
45 + spec->channels = rf_vals_xtal20mhz_3x;
46 + else
47 + spec->channels = rf_vals_3x;
48 break;
49
50 case RF3052:
51 @@ -8457,6 +8482,20 @@ static int rt2800_probe_rt(struct rt2x00
52 return 0;
53 }
54
55 +int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
56 +{
57 + struct hw_mode_spec *spec = &rt2x00dev->spec;
58 + struct clk *clk = clk_get(rt2x00dev->dev, NULL);
59 +
60 + if (IS_ERR(clk))
61 + return PTR_ERR(clk);
62 +
63 + if (clk_get_rate(clk) == 20000000)
64 + spec->clk_is_20mhz = 1;
65 +
66 + return 0;
67 +}
68 +
69 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
70 {
71 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
72 @@ -8499,6 +8538,15 @@ int rt2800_probe_hw(struct rt2x00_dev *r
73 rt2800_register_write(rt2x00dev, GPIO_CTRL, reg);
74
75 /*
76 + * Probe SoC clock.
77 + */
78 + if (rt2x00_is_soc(rt2x00dev)) {
79 + retval = rt2800_probe_clk(rt2x00dev);
80 + if (retval)
81 + return retval;
82 + }
83 +
84 + /*
85 * Initialize hw specifications.
86 */
87 retval = rt2800_probe_hw_mode(rt2x00dev);
88 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
89 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
90 @@ -401,6 +401,7 @@ static inline struct rt2x00_intf* vif_to
91 * @channels: Device/chipset specific channel values (See &struct rf_channel).
92 * @channels_info: Additional information for channels (See &struct channel_info).
93 * @ht: Driver HT Capabilities (See &ieee80211_sta_ht_cap).
94 + * @clk_is_20mhz: External crystal of WiSoC is 20MHz instead of 40MHz
95 */
96 struct hw_mode_spec {
97 unsigned int supported_bands;
98 @@ -417,6 +418,7 @@ struct hw_mode_spec {
99 const struct channel_info *channels_info;
100
101 struct ieee80211_sta_ht_cap ht;
102 + int clk_is_20mhz;
103 };
104
105 /*