dmaengine: imx-sdma: Let the core do the device node validation
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt7601u / debugfs.c
blob991a6a729b1e166d8d8a58074af263af602999a1
1 /*
2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <linux/debugfs.h>
17 #include "mt7601u.h"
18 #include "eeprom.h"
20 static int
21 mt76_reg_set(void *data, u64 val)
23 struct mt7601u_dev *dev = data;
25 mt76_wr(dev, dev->debugfs_reg, val);
26 return 0;
29 static int
30 mt76_reg_get(void *data, u64 *val)
32 struct mt7601u_dev *dev = data;
34 *val = mt76_rr(dev, dev->debugfs_reg);
35 return 0;
38 DEFINE_SIMPLE_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set, "0x%08llx\n");
40 static int
41 mt7601u_ampdu_stat_read(struct seq_file *file, void *data)
43 struct mt7601u_dev *dev = file->private;
44 int i, j;
46 #define stat_printf(grp, off, name) \
47 seq_printf(file, #name ":\t%llu\n", dev->stats.grp[off])
49 stat_printf(rx_stat, 0, rx_crc_err);
50 stat_printf(rx_stat, 1, rx_phy_err);
51 stat_printf(rx_stat, 2, rx_false_cca);
52 stat_printf(rx_stat, 3, rx_plcp_err);
53 stat_printf(rx_stat, 4, rx_fifo_overflow);
54 stat_printf(rx_stat, 5, rx_duplicate);
56 stat_printf(tx_stat, 0, tx_fail_cnt);
57 stat_printf(tx_stat, 1, tx_bcn_cnt);
58 stat_printf(tx_stat, 2, tx_success);
59 stat_printf(tx_stat, 3, tx_retransmit);
60 stat_printf(tx_stat, 4, tx_zero_len);
61 stat_printf(tx_stat, 5, tx_underflow);
63 stat_printf(aggr_stat, 0, non_aggr_tx);
64 stat_printf(aggr_stat, 1, aggr_tx);
66 stat_printf(zero_len_del, 0, tx_zero_len_del);
67 stat_printf(zero_len_del, 1, rx_zero_len_del);
68 #undef stat_printf
70 seq_puts(file, "Aggregations stats:\n");
71 for (i = 0; i < 4; i++) {
72 for (j = 0; j < 8; j++)
73 seq_printf(file, "%08llx ",
74 dev->stats.aggr_n[i * 8 + j]);
75 seq_putc(file, '\n');
78 seq_printf(file, "recent average AMPDU len: %d\n",
79 atomic_read(&dev->avg_ampdu_len));
81 return 0;
84 static int
85 mt7601u_ampdu_stat_open(struct inode *inode, struct file *f)
87 return single_open(f, mt7601u_ampdu_stat_read, inode->i_private);
90 static const struct file_operations fops_ampdu_stat = {
91 .open = mt7601u_ampdu_stat_open,
92 .read = seq_read,
93 .llseek = seq_lseek,
94 .release = single_release,
97 static int
98 mt7601u_eeprom_param_read(struct seq_file *file, void *data)
100 struct mt7601u_dev *dev = file->private;
101 struct mt7601u_rate_power *rp = &dev->ee->power_rate_table;
102 struct tssi_data *td = &dev->ee->tssi_data;
103 int i;
105 seq_printf(file, "RF freq offset: %hhx\n", dev->ee->rf_freq_off);
106 seq_printf(file, "RSSI offset: %hhx %hhx\n",
107 dev->ee->rssi_offset[0], dev->ee->rssi_offset[1]);
108 seq_printf(file, "Reference temp: %hhx\n", dev->ee->ref_temp);
109 seq_printf(file, "LNA gain: %hhx\n", dev->ee->lna_gain);
110 seq_printf(file, "Reg channels: %hhu-%hhu\n", dev->ee->reg.start,
111 dev->ee->reg.start + dev->ee->reg.num - 1);
113 seq_puts(file, "Per rate power:\n");
114 for (i = 0; i < 2; i++)
115 seq_printf(file, "\t raw:%02hhx bw20:%02hhx bw40:%02hhx\n",
116 rp->cck[i].raw, rp->cck[i].bw20, rp->cck[i].bw40);
117 for (i = 0; i < 4; i++)
118 seq_printf(file, "\t raw:%02hhx bw20:%02hhx bw40:%02hhx\n",
119 rp->ofdm[i].raw, rp->ofdm[i].bw20, rp->ofdm[i].bw40);
120 for (i = 0; i < 4; i++)
121 seq_printf(file, "\t raw:%02hhx bw20:%02hhx bw40:%02hhx\n",
122 rp->ht[i].raw, rp->ht[i].bw20, rp->ht[i].bw40);
124 seq_puts(file, "Per channel power:\n");
125 for (i = 0; i < 7; i++)
126 seq_printf(file, "\t tx_power ch%u:%02hhx ch%u:%02hhx\n",
127 i * 2 + 1, dev->ee->chan_pwr[i * 2],
128 i * 2 + 2, dev->ee->chan_pwr[i * 2 + 1]);
130 if (!dev->ee->tssi_enabled)
131 return 0;
133 seq_puts(file, "TSSI:\n");
134 seq_printf(file, "\t slope:%02hhx\n", td->slope);
135 seq_printf(file, "\t offset=%02hhx %02hhx %02hhx\n",
136 td->offset[0], td->offset[1], td->offset[2]);
137 seq_printf(file, "\t delta_off:%08x\n", td->tx0_delta_offset);
139 return 0;
142 static int
143 mt7601u_eeprom_param_open(struct inode *inode, struct file *f)
145 return single_open(f, mt7601u_eeprom_param_read, inode->i_private);
148 static const struct file_operations fops_eeprom_param = {
149 .open = mt7601u_eeprom_param_open,
150 .read = seq_read,
151 .llseek = seq_lseek,
152 .release = single_release,
155 void mt7601u_init_debugfs(struct mt7601u_dev *dev)
157 struct dentry *dir;
159 dir = debugfs_create_dir("mt7601u", dev->hw->wiphy->debugfsdir);
160 if (!dir)
161 return;
163 debugfs_create_u8("temperature", 0400, dir, &dev->raw_temp);
164 debugfs_create_u32("temp_mode", 0400, dir, &dev->temp_mode);
166 debugfs_create_u32("regidx", 0600, dir, &dev->debugfs_reg);
167 debugfs_create_file("regval", 0600, dir, dev, &fops_regval);
168 debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat);
169 debugfs_create_file("eeprom_param", 0400, dir, dev, &fops_eeprom_param);