12be7d22fSVladimir Kondratiev /*
22be7d22fSVladimir Kondratiev  * Copyright (c) 2012 Qualcomm Atheros, Inc.
32be7d22fSVladimir Kondratiev  *
42be7d22fSVladimir Kondratiev  * Permission to use, copy, modify, and/or distribute this software for any
52be7d22fSVladimir Kondratiev  * purpose with or without fee is hereby granted, provided that the above
62be7d22fSVladimir Kondratiev  * copyright notice and this permission notice appear in all copies.
72be7d22fSVladimir Kondratiev  *
82be7d22fSVladimir Kondratiev  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
92be7d22fSVladimir Kondratiev  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
102be7d22fSVladimir Kondratiev  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
112be7d22fSVladimir Kondratiev  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
122be7d22fSVladimir Kondratiev  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
132be7d22fSVladimir Kondratiev  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
142be7d22fSVladimir Kondratiev  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
152be7d22fSVladimir Kondratiev  */
162be7d22fSVladimir Kondratiev 
172be7d22fSVladimir Kondratiev #include <linux/module.h>
182be7d22fSVladimir Kondratiev #include <linux/debugfs.h>
192be7d22fSVladimir Kondratiev #include <linux/seq_file.h>
202be7d22fSVladimir Kondratiev #include <linux/pci.h>
212be7d22fSVladimir Kondratiev #include <linux/rtnetlink.h>
222be7d22fSVladimir Kondratiev 
232be7d22fSVladimir Kondratiev #include "wil6210.h"
242be7d22fSVladimir Kondratiev #include "txrx.h"
252be7d22fSVladimir Kondratiev 
262be7d22fSVladimir Kondratiev /* Nasty hack. Better have per device instances */
272be7d22fSVladimir Kondratiev static u32 mem_addr;
282be7d22fSVladimir Kondratiev static u32 dbg_txdesc_index;
292be7d22fSVladimir Kondratiev 
302be7d22fSVladimir Kondratiev static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
312be7d22fSVladimir Kondratiev 			    const char *name, struct vring *vring)
322be7d22fSVladimir Kondratiev {
332be7d22fSVladimir Kondratiev 	void __iomem *x = wmi_addr(wil, vring->hwtail);
342be7d22fSVladimir Kondratiev 
352be7d22fSVladimir Kondratiev 	seq_printf(s, "VRING %s = {\n", name);
362be7d22fSVladimir Kondratiev 	seq_printf(s, "  pa     = 0x%016llx\n", (unsigned long long)vring->pa);
372be7d22fSVladimir Kondratiev 	seq_printf(s, "  va     = 0x%p\n", vring->va);
382be7d22fSVladimir Kondratiev 	seq_printf(s, "  size   = %d\n", vring->size);
392be7d22fSVladimir Kondratiev 	seq_printf(s, "  swtail = %d\n", vring->swtail);
402be7d22fSVladimir Kondratiev 	seq_printf(s, "  swhead = %d\n", vring->swhead);
412be7d22fSVladimir Kondratiev 	seq_printf(s, "  hwtail = [0x%08x] -> ", vring->hwtail);
422be7d22fSVladimir Kondratiev 	if (x)
432be7d22fSVladimir Kondratiev 		seq_printf(s, "0x%08x\n", ioread32(x));
442be7d22fSVladimir Kondratiev 	else
452be7d22fSVladimir Kondratiev 		seq_printf(s, "???\n");
462be7d22fSVladimir Kondratiev 
472be7d22fSVladimir Kondratiev 	if (vring->va && (vring->size < 1025)) {
482be7d22fSVladimir Kondratiev 		uint i;
492be7d22fSVladimir Kondratiev 		for (i = 0; i < vring->size; i++) {
502be7d22fSVladimir Kondratiev 			volatile struct vring_tx_desc *d = &vring->va[i].tx;
512be7d22fSVladimir Kondratiev 			if ((i % 64) == 0 && (i != 0))
522be7d22fSVladimir Kondratiev 				seq_printf(s, "\n");
532be7d22fSVladimir Kondratiev 			seq_printf(s, "%s", (d->dma.status & BIT(0)) ?
54f88f113aSVladimir Kondratiev 					"S" : (vring->ctx[i].skb ? "H" : "h"));
552be7d22fSVladimir Kondratiev 		}
562be7d22fSVladimir Kondratiev 		seq_printf(s, "\n");
572be7d22fSVladimir Kondratiev 	}
582be7d22fSVladimir Kondratiev 	seq_printf(s, "}\n");
592be7d22fSVladimir Kondratiev }
602be7d22fSVladimir Kondratiev 
612be7d22fSVladimir Kondratiev static int wil_vring_debugfs_show(struct seq_file *s, void *data)
622be7d22fSVladimir Kondratiev {
632be7d22fSVladimir Kondratiev 	uint i;
642be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
652be7d22fSVladimir Kondratiev 
662be7d22fSVladimir Kondratiev 	wil_print_vring(s, wil, "rx", &wil->vring_rx);
672be7d22fSVladimir Kondratiev 
682be7d22fSVladimir Kondratiev 	for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
692be7d22fSVladimir Kondratiev 		struct vring *vring = &(wil->vring_tx[i]);
702be7d22fSVladimir Kondratiev 		if (vring->va) {
712be7d22fSVladimir Kondratiev 			char name[10];
722be7d22fSVladimir Kondratiev 			snprintf(name, sizeof(name), "tx_%2d", i);
732be7d22fSVladimir Kondratiev 			wil_print_vring(s, wil, name, vring);
742be7d22fSVladimir Kondratiev 		}
752be7d22fSVladimir Kondratiev 	}
762be7d22fSVladimir Kondratiev 
772be7d22fSVladimir Kondratiev 	return 0;
782be7d22fSVladimir Kondratiev }
792be7d22fSVladimir Kondratiev 
802be7d22fSVladimir Kondratiev static int wil_vring_seq_open(struct inode *inode, struct file *file)
812be7d22fSVladimir Kondratiev {
822be7d22fSVladimir Kondratiev 	return single_open(file, wil_vring_debugfs_show, inode->i_private);
832be7d22fSVladimir Kondratiev }
842be7d22fSVladimir Kondratiev 
852be7d22fSVladimir Kondratiev static const struct file_operations fops_vring = {
862be7d22fSVladimir Kondratiev 	.open		= wil_vring_seq_open,
872be7d22fSVladimir Kondratiev 	.release	= single_release,
882be7d22fSVladimir Kondratiev 	.read		= seq_read,
892be7d22fSVladimir Kondratiev 	.llseek		= seq_lseek,
902be7d22fSVladimir Kondratiev };
912be7d22fSVladimir Kondratiev 
922be7d22fSVladimir Kondratiev static void wil_print_ring(struct seq_file *s, const char *prefix,
932be7d22fSVladimir Kondratiev 			   void __iomem *off)
942be7d22fSVladimir Kondratiev {
952be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
962be7d22fSVladimir Kondratiev 	struct wil6210_mbox_ring r;
972be7d22fSVladimir Kondratiev 	int rsize;
982be7d22fSVladimir Kondratiev 	uint i;
992be7d22fSVladimir Kondratiev 
1002be7d22fSVladimir Kondratiev 	wil_memcpy_fromio_32(&r, off, sizeof(r));
1012be7d22fSVladimir Kondratiev 	wil_mbox_ring_le2cpus(&r);
1022be7d22fSVladimir Kondratiev 	/*
1032be7d22fSVladimir Kondratiev 	 * we just read memory block from NIC. This memory may be
1042be7d22fSVladimir Kondratiev 	 * garbage. Check validity before using it.
1052be7d22fSVladimir Kondratiev 	 */
1062be7d22fSVladimir Kondratiev 	rsize = r.size / sizeof(struct wil6210_mbox_ring_desc);
1072be7d22fSVladimir Kondratiev 
1082be7d22fSVladimir Kondratiev 	seq_printf(s, "ring %s = {\n", prefix);
1092be7d22fSVladimir Kondratiev 	seq_printf(s, "  base = 0x%08x\n", r.base);
1102be7d22fSVladimir Kondratiev 	seq_printf(s, "  size = 0x%04x bytes -> %d entries\n", r.size, rsize);
1112be7d22fSVladimir Kondratiev 	seq_printf(s, "  tail = 0x%08x\n", r.tail);
1122be7d22fSVladimir Kondratiev 	seq_printf(s, "  head = 0x%08x\n", r.head);
1132be7d22fSVladimir Kondratiev 	seq_printf(s, "  entry size = %d\n", r.entry_size);
1142be7d22fSVladimir Kondratiev 
1152be7d22fSVladimir Kondratiev 	if (r.size % sizeof(struct wil6210_mbox_ring_desc)) {
1162be7d22fSVladimir Kondratiev 		seq_printf(s, "  ??? size is not multiple of %zd, garbage?\n",
1172be7d22fSVladimir Kondratiev 			   sizeof(struct wil6210_mbox_ring_desc));
1182be7d22fSVladimir Kondratiev 		goto out;
1192be7d22fSVladimir Kondratiev 	}
1202be7d22fSVladimir Kondratiev 
1212be7d22fSVladimir Kondratiev 	if (!wmi_addr(wil, r.base) ||
1222be7d22fSVladimir Kondratiev 	    !wmi_addr(wil, r.tail) ||
1232be7d22fSVladimir Kondratiev 	    !wmi_addr(wil, r.head)) {
1242be7d22fSVladimir Kondratiev 		seq_printf(s, "  ??? pointers are garbage?\n");
1252be7d22fSVladimir Kondratiev 		goto out;
1262be7d22fSVladimir Kondratiev 	}
1272be7d22fSVladimir Kondratiev 
1282be7d22fSVladimir Kondratiev 	for (i = 0; i < rsize; i++) {
1292be7d22fSVladimir Kondratiev 		struct wil6210_mbox_ring_desc d;
1302be7d22fSVladimir Kondratiev 		struct wil6210_mbox_hdr hdr;
1312be7d22fSVladimir Kondratiev 		size_t delta = i * sizeof(d);
1322be7d22fSVladimir Kondratiev 		void __iomem *x = wil->csr + HOSTADDR(r.base) + delta;
1332be7d22fSVladimir Kondratiev 
1342be7d22fSVladimir Kondratiev 		wil_memcpy_fromio_32(&d, x, sizeof(d));
1352be7d22fSVladimir Kondratiev 
1362be7d22fSVladimir Kondratiev 		seq_printf(s, "  [%2x] %s %s%s 0x%08x", i,
1372be7d22fSVladimir Kondratiev 			   d.sync ? "F" : "E",
1382be7d22fSVladimir Kondratiev 			   (r.tail - r.base == delta) ? "t" : " ",
1392be7d22fSVladimir Kondratiev 			   (r.head - r.base == delta) ? "h" : " ",
1402be7d22fSVladimir Kondratiev 			   le32_to_cpu(d.addr));
1412be7d22fSVladimir Kondratiev 		if (0 == wmi_read_hdr(wil, d.addr, &hdr)) {
1422be7d22fSVladimir Kondratiev 			u16 len = le16_to_cpu(hdr.len);
1432be7d22fSVladimir Kondratiev 			seq_printf(s, " -> %04x %04x %04x %02x\n",
1442be7d22fSVladimir Kondratiev 				   le16_to_cpu(hdr.seq), len,
1452be7d22fSVladimir Kondratiev 				   le16_to_cpu(hdr.type), hdr.flags);
1462be7d22fSVladimir Kondratiev 			if (len <= MAX_MBOXITEM_SIZE) {
1472be7d22fSVladimir Kondratiev 				int n = 0;
1482be7d22fSVladimir Kondratiev 				unsigned char printbuf[16 * 3 + 2];
1492be7d22fSVladimir Kondratiev 				unsigned char databuf[MAX_MBOXITEM_SIZE];
1502be7d22fSVladimir Kondratiev 				void __iomem *src = wmi_buffer(wil, d.addr) +
1512be7d22fSVladimir Kondratiev 					sizeof(struct wil6210_mbox_hdr);
1522be7d22fSVladimir Kondratiev 				/*
1532be7d22fSVladimir Kondratiev 				 * No need to check @src for validity -
1542be7d22fSVladimir Kondratiev 				 * we already validated @d.addr while
1552be7d22fSVladimir Kondratiev 				 * reading header
1562be7d22fSVladimir Kondratiev 				 */
1572be7d22fSVladimir Kondratiev 				wil_memcpy_fromio_32(databuf, src, len);
1582be7d22fSVladimir Kondratiev 				while (n < len) {
1592be7d22fSVladimir Kondratiev 					int l = min(len - n, 16);
1602be7d22fSVladimir Kondratiev 					hex_dump_to_buffer(databuf + n, l,
1612be7d22fSVladimir Kondratiev 							   16, 1, printbuf,
1622be7d22fSVladimir Kondratiev 							   sizeof(printbuf),
1632be7d22fSVladimir Kondratiev 							   false);
1642be7d22fSVladimir Kondratiev 					seq_printf(s, "      : %s\n", printbuf);
1652be7d22fSVladimir Kondratiev 					n += l;
1662be7d22fSVladimir Kondratiev 				}
1672be7d22fSVladimir Kondratiev 			}
1682be7d22fSVladimir Kondratiev 		} else {
1692be7d22fSVladimir Kondratiev 			seq_printf(s, "\n");
1702be7d22fSVladimir Kondratiev 		}
1712be7d22fSVladimir Kondratiev 	}
1722be7d22fSVladimir Kondratiev  out:
1732be7d22fSVladimir Kondratiev 	seq_printf(s, "}\n");
1742be7d22fSVladimir Kondratiev }
1752be7d22fSVladimir Kondratiev 
1762be7d22fSVladimir Kondratiev static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
1772be7d22fSVladimir Kondratiev {
1782be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
1792be7d22fSVladimir Kondratiev 
1802be7d22fSVladimir Kondratiev 	wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
1812be7d22fSVladimir Kondratiev 		       offsetof(struct wil6210_mbox_ctl, tx));
1822be7d22fSVladimir Kondratiev 	wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
1832be7d22fSVladimir Kondratiev 		       offsetof(struct wil6210_mbox_ctl, rx));
1842be7d22fSVladimir Kondratiev 
1852be7d22fSVladimir Kondratiev 	return 0;
1862be7d22fSVladimir Kondratiev }
1872be7d22fSVladimir Kondratiev 
1882be7d22fSVladimir Kondratiev static int wil_mbox_seq_open(struct inode *inode, struct file *file)
1892be7d22fSVladimir Kondratiev {
1902be7d22fSVladimir Kondratiev 	return single_open(file, wil_mbox_debugfs_show, inode->i_private);
1912be7d22fSVladimir Kondratiev }
1922be7d22fSVladimir Kondratiev 
1932be7d22fSVladimir Kondratiev static const struct file_operations fops_mbox = {
1942be7d22fSVladimir Kondratiev 	.open		= wil_mbox_seq_open,
1952be7d22fSVladimir Kondratiev 	.release	= single_release,
1962be7d22fSVladimir Kondratiev 	.read		= seq_read,
1972be7d22fSVladimir Kondratiev 	.llseek		= seq_lseek,
1982be7d22fSVladimir Kondratiev };
1992be7d22fSVladimir Kondratiev 
2002be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_set(void *data, u64 val)
2012be7d22fSVladimir Kondratiev {
2022be7d22fSVladimir Kondratiev 	iowrite32(val, (void __iomem *)data);
2032be7d22fSVladimir Kondratiev 	wmb(); /* make sure write propagated to HW */
2042be7d22fSVladimir Kondratiev 
2052be7d22fSVladimir Kondratiev 	return 0;
2062be7d22fSVladimir Kondratiev }
2072be7d22fSVladimir Kondratiev 
2082be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
2092be7d22fSVladimir Kondratiev {
2102be7d22fSVladimir Kondratiev 	*val = ioread32((void __iomem *)data);
2112be7d22fSVladimir Kondratiev 
2122be7d22fSVladimir Kondratiev 	return 0;
2132be7d22fSVladimir Kondratiev }
2142be7d22fSVladimir Kondratiev 
2152be7d22fSVladimir Kondratiev DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
2162be7d22fSVladimir Kondratiev 			wil_debugfs_iomem_x32_set, "0x%08llx\n");
2172be7d22fSVladimir Kondratiev 
2182be7d22fSVladimir Kondratiev static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
2190ecc833bSAl Viro 						   umode_t mode,
2202be7d22fSVladimir Kondratiev 						   struct dentry *parent,
2212be7d22fSVladimir Kondratiev 						   void __iomem *value)
2222be7d22fSVladimir Kondratiev {
2232be7d22fSVladimir Kondratiev 	return debugfs_create_file(name, mode, parent, (void * __force)value,
2242be7d22fSVladimir Kondratiev 				   &fops_iomem_x32);
2252be7d22fSVladimir Kondratiev }
2262be7d22fSVladimir Kondratiev 
2272be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
2282be7d22fSVladimir Kondratiev 				      const char *name,
2292be7d22fSVladimir Kondratiev 				      struct dentry *parent, u32 off)
2302be7d22fSVladimir Kondratiev {
2312be7d22fSVladimir Kondratiev 	struct dentry *d = debugfs_create_dir(name, parent);
2322be7d22fSVladimir Kondratiev 
2332be7d22fSVladimir Kondratiev 	if (IS_ERR_OR_NULL(d))
2342be7d22fSVladimir Kondratiev 		return -ENODEV;
2352be7d22fSVladimir Kondratiev 
2362be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("ICC", S_IRUGO | S_IWUSR, d,
2372be7d22fSVladimir Kondratiev 				     wil->csr + off);
2382be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("ICR", S_IRUGO | S_IWUSR, d,
2392be7d22fSVladimir Kondratiev 				     wil->csr + off + 4);
2402be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("ICM", S_IRUGO | S_IWUSR, d,
2412be7d22fSVladimir Kondratiev 				     wil->csr + off + 8);
2422be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("ICS", S_IWUSR, d,
2432be7d22fSVladimir Kondratiev 				     wil->csr + off + 12);
2442be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("IMV", S_IRUGO | S_IWUSR, d,
2452be7d22fSVladimir Kondratiev 				     wil->csr + off + 16);
2462be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("IMS", S_IWUSR, d,
2472be7d22fSVladimir Kondratiev 				     wil->csr + off + 20);
2482be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("IMC", S_IWUSR, d,
2492be7d22fSVladimir Kondratiev 				     wil->csr + off + 24);
2502be7d22fSVladimir Kondratiev 
2512be7d22fSVladimir Kondratiev 	return 0;
2522be7d22fSVladimir Kondratiev }
2532be7d22fSVladimir Kondratiev 
2542be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
2552be7d22fSVladimir Kondratiev 					     struct dentry *parent)
2562be7d22fSVladimir Kondratiev {
2572be7d22fSVladimir Kondratiev 	struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent);
2582be7d22fSVladimir Kondratiev 
2592be7d22fSVladimir Kondratiev 	if (IS_ERR_OR_NULL(d))
2602be7d22fSVladimir Kondratiev 		return -ENODEV;
2612be7d22fSVladimir Kondratiev 
2622be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("CAUSE", S_IRUGO, d, wil->csr +
2632be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_PSEUDO_CAUSE));
2642be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("MASK_SW", S_IRUGO, d, wil->csr +
2652be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW));
2662be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("MASK_FW", S_IRUGO, d, wil->csr +
2672be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW));
2682be7d22fSVladimir Kondratiev 
2692be7d22fSVladimir Kondratiev 	return 0;
2702be7d22fSVladimir Kondratiev }
2712be7d22fSVladimir Kondratiev 
2722be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
2732be7d22fSVladimir Kondratiev 					  struct dentry *parent)
2742be7d22fSVladimir Kondratiev {
2752be7d22fSVladimir Kondratiev 	struct dentry *d = debugfs_create_dir("ITR_CNT", parent);
2762be7d22fSVladimir Kondratiev 
2772be7d22fSVladimir Kondratiev 	if (IS_ERR_OR_NULL(d))
2782be7d22fSVladimir Kondratiev 		return -ENODEV;
2792be7d22fSVladimir Kondratiev 
2802be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("TRSH", S_IRUGO, d, wil->csr +
2812be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
2822be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("DATA", S_IRUGO, d, wil->csr +
2832be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_ITR_CNT_DATA));
2842be7d22fSVladimir Kondratiev 	wil_debugfs_create_iomem_x32("CTL", S_IRUGO, d, wil->csr +
2852be7d22fSVladimir Kondratiev 				     HOSTADDR(RGF_DMA_ITR_CNT_CRL));
2862be7d22fSVladimir Kondratiev 
2872be7d22fSVladimir Kondratiev 	return 0;
2882be7d22fSVladimir Kondratiev }
2892be7d22fSVladimir Kondratiev 
2902be7d22fSVladimir Kondratiev static int wil_memread_debugfs_show(struct seq_file *s, void *data)
2912be7d22fSVladimir Kondratiev {
2922be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
2932be7d22fSVladimir Kondratiev 	void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
2942be7d22fSVladimir Kondratiev 
2952be7d22fSVladimir Kondratiev 	if (a)
2962be7d22fSVladimir Kondratiev 		seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, ioread32(a));
2972be7d22fSVladimir Kondratiev 	else
2982be7d22fSVladimir Kondratiev 		seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
2992be7d22fSVladimir Kondratiev 
3002be7d22fSVladimir Kondratiev 	return 0;
3012be7d22fSVladimir Kondratiev }
3022be7d22fSVladimir Kondratiev 
3032be7d22fSVladimir Kondratiev static int wil_memread_seq_open(struct inode *inode, struct file *file)
3042be7d22fSVladimir Kondratiev {
3052be7d22fSVladimir Kondratiev 	return single_open(file, wil_memread_debugfs_show, inode->i_private);
3062be7d22fSVladimir Kondratiev }
3072be7d22fSVladimir Kondratiev 
3082be7d22fSVladimir Kondratiev static const struct file_operations fops_memread = {
3092be7d22fSVladimir Kondratiev 	.open		= wil_memread_seq_open,
3102be7d22fSVladimir Kondratiev 	.release	= single_release,
3112be7d22fSVladimir Kondratiev 	.read		= seq_read,
3122be7d22fSVladimir Kondratiev 	.llseek		= seq_lseek,
3132be7d22fSVladimir Kondratiev };
3142be7d22fSVladimir Kondratiev 
3152be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
3162be7d22fSVladimir Kondratiev 				size_t count, loff_t *ppos)
3172be7d22fSVladimir Kondratiev {
3182be7d22fSVladimir Kondratiev 	enum { max_count = 4096 };
3192be7d22fSVladimir Kondratiev 	struct debugfs_blob_wrapper *blob = file->private_data;
3202be7d22fSVladimir Kondratiev 	loff_t pos = *ppos;
3212be7d22fSVladimir Kondratiev 	size_t available = blob->size;
3222be7d22fSVladimir Kondratiev 	void *buf;
3232be7d22fSVladimir Kondratiev 	size_t ret;
3242be7d22fSVladimir Kondratiev 
3252be7d22fSVladimir Kondratiev 	if (pos < 0)
3262be7d22fSVladimir Kondratiev 		return -EINVAL;
3272be7d22fSVladimir Kondratiev 
3282be7d22fSVladimir Kondratiev 	if (pos >= available || !count)
3292be7d22fSVladimir Kondratiev 		return 0;
3302be7d22fSVladimir Kondratiev 
3312be7d22fSVladimir Kondratiev 	if (count > available - pos)
3322be7d22fSVladimir Kondratiev 		count = available - pos;
3332be7d22fSVladimir Kondratiev 	if (count > max_count)
3342be7d22fSVladimir Kondratiev 		count = max_count;
3352be7d22fSVladimir Kondratiev 
3362be7d22fSVladimir Kondratiev 	buf = kmalloc(count, GFP_KERNEL);
3372be7d22fSVladimir Kondratiev 	if (!buf)
3382be7d22fSVladimir Kondratiev 		return -ENOMEM;
3392be7d22fSVladimir Kondratiev 
3402be7d22fSVladimir Kondratiev 	wil_memcpy_fromio_32(buf, (const volatile void __iomem *)blob->data +
3412be7d22fSVladimir Kondratiev 			     pos, count);
3422be7d22fSVladimir Kondratiev 
3432be7d22fSVladimir Kondratiev 	ret = copy_to_user(user_buf, buf, count);
3442be7d22fSVladimir Kondratiev 	kfree(buf);
3452be7d22fSVladimir Kondratiev 	if (ret == count)
3462be7d22fSVladimir Kondratiev 		return -EFAULT;
3472be7d22fSVladimir Kondratiev 
3482be7d22fSVladimir Kondratiev 	count -= ret;
3492be7d22fSVladimir Kondratiev 	*ppos = pos + count;
3502be7d22fSVladimir Kondratiev 
3512be7d22fSVladimir Kondratiev 	return count;
3522be7d22fSVladimir Kondratiev }
3532be7d22fSVladimir Kondratiev 
3542be7d22fSVladimir Kondratiev static const struct file_operations fops_ioblob = {
3552be7d22fSVladimir Kondratiev 	.read =		wil_read_file_ioblob,
35693ecbd64SWei Yongjun 	.open =		simple_open,
3572be7d22fSVladimir Kondratiev 	.llseek =	default_llseek,
3582be7d22fSVladimir Kondratiev };
3592be7d22fSVladimir Kondratiev 
3602be7d22fSVladimir Kondratiev static
3612be7d22fSVladimir Kondratiev struct dentry *wil_debugfs_create_ioblob(const char *name,
3620ecc833bSAl Viro 					 umode_t mode,
3632be7d22fSVladimir Kondratiev 					 struct dentry *parent,
3642be7d22fSVladimir Kondratiev 					 struct debugfs_blob_wrapper *blob)
3652be7d22fSVladimir Kondratiev {
3662be7d22fSVladimir Kondratiev 	return debugfs_create_file(name, mode, parent, blob, &fops_ioblob);
3672be7d22fSVladimir Kondratiev }
3682be7d22fSVladimir Kondratiev /*---reset---*/
3692be7d22fSVladimir Kondratiev static ssize_t wil_write_file_reset(struct file *file, const char __user *buf,
3702be7d22fSVladimir Kondratiev 				    size_t len, loff_t *ppos)
3712be7d22fSVladimir Kondratiev {
3722be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = file->private_data;
3732be7d22fSVladimir Kondratiev 	struct net_device *ndev = wil_to_ndev(wil);
3742be7d22fSVladimir Kondratiev 
3752be7d22fSVladimir Kondratiev 	/**
3762be7d22fSVladimir Kondratiev 	 * BUG:
3772be7d22fSVladimir Kondratiev 	 * this code does NOT sync device state with the rest of system
3782be7d22fSVladimir Kondratiev 	 * use with care, debug only!!!
3792be7d22fSVladimir Kondratiev 	 */
3802be7d22fSVladimir Kondratiev 	rtnl_lock();
3812be7d22fSVladimir Kondratiev 	dev_close(ndev);
3822be7d22fSVladimir Kondratiev 	ndev->flags &= ~IFF_UP;
3832be7d22fSVladimir Kondratiev 	rtnl_unlock();
3842be7d22fSVladimir Kondratiev 	wil_reset(wil);
3852be7d22fSVladimir Kondratiev 
3862be7d22fSVladimir Kondratiev 	return len;
3872be7d22fSVladimir Kondratiev }
3882be7d22fSVladimir Kondratiev 
3892be7d22fSVladimir Kondratiev static const struct file_operations fops_reset = {
3902be7d22fSVladimir Kondratiev 	.write = wil_write_file_reset,
39193ecbd64SWei Yongjun 	.open  = simple_open,
3922be7d22fSVladimir Kondratiev };
3932be7d22fSVladimir Kondratiev /*---------Tx descriptor------------*/
3942be7d22fSVladimir Kondratiev 
3952be7d22fSVladimir Kondratiev static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
3962be7d22fSVladimir Kondratiev {
3972be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
3982be7d22fSVladimir Kondratiev 	struct vring *vring = &(wil->vring_tx[0]);
3992be7d22fSVladimir Kondratiev 
4002be7d22fSVladimir Kondratiev 	if (!vring->va) {
4012be7d22fSVladimir Kondratiev 		seq_printf(s, "No Tx VRING\n");
4022be7d22fSVladimir Kondratiev 		return 0;
4032be7d22fSVladimir Kondratiev 	}
4042be7d22fSVladimir Kondratiev 
4052be7d22fSVladimir Kondratiev 	if (dbg_txdesc_index < vring->size) {
4062be7d22fSVladimir Kondratiev 		volatile struct vring_tx_desc *d =
4072be7d22fSVladimir Kondratiev 				&(vring->va[dbg_txdesc_index].tx);
4082be7d22fSVladimir Kondratiev 		volatile u32 *u = (volatile u32 *)d;
409f88f113aSVladimir Kondratiev 		struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
4102be7d22fSVladimir Kondratiev 
4112be7d22fSVladimir Kondratiev 		seq_printf(s, "Tx[%3d] = {\n", dbg_txdesc_index);
4122be7d22fSVladimir Kondratiev 		seq_printf(s, "  MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n",
4132be7d22fSVladimir Kondratiev 			   u[0], u[1], u[2], u[3]);
4142be7d22fSVladimir Kondratiev 		seq_printf(s, "  DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n",
4152be7d22fSVladimir Kondratiev 			   u[4], u[5], u[6], u[7]);
4162be7d22fSVladimir Kondratiev 		seq_printf(s, "  SKB = %p\n", skb);
4172be7d22fSVladimir Kondratiev 
4182be7d22fSVladimir Kondratiev 		if (skb) {
4192be7d22fSVladimir Kondratiev 			unsigned char printbuf[16 * 3 + 2];
4202be7d22fSVladimir Kondratiev 			int i = 0;
4217e594444SVladimir Kondratiev 			int len = le16_to_cpu(d->dma.length);
4222be7d22fSVladimir Kondratiev 			void *p = skb->data;
4232be7d22fSVladimir Kondratiev 
4247e594444SVladimir Kondratiev 			if (len != skb_headlen(skb)) {
4257e594444SVladimir Kondratiev 				seq_printf(s, "!!! len: desc = %d skb = %d\n",
4267e594444SVladimir Kondratiev 					   len, skb_headlen(skb));
4277e594444SVladimir Kondratiev 				len = min_t(int, len, skb_headlen(skb));
4287e594444SVladimir Kondratiev 			}
4297e594444SVladimir Kondratiev 
4302be7d22fSVladimir Kondratiev 			seq_printf(s, "    len = %d\n", len);
4312be7d22fSVladimir Kondratiev 
4322be7d22fSVladimir Kondratiev 			while (i < len) {
4332be7d22fSVladimir Kondratiev 				int l = min(len - i, 16);
4342be7d22fSVladimir Kondratiev 				hex_dump_to_buffer(p + i, l, 16, 1, printbuf,
4352be7d22fSVladimir Kondratiev 						   sizeof(printbuf), false);
4362be7d22fSVladimir Kondratiev 				seq_printf(s, "      : %s\n", printbuf);
4372be7d22fSVladimir Kondratiev 				i += l;
4382be7d22fSVladimir Kondratiev 			}
4392be7d22fSVladimir Kondratiev 		}
4402be7d22fSVladimir Kondratiev 		seq_printf(s, "}\n");
4412be7d22fSVladimir Kondratiev 	} else {
4422be7d22fSVladimir Kondratiev 		seq_printf(s, "TxDesc index (%d) >= size (%d)\n",
4432be7d22fSVladimir Kondratiev 			   dbg_txdesc_index, vring->size);
4442be7d22fSVladimir Kondratiev 	}
4452be7d22fSVladimir Kondratiev 
4462be7d22fSVladimir Kondratiev 	return 0;
4472be7d22fSVladimir Kondratiev }
4482be7d22fSVladimir Kondratiev 
4492be7d22fSVladimir Kondratiev static int wil_txdesc_seq_open(struct inode *inode, struct file *file)
4502be7d22fSVladimir Kondratiev {
4512be7d22fSVladimir Kondratiev 	return single_open(file, wil_txdesc_debugfs_show, inode->i_private);
4522be7d22fSVladimir Kondratiev }
4532be7d22fSVladimir Kondratiev 
4542be7d22fSVladimir Kondratiev static const struct file_operations fops_txdesc = {
4552be7d22fSVladimir Kondratiev 	.open		= wil_txdesc_seq_open,
4562be7d22fSVladimir Kondratiev 	.release	= single_release,
4572be7d22fSVladimir Kondratiev 	.read		= seq_read,
4582be7d22fSVladimir Kondratiev 	.llseek		= seq_lseek,
4592be7d22fSVladimir Kondratiev };
4602be7d22fSVladimir Kondratiev 
4612be7d22fSVladimir Kondratiev /*---------beamforming------------*/
4622be7d22fSVladimir Kondratiev static int wil_bf_debugfs_show(struct seq_file *s, void *data)
4632be7d22fSVladimir Kondratiev {
4642be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
4652be7d22fSVladimir Kondratiev 	seq_printf(s,
4662be7d22fSVladimir Kondratiev 		   "TSF : 0x%016llx\n"
4672be7d22fSVladimir Kondratiev 		   "TxMCS : %d\n"
4682be7d22fSVladimir Kondratiev 		   "Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n",
4692be7d22fSVladimir Kondratiev 		   wil->stats.tsf, wil->stats.bf_mcs,
4702be7d22fSVladimir Kondratiev 		   wil->stats.my_rx_sector, wil->stats.my_tx_sector,
4712be7d22fSVladimir Kondratiev 		   wil->stats.peer_rx_sector, wil->stats.peer_tx_sector);
4722be7d22fSVladimir Kondratiev 	return 0;
4732be7d22fSVladimir Kondratiev }
4742be7d22fSVladimir Kondratiev 
4752be7d22fSVladimir Kondratiev static int wil_bf_seq_open(struct inode *inode, struct file *file)
4762be7d22fSVladimir Kondratiev {
4772be7d22fSVladimir Kondratiev 	return single_open(file, wil_bf_debugfs_show, inode->i_private);
4782be7d22fSVladimir Kondratiev }
4792be7d22fSVladimir Kondratiev 
4802be7d22fSVladimir Kondratiev static const struct file_operations fops_bf = {
4812be7d22fSVladimir Kondratiev 	.open		= wil_bf_seq_open,
4822be7d22fSVladimir Kondratiev 	.release	= single_release,
4832be7d22fSVladimir Kondratiev 	.read		= seq_read,
4842be7d22fSVladimir Kondratiev 	.llseek		= seq_lseek,
4852be7d22fSVladimir Kondratiev };
4862be7d22fSVladimir Kondratiev /*---------SSID------------*/
4872be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf,
4882be7d22fSVladimir Kondratiev 				  size_t count, loff_t *ppos)
4892be7d22fSVladimir Kondratiev {
4902be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = file->private_data;
4912be7d22fSVladimir Kondratiev 	struct wireless_dev *wdev = wil_to_wdev(wil);
4922be7d22fSVladimir Kondratiev 
4932be7d22fSVladimir Kondratiev 	return simple_read_from_buffer(user_buf, count, ppos,
4942be7d22fSVladimir Kondratiev 				       wdev->ssid, wdev->ssid_len);
4952be7d22fSVladimir Kondratiev }
4962be7d22fSVladimir Kondratiev 
4972be7d22fSVladimir Kondratiev static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
4982be7d22fSVladimir Kondratiev 				   size_t count, loff_t *ppos)
4992be7d22fSVladimir Kondratiev {
5002be7d22fSVladimir Kondratiev 	struct wil6210_priv *wil = file->private_data;
5012be7d22fSVladimir Kondratiev 	struct wireless_dev *wdev = wil_to_wdev(wil);
5022be7d22fSVladimir Kondratiev 	struct net_device *ndev = wil_to_ndev(wil);
5032be7d22fSVladimir Kondratiev 
5042be7d22fSVladimir Kondratiev 	if (*ppos != 0) {
5052be7d22fSVladimir Kondratiev 		wil_err(wil, "Unable to set SSID substring from [%d]\n",
5062be7d22fSVladimir Kondratiev 			(int)*ppos);
5072be7d22fSVladimir Kondratiev 		return -EINVAL;
5082be7d22fSVladimir Kondratiev 	}
5092be7d22fSVladimir Kondratiev 
5102be7d22fSVladimir Kondratiev 	if (count > sizeof(wdev->ssid)) {
5112be7d22fSVladimir Kondratiev 		wil_err(wil, "SSID too long, len = %d\n", (int)count);
5122be7d22fSVladimir Kondratiev 		return -EINVAL;
5132be7d22fSVladimir Kondratiev 	}
5142be7d22fSVladimir Kondratiev 	if (netif_running(ndev)) {
5152be7d22fSVladimir Kondratiev 		wil_err(wil, "Unable to change SSID on running interface\n");
5162be7d22fSVladimir Kondratiev 		return -EINVAL;
5172be7d22fSVladimir Kondratiev 	}
5182be7d22fSVladimir Kondratiev 
5192be7d22fSVladimir Kondratiev 	wdev->ssid_len = count;
5202be7d22fSVladimir Kondratiev 	return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
5212be7d22fSVladimir Kondratiev 				      buf, count);
5222be7d22fSVladimir Kondratiev }
5232be7d22fSVladimir Kondratiev 
5242be7d22fSVladimir Kondratiev static const struct file_operations fops_ssid = {
5252be7d22fSVladimir Kondratiev 	.read = wil_read_file_ssid,
5262be7d22fSVladimir Kondratiev 	.write = wil_write_file_ssid,
52793ecbd64SWei Yongjun 	.open  = simple_open,
5282be7d22fSVladimir Kondratiev };
5292be7d22fSVladimir Kondratiev 
5301a2780e0SVladimir Kondratiev /*---------temp------------*/
5311a2780e0SVladimir Kondratiev static void print_temp(struct seq_file *s, const char *prefix, u32 t)
5321a2780e0SVladimir Kondratiev {
5331a2780e0SVladimir Kondratiev 	switch (t) {
5341a2780e0SVladimir Kondratiev 	case 0:
5351a2780e0SVladimir Kondratiev 	case ~(u32)0:
5361a2780e0SVladimir Kondratiev 		seq_printf(s, "%s N/A\n", prefix);
5371a2780e0SVladimir Kondratiev 	break;
5381a2780e0SVladimir Kondratiev 	default:
5391a2780e0SVladimir Kondratiev 		seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
5401a2780e0SVladimir Kondratiev 		break;
5411a2780e0SVladimir Kondratiev 	}
5421a2780e0SVladimir Kondratiev }
5431a2780e0SVladimir Kondratiev 
5441a2780e0SVladimir Kondratiev static int wil_temp_debugfs_show(struct seq_file *s, void *data)
5451a2780e0SVladimir Kondratiev {
5461a2780e0SVladimir Kondratiev 	struct wil6210_priv *wil = s->private;
5471a2780e0SVladimir Kondratiev 	u32 t_m, t_r;
5481a2780e0SVladimir Kondratiev 
5491a2780e0SVladimir Kondratiev 	int rc = wmi_get_temperature(wil, &t_m, &t_r);
5501a2780e0SVladimir Kondratiev 	if (rc) {
5511a2780e0SVladimir Kondratiev 		seq_printf(s, "Failed\n");
5521a2780e0SVladimir Kondratiev 		return 0;
5531a2780e0SVladimir Kondratiev 	}
5541a2780e0SVladimir Kondratiev 
5551a2780e0SVladimir Kondratiev 	print_temp(s, "MAC temperature   :", t_m);
5561a2780e0SVladimir Kondratiev 	print_temp(s, "Radio temperature :", t_r);
5571a2780e0SVladimir Kondratiev 
5581a2780e0SVladimir Kondratiev 	return 0;
5591a2780e0SVladimir Kondratiev }
5601a2780e0SVladimir Kondratiev 
5611a2780e0SVladimir Kondratiev static int wil_temp_seq_open(struct inode *inode, struct file *file)
5621a2780e0SVladimir Kondratiev {
5631a2780e0SVladimir Kondratiev 	return single_open(file, wil_temp_debugfs_show, inode->i_private);
5641a2780e0SVladimir Kondratiev }
5651a2780e0SVladimir Kondratiev 
5661a2780e0SVladimir Kondratiev static const struct file_operations fops_temp = {
5671a2780e0SVladimir Kondratiev 	.open		= wil_temp_seq_open,
5681a2780e0SVladimir Kondratiev 	.release	= single_release,
5691a2780e0SVladimir Kondratiev 	.read		= seq_read,
5701a2780e0SVladimir Kondratiev 	.llseek		= seq_lseek,
5711a2780e0SVladimir Kondratiev };
5721a2780e0SVladimir Kondratiev 
5732be7d22fSVladimir Kondratiev /*----------------*/
5742be7d22fSVladimir Kondratiev int wil6210_debugfs_init(struct wil6210_priv *wil)
5752be7d22fSVladimir Kondratiev {
5762be7d22fSVladimir Kondratiev 	struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
5772be7d22fSVladimir Kondratiev 			wil_to_wiphy(wil)->debugfsdir);
5782be7d22fSVladimir Kondratiev 
5792be7d22fSVladimir Kondratiev 	if (IS_ERR_OR_NULL(dbg))
5802be7d22fSVladimir Kondratiev 		return -ENODEV;
5812be7d22fSVladimir Kondratiev 
5822be7d22fSVladimir Kondratiev 	debugfs_create_file("mbox", S_IRUGO, dbg, wil, &fops_mbox);
5832be7d22fSVladimir Kondratiev 	debugfs_create_file("vrings", S_IRUGO, dbg, wil, &fops_vring);
5842be7d22fSVladimir Kondratiev 	debugfs_create_file("txdesc", S_IRUGO, dbg, wil, &fops_txdesc);
5852be7d22fSVladimir Kondratiev 	debugfs_create_u32("txdesc_index", S_IRUGO | S_IWUSR, dbg,
5862be7d22fSVladimir Kondratiev 			   &dbg_txdesc_index);
5872be7d22fSVladimir Kondratiev 	debugfs_create_file("bf", S_IRUGO, dbg, wil, &fops_bf);
5882be7d22fSVladimir Kondratiev 	debugfs_create_file("ssid", S_IRUGO | S_IWUSR, dbg, wil, &fops_ssid);
5892be7d22fSVladimir Kondratiev 	debugfs_create_u32("secure_pcp", S_IRUGO | S_IWUSR, dbg,
5902be7d22fSVladimir Kondratiev 			   &wil->secure_pcp);
5912be7d22fSVladimir Kondratiev 
5922be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_ISR(wil, "USER_ICR", dbg,
5932be7d22fSVladimir Kondratiev 				   HOSTADDR(RGF_USER_USER_ICR));
5942be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_ISR(wil, "DMA_EP_TX_ICR", dbg,
5952be7d22fSVladimir Kondratiev 				   HOSTADDR(RGF_DMA_EP_TX_ICR));
5962be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_ISR(wil, "DMA_EP_RX_ICR", dbg,
5972be7d22fSVladimir Kondratiev 				   HOSTADDR(RGF_DMA_EP_RX_ICR));
5982be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_ISR(wil, "DMA_EP_MISC_ICR", dbg,
5992be7d22fSVladimir Kondratiev 				   HOSTADDR(RGF_DMA_EP_MISC_ICR));
6002be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_pseudo_ISR(wil, dbg);
6012be7d22fSVladimir Kondratiev 	wil6210_debugfs_create_ITR_CNT(wil, dbg);
6022be7d22fSVladimir Kondratiev 
6032be7d22fSVladimir Kondratiev 	debugfs_create_u32("mem_addr", S_IRUGO | S_IWUSR, dbg, &mem_addr);
6042be7d22fSVladimir Kondratiev 	debugfs_create_file("mem_val", S_IRUGO, dbg, wil, &fops_memread);
6052be7d22fSVladimir Kondratiev 
6062be7d22fSVladimir Kondratiev 	debugfs_create_file("reset", S_IWUSR, dbg, wil, &fops_reset);
6071a2780e0SVladimir Kondratiev 	debugfs_create_file("temp", S_IRUGO, dbg, wil, &fops_temp);
6082be7d22fSVladimir Kondratiev 
6092be7d22fSVladimir Kondratiev 	wil->rgf_blob.data = (void * __force)wil->csr + 0;
6102be7d22fSVladimir Kondratiev 	wil->rgf_blob.size = 0xa000;
6112be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_rgf", S_IRUGO, dbg, &wil->rgf_blob);
6122be7d22fSVladimir Kondratiev 
6132be7d22fSVladimir Kondratiev 	wil->fw_code_blob.data = (void * __force)wil->csr + 0x40000;
6142be7d22fSVladimir Kondratiev 	wil->fw_code_blob.size = 0x40000;
6152be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_fw_code", S_IRUGO, dbg,
6162be7d22fSVladimir Kondratiev 				  &wil->fw_code_blob);
6172be7d22fSVladimir Kondratiev 
6182be7d22fSVladimir Kondratiev 	wil->fw_data_blob.data = (void * __force)wil->csr + 0x80000;
6192be7d22fSVladimir Kondratiev 	wil->fw_data_blob.size = 0x8000;
6202be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_fw_data", S_IRUGO, dbg,
6212be7d22fSVladimir Kondratiev 				  &wil->fw_data_blob);
6222be7d22fSVladimir Kondratiev 
6232be7d22fSVladimir Kondratiev 	wil->fw_peri_blob.data = (void * __force)wil->csr + 0x88000;
6242be7d22fSVladimir Kondratiev 	wil->fw_peri_blob.size = 0x18000;
6252be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_fw_peri", S_IRUGO, dbg,
6262be7d22fSVladimir Kondratiev 				  &wil->fw_peri_blob);
6272be7d22fSVladimir Kondratiev 
6282be7d22fSVladimir Kondratiev 	wil->uc_code_blob.data = (void * __force)wil->csr + 0xa0000;
6292be7d22fSVladimir Kondratiev 	wil->uc_code_blob.size = 0x10000;
6302be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_uc_code", S_IRUGO, dbg,
6312be7d22fSVladimir Kondratiev 				  &wil->uc_code_blob);
6322be7d22fSVladimir Kondratiev 
6332be7d22fSVladimir Kondratiev 	wil->uc_data_blob.data = (void * __force)wil->csr + 0xb0000;
6342be7d22fSVladimir Kondratiev 	wil->uc_data_blob.size = 0x4000;
6352be7d22fSVladimir Kondratiev 	wil_debugfs_create_ioblob("blob_uc_data", S_IRUGO, dbg,
6362be7d22fSVladimir Kondratiev 				  &wil->uc_data_blob);
6372be7d22fSVladimir Kondratiev 
6382be7d22fSVladimir Kondratiev 	return 0;
6392be7d22fSVladimir Kondratiev }
6402be7d22fSVladimir Kondratiev 
6412be7d22fSVladimir Kondratiev void wil6210_debugfs_remove(struct wil6210_priv *wil)
6422be7d22fSVladimir Kondratiev {
6432be7d22fSVladimir Kondratiev 	debugfs_remove_recursive(wil->debug);
6442be7d22fSVladimir Kondratiev 	wil->debug = NULL;
6452be7d22fSVladimir Kondratiev }
646