1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
8 mt76_reg_set(void *data
, u64 val
)
10 struct mt76_dev
*dev
= data
;
12 __mt76_wr(dev
, dev
->debugfs_reg
, val
);
17 mt76_reg_get(void *data
, u64
*val
)
19 struct mt76_dev
*dev
= data
;
21 *val
= __mt76_rr(dev
, dev
->debugfs_reg
);
25 DEFINE_DEBUGFS_ATTRIBUTE(fops_regval
, mt76_reg_get
, mt76_reg_set
,
29 mt76_napi_threaded_set(void *data
, u64 val
)
31 struct mt76_dev
*dev
= data
;
33 if (!mt76_is_mmio(dev
))
36 if (dev
->napi_dev
->threaded
!= val
)
37 return dev_set_threaded(dev
->napi_dev
, val
);
43 mt76_napi_threaded_get(void *data
, u64
*val
)
45 struct mt76_dev
*dev
= data
;
47 *val
= dev
->napi_dev
->threaded
;
51 DEFINE_DEBUGFS_ATTRIBUTE(fops_napi_threaded
, mt76_napi_threaded_get
,
52 mt76_napi_threaded_set
, "%llu\n");
54 int mt76_queues_read(struct seq_file
*s
, void *data
)
56 struct mt76_dev
*dev
= dev_get_drvdata(s
->private);
59 seq_puts(s
, " queue | hw-queued | head | tail |\n");
60 for (i
= 0; i
< ARRAY_SIZE(dev
->phy
.q_tx
); i
++) {
61 struct mt76_queue
*q
= dev
->phy
.q_tx
[i
];
66 seq_printf(s
, " %9d | %9d | %9d | %9d |\n",
67 i
, q
->queued
, q
->head
, q
->tail
);
72 EXPORT_SYMBOL_GPL(mt76_queues_read
);
74 static int mt76_rx_queues_read(struct seq_file
*s
, void *data
)
76 struct mt76_dev
*dev
= dev_get_drvdata(s
->private);
79 seq_puts(s
, " queue | hw-queued | head | tail |\n");
80 mt76_for_each_q_rx(dev
, i
) {
81 struct mt76_queue
*q
= &dev
->q_rx
[i
];
83 queued
= mt76_is_usb(dev
) ? q
->ndesc
- q
->queued
: q
->queued
;
84 seq_printf(s
, " %9d | %9d | %9d | %9d |\n",
85 i
, queued
, q
->head
, q
->tail
);
91 void mt76_seq_puts_array(struct seq_file
*file
, const char *str
,
96 seq_printf(file
, "%10s:", str
);
97 for (i
= 0; i
< len
; i
++)
98 seq_printf(file
, " %2d", val
[i
]);
101 EXPORT_SYMBOL_GPL(mt76_seq_puts_array
);
104 mt76_register_debugfs_fops(struct mt76_phy
*phy
,
105 const struct file_operations
*ops
)
107 const struct file_operations
*fops
= ops
? ops
: &fops_regval
;
108 struct mt76_dev
*dev
= phy
->dev
;
111 dir
= debugfs_create_dir("mt76", phy
->hw
->wiphy
->debugfsdir
);
113 debugfs_create_u8("led_pin", 0600, dir
, &phy
->leds
.pin
);
114 debugfs_create_u32("regidx", 0600, dir
, &dev
->debugfs_reg
);
115 debugfs_create_file_unsafe("regval", 0600, dir
, dev
, fops
);
116 debugfs_create_file_unsafe("napi_threaded", 0600, dir
, dev
,
117 &fops_napi_threaded
);
118 debugfs_create_blob("eeprom", 0400, dir
, &dev
->eeprom
);
120 debugfs_create_blob("otp", 0400, dir
, &dev
->otp
);
121 debugfs_create_devm_seqfile(dev
->dev
, "rx-queues", dir
,
122 mt76_rx_queues_read
);
126 EXPORT_SYMBOL_GPL(mt76_register_debugfs_fops
);