mac80211: brcm: remove alternative DT firmware names patch
[openwrt/staging/dangole.git] / package / kernel / mac80211 / patches / ath9k / 512-ath9k_channelbw_debugfs.patch
1 --- a/drivers/net/wireless/ath/ath9k/debug.c
2 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3 @@ -1472,6 +1472,7 @@ int ath9k_init_debug(struct ath_hw *ah)
4 ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
5 ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
6 ath9k_cmn_debug_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
7 + ath9k_cmn_debug_chanbw(sc->debug.debugfs_phy, sc->sc_ah);
8
9 debugfs_create_u32("gpio_mask", 0600,
10 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
11 --- a/drivers/net/wireless/ath/ath.h
12 +++ b/drivers/net/wireless/ath/ath.h
13 @@ -153,6 +153,7 @@ struct ath_common {
14 int debug_mask;
15 enum ath_device_state state;
16 unsigned long op_flags;
17 + u32 chan_bw;
18
19 struct ath_ani ani;
20
21 @@ -181,6 +182,7 @@ struct ath_common {
22 const struct ath_ops *ops;
23 const struct ath_bus_ops *bus_ops;
24 const struct ath_ps_ops *ps_ops;
25 + const struct ieee80211_ops *ieee_ops;
26
27 bool btcoex_enabled;
28 bool disable_ani;
29 --- a/drivers/net/wireless/ath/ath9k/common.c
30 +++ b/drivers/net/wireless/ath/ath9k/common.c
31 @@ -297,11 +297,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke
32 /*
33 * Update internal channel flags.
34 */
35 -static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
36 +static void ath9k_cmn_update_ichannel(struct ath_common *common,
37 + struct ath9k_channel *ichan,
38 struct cfg80211_chan_def *chandef)
39 {
40 struct ieee80211_channel *chan = chandef->chan;
41 u16 flags = 0;
42 + int width;
43
44 ichan->channel = chan->center_freq;
45 ichan->chan = chan;
46 @@ -309,7 +311,19 @@ static void ath9k_cmn_update_ichannel(st
47 if (chan->band == NL80211_BAND_5GHZ)
48 flags |= CHANNEL_5GHZ;
49
50 - switch (chandef->width) {
51 + switch (common->chan_bw) {
52 + case 5:
53 + width = NL80211_CHAN_WIDTH_5;
54 + break;
55 + case 10:
56 + width = NL80211_CHAN_WIDTH_10;
57 + break;
58 + default:
59 + width = chandef->width;
60 + break;
61 + }
62 +
63 + switch (width) {
64 case NL80211_CHAN_WIDTH_5:
65 flags |= CHANNEL_QUARTER;
66 break;
67 @@ -342,10 +356,11 @@ struct ath9k_channel *ath9k_cmn_get_chan
68 struct cfg80211_chan_def *chandef)
69 {
70 struct ieee80211_channel *curchan = chandef->chan;
71 + struct ath_common *common = ath9k_hw_common(ah);
72 struct ath9k_channel *channel;
73
74 channel = &ah->channels[curchan->hw_value];
75 - ath9k_cmn_update_ichannel(channel, chandef);
76 + ath9k_cmn_update_ichannel(common, channel, chandef);
77
78 return channel;
79 }
80 --- a/drivers/net/wireless/ath/ath9k/common-debug.c
81 +++ b/drivers/net/wireless/ath/ath9k/common-debug.c
82 @@ -315,3 +315,55 @@ void ath9k_cmn_debug_eeprom(struct dentr
83 &fops_eeprom);
84 }
85 EXPORT_SYMBOL(ath9k_cmn_debug_eeprom);
86 +
87 +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
88 + size_t count, loff_t *ppos)
89 +{
90 + struct ath_hw *ah = file->private_data;
91 + struct ath_common *common = ath9k_hw_common(ah);
92 + char buf[32];
93 + unsigned int len;
94 +
95 + len = sprintf(buf, "0x%08x\n", common->chan_bw);
96 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
97 +}
98 +
99 +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
100 + size_t count, loff_t *ppos)
101 +{
102 + struct ath_hw *ah = file->private_data;
103 + struct ath_common *common = ath9k_hw_common(ah);
104 + unsigned long chan_bw;
105 + char buf[32];
106 + ssize_t len;
107 +
108 + len = min(count, sizeof(buf) - 1);
109 + if (copy_from_user(buf, user_buf, len))
110 + return -EFAULT;
111 +
112 + buf[len] = '\0';
113 + if (kstrtoul(buf, 0, &chan_bw))
114 + return -EINVAL;
115 +
116 + common->chan_bw = chan_bw;
117 + if (!test_bit(ATH_OP_INVALID, &common->op_flags))
118 + common->ieee_ops->config(ah->hw, IEEE80211_CONF_CHANGE_CHANNEL);
119 +
120 + return count;
121 +}
122 +
123 +static const struct file_operations fops_chanbw = {
124 + .read = read_file_chan_bw,
125 + .write = write_file_chan_bw,
126 + .open = simple_open,
127 + .owner = THIS_MODULE,
128 + .llseek = default_llseek,
129 +};
130 +
131 +void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy,
132 + struct ath_hw *ah)
133 +{
134 + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, debugfs_phy, ah,
135 + &fops_chanbw);
136 +}
137 +EXPORT_SYMBOL(ath9k_cmn_debug_chanbw);
138 --- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
139 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
140 @@ -520,6 +520,7 @@ int ath9k_htc_init_debug(struct ath_hw *
141 ath9k_cmn_debug_base_eeprom(priv->debug.debugfs_phy, priv->ah);
142 ath9k_cmn_debug_modal_eeprom(priv->debug.debugfs_phy, priv->ah);
143 ath9k_cmn_debug_eeprom(priv->debug.debugfs_phy, priv->ah);
144 + ath9k_cmn_debug_chanbw(priv->debug.debugfs_phy, priv->ah);
145
146 return 0;
147 }
148 --- a/drivers/net/wireless/ath/ath9k/common-debug.h
149 +++ b/drivers/net/wireless/ath/ath9k/common-debug.h
150 @@ -71,6 +71,8 @@ void ath9k_cmn_debug_base_eeprom(struct
151 struct ath_hw *ah);
152 void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy,
153 struct ath_hw *ah);
154 +void ath9k_cmn_debug_chanbw(struct dentry *debugfs_phy,
155 + struct ath_hw *ah);
156 void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
157 struct ath_rx_status *rs);
158 void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
159 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
160 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
161 @@ -631,6 +631,7 @@ static int ath9k_init_priv(struct ath9k_
162 priv->ah = ah;
163
164 common = ath9k_hw_common(ah);
165 + common->ieee_ops = &ath9k_htc_ops;
166 common->ops = &ah->reg_ops;
167 common->ps_ops = &ath9k_htc_ps_ops;
168 common->bus_ops = &ath9k_usb_bus_ops;
169 @@ -746,9 +747,9 @@ static void ath9k_set_hw_capab(struct at
170
171 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN |
172 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
173 - WIPHY_FLAG_HAS_CHANNEL_SWITCH;
174 -
175 - hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
176 + WIPHY_FLAG_HAS_CHANNEL_SWITCH |
177 + WIPHY_FLAG_SUPPORTS_5_10_MHZ |
178 + WIPHY_FLAG_SUPPORTS_TDLS;
179
180 hw->queues = 4;
181 hw->max_listen_interval = 1;
182 --- a/drivers/net/wireless/ath/ath9k/init.c
183 +++ b/drivers/net/wireless/ath/ath9k/init.c
184 @@ -733,6 +733,7 @@ static int ath9k_init_softc(u16 devid, s
185 if (!ath9k_is_chanctx_enabled())
186 sc->cur_chan->hw_queue_base = 0;
187
188 + common->ieee_ops = &ath9k_ops;
189 common->ops = &ah->reg_ops;
190 common->bus_ops = bus_ops;
191 common->ps_ops = &ath9k_ps_ops;