1 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
4 #include <linux/kernel.h>
5 #include <linux/module.h>
6 #include <linux/slab.h>
7 +#include <linux/clk.h>
10 #include "rt2800lib.h"
11 @@ -8183,6 +8184,27 @@ static const struct rf_channel rf_vals_5
16 + * RF value list for rt3xxx with Xtal20MHz
17 + * Supports: 2.4 GHz (all) (RF3322)
19 +static const struct rf_channel rf_vals_xtal20mhz_3x[] = {
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},
36 static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
38 struct hw_mode_spec *spec = &rt2x00dev->spec;
39 @@ -8273,7 +8295,10 @@ static int rt2800_probe_hw_mode(struct r
42 spec->num_channels = 14;
43 - spec->channels = rf_vals_3x;
44 + if (spec->clk_is_20mhz)
45 + spec->channels = rf_vals_xtal20mhz_3x;
47 + spec->channels = rf_vals_3x;
51 @@ -8457,6 +8482,20 @@ static int rt2800_probe_rt(struct rt2x00
55 +int rt2800_probe_clk(struct rt2x00_dev *rt2x00dev)
57 + struct hw_mode_spec *spec = &rt2x00dev->spec;
58 + struct clk *clk = clk_get(rt2x00dev->dev, NULL);
61 + return PTR_ERR(clk);
63 + if (clk_get_rate(clk) == 20000000)
64 + spec->clk_is_20mhz = 1;
69 int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev)
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);
78 + if (rt2x00_is_soc(rt2x00dev)) {
79 + retval = rt2800_probe_clk(rt2x00dev);
85 * Initialize hw specifications.
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
97 unsigned int supported_bands;
98 @@ -417,6 +418,7 @@ struct hw_mode_spec {
99 const struct channel_info *channels_info;
101 struct ieee80211_sta_ht_cap ht;