linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch.de>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, bcm43xx-dev@lists.berlios.de,
	Larry Finger <larry.finger@lwfinger.net>
Subject: [patch 4/7] b43: Add debugfs file to extract LO calibration data
Date: Fri, 24 Aug 2007 00:21:57 +0200	[thread overview]
Message-ID: <20070823222155.727360000@bu3sch.de> (raw)
In-Reply-To: 20070823222153.073035000@bu3sch.de

Add a file to debugfs to extract the Local Oscillator
calibration data.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Cc: Larry Finger <larry.finger@lwfinger.net>

Index: wireless-dev-new/drivers/net/wireless/b43/debugfs.c
===================================================================
--- wireless-dev-new.orig/drivers/net/wireless/b43/debugfs.c	2007-08-22 00:42:34.000000000 +0200
+++ wireless-dev-new/drivers/net/wireless/b43/debugfs.c	2007-08-22 01:38:36.000000000 +0200
@@ -374,6 +374,88 @@ static ssize_t txpower_g_write_file(stru
 	return res;
 }
 
+static size_t append_lo_table(size_t pos, char *buf, const size_t len,
+			      struct b43_loctl table[B43_NR_BB][B43_NR_RF])
+{
+	unsigned int i, j;
+	struct b43_loctl *ctl;
+
+	for (i = 0; i < B43_NR_BB; i++) {
+		for (j = 0; j < B43_NR_RF; j++) {
+			ctl = &(table[i][j]);
+			fappend("(bbatt %2u, rfatt %2u)  ->  "
+				"(I %+3d, Q %+3d, Used: %d, Calibrated: %d)\n",
+				i, j, ctl->i, ctl->q,
+				ctl->used,
+				b43_loctl_is_calibrated(ctl));
+		}
+	}
+
+	return pos;
+}
+
+static ssize_t loctls_read_file(struct file *file, char __user *userbuf,
+				size_t count, loff_t *ppos)
+{
+	struct b43_wldev *dev = file->private_data;
+	const size_t len = ARRAY_SIZE(big_buffer);
+	char *buf = big_buffer;
+	size_t pos = 0;
+	ssize_t res;
+	unsigned long flags;
+	struct b43_txpower_lo_control *lo;
+	unsigned int i;
+
+	mutex_lock(&big_buffer_mutex);
+	mutex_lock(&dev->wl->mutex);
+	spin_lock_irqsave(&dev->wl->irq_lock, flags);
+	if (b43_status(dev) < B43_STAT_INITIALIZED) {
+		fappend("Not initialized\n");
+		goto out;
+	}
+	if (dev->phy.type != B43_PHYTYPE_G) {
+		fappend("Device is not a G-PHY\n");
+		goto out;
+	}
+
+	lo = dev->phy.lo_control;
+	fappend("-- Local Oscillator calibration data --\n\n");
+	fappend("Measured: %d,  Rebuild: %d,  HW-power-control: %d\n",
+		lo->lo_measured,
+		lo->rebuild,
+		dev->phy.hardware_power_control);
+	fappend("TX Bias: 0x%02X,  TX Magn: 0x%02X\n",
+		lo->tx_bias, lo->tx_magn);
+	fappend("Power Vector: 0x%08X%08X\n",
+		(unsigned int)((lo->power_vector & 0xFFFFFFFF00000000ULL) >> 32),
+		(unsigned int)(lo->power_vector & 0x00000000FFFFFFFFULL));
+	fappend("\nControl table WITH PADMIX:\n");
+	pos = append_lo_table(pos, buf, len, lo->with_padmix);
+	fappend("\nControl table WITHOUT PADMIX:\n");
+	pos = append_lo_table(pos, buf, len, lo->no_padmix);
+	fappend("\nUsed RF attenuation values:  Value(WithPadmix flag)\n");
+	for (i = 0; i < lo->rfatt_list.len; i++) {
+		fappend("%u(%d), ",
+			lo->rfatt_list.list[i].att,
+			lo->rfatt_list.list[i].with_padmix);
+	}
+	fappend("\n");
+	fappend("\nUsed Baseband attenuation values:\n");
+	for (i = 0; i < lo->bbatt_list.len; i++) {
+		fappend("%u, ",
+			lo->bbatt_list.list[i].att);
+	}
+	fappend("\n");
+
+out:
+	spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
+	mutex_unlock(&dev->wl->mutex);
+	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	mutex_unlock(&big_buffer_mutex);
+
+	return res;
+}
+
 #undef fappend
 
 static struct file_operations drvinfo_fops = {
@@ -405,6 +487,12 @@ static struct file_operations restart_fo
 	.open = open_file_generic,
 };
 
+static struct file_operations loctls_fops = {
+	.read = loctls_read_file,
+	.open = open_file_generic,
+};
+
+
 int b43_debug(struct b43_wldev *dev, enum b43_dyndbg feature)
 {
 	return !!(dev->dfsentry && dev->dfsentry->dyn_debug[feature]);
@@ -499,6 +587,10 @@ void b43_debugfs_add_device(struct b43_w
 						dev, &restart_fops);
 	if (IS_ERR(e->dentry_restart))
 		e->dentry_restart = NULL;
+	e->dentry_loctls = debugfs_create_file("loctls", 0400, e->subdir,
+					       dev, &loctls_fops);
+	if (IS_ERR(e->dentry_loctls))
+		e->dentry_loctls = NULL;
 
 	b43_add_dynamic_debug(dev);
 }
@@ -513,6 +605,7 @@ void b43_debugfs_remove_device(struct b4
 	if (!e)
 		return;
 	b43_remove_dynamic_debug(dev);
+	debugfs_remove(e->dentry_loctls);
 	debugfs_remove(e->dentry_tsf);
 	debugfs_remove(e->dentry_txstat);
 	debugfs_remove(e->dentry_restart);
Index: wireless-dev-new/drivers/net/wireless/b43/debugfs.h
===================================================================
--- wireless-dev-new.orig/drivers/net/wireless/b43/debugfs.h	2007-08-22 00:42:34.000000000 +0200
+++ wireless-dev-new/drivers/net/wireless/b43/debugfs.h	2007-08-22 00:42:34.000000000 +0200
@@ -34,6 +34,7 @@ struct b43_dfsentry {
 	struct dentry *dentry_txstat;
 	struct dentry *dentry_txpower_g;
 	struct dentry *dentry_restart;
+	struct dentry *dentry_loctls;
 
 	struct b43_wldev *dev;
 

-- 


  parent reply	other threads:[~2007-08-23 22:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 22:21 [patch 0/7] New patch series for merge Michael Buesch
2007-08-23 22:21 ` [patch 1/7] b43: Change Kconfig help text Michael Buesch
2007-08-23 22:21 ` [patch 2/7] b43: Fix oops when firmware not found Michael Buesch
2007-08-23 22:21 ` [patch 3/7] b43: allow disabling hardware encryption Michael Buesch
2007-08-23 22:21 ` Michael Buesch [this message]
2007-08-23 22:21 ` [patch 5/7] b43: Fix hwcrypto keyidx for new firmware Michael Buesch
2007-08-23 22:21 ` [patch 6/7] b43: Add missing stuff to pwork Michael Buesch
2007-08-23 22:22 ` [patch 7/7] b43: Fix and cleanup hwcrypto Michael Buesch
2007-08-24 10:08   ` Johannes Berg
2007-08-24 10:16     ` Michael Buesch
2007-08-24 10:27       ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070823222155.727360000@bu3sch.de \
    --to=mb@bu3sch.de \
    --cc=bcm43xx-dev@lists.berlios.de \
    --cc=larry.finger@lwfinger.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).