Commit c791f746 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman
Browse files

staging: wfx: add support for tx_power_loop



During the calibration of the RF amplifier, the device is able to provide
some data about the status of the amplifier.

Record these data and expose them in debugfs.

Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200526171821.934581-5-Jerome.Pouiller@silabs.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent be2e9622
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -178,6 +178,30 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v)
}
DEFINE_SHOW_ATTRIBUTE(wfx_rx_stats);

static int wfx_tx_power_loop_show(struct seq_file *seq, void *v)
{
	struct wfx_dev *wdev = seq->private;
	struct hif_tx_power_loop_info *st = &wdev->tx_power_loop_info;
	int tmp;

	mutex_lock(&wdev->tx_power_loop_info_lock);
	tmp = le16_to_cpu(st->tx_gain_dig);
	seq_printf(seq, "Tx gain digital: %d\n", tmp);
	tmp = le16_to_cpu(st->tx_gain_pa);
	seq_printf(seq, "Tx gain PA: %d\n", tmp);
	tmp = (s16)le16_to_cpu(st->target_pout);
	seq_printf(seq, "Target Pout: %d.%02d dBm\n", tmp / 4, (tmp % 4) * 25);
	tmp = (s16)le16_to_cpu(st->p_estimation);
	seq_printf(seq, "FEM Pout: %d.%02d dBm\n", tmp / 4, (tmp % 4) * 25);
	tmp = le16_to_cpu(st->vpdet);
	seq_printf(seq, "Vpdet: %d mV\n", tmp);
	seq_printf(seq, "Measure index: %d\n", st->measurement_index);
	mutex_unlock(&wdev->tx_power_loop_info_lock);

	return 0;
}
DEFINE_SHOW_ATTRIBUTE(wfx_tx_power_loop);

static ssize_t wfx_send_pds_write(struct file *file,
				  const char __user *user_buf,
				  size_t count, loff_t *ppos)
@@ -317,6 +341,8 @@ int wfx_debug_init(struct wfx_dev *wdev)
	d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir);
	debugfs_create_file("counters", 0444, d, wdev, &wfx_counters_fops);
	debugfs_create_file("rx_stats", 0444, d, wdev, &wfx_rx_stats_fops);
	debugfs_create_file("tx_power_loop", 0444, d, wdev,
			    &wfx_tx_power_loop_fops);
	debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops);
	debugfs_create_file("burn_slk_key", 0200, d, wdev,
			    &wfx_burn_slk_key_fops);
+15 −3
Original line number Diff line number Diff line
@@ -203,7 +203,8 @@ struct hif_cnf_control_gpio {
enum hif_generic_indication_type {
	HIF_GENERIC_INDICATION_TYPE_RAW                = 0x0,
	HIF_GENERIC_INDICATION_TYPE_STRING             = 0x1,
	HIF_GENERIC_INDICATION_TYPE_RX_STATS = 0x2
	HIF_GENERIC_INDICATION_TYPE_RX_STATS           = 0x2,
	HIF_GENERIC_INDICATION_TYPE_TX_POWER_LOOP_INFO = 0x3,
};

struct hif_rx_stats {
@@ -222,8 +223,19 @@ struct hif_rx_stats {
	s8     current_temp;
} __packed;

struct hif_tx_power_loop_info {
	__le16 tx_gain_dig;
	__le16 tx_gain_pa;
	__le16 target_pout; // signed value
	__le16 p_estimation; // signed value
	__le16 vpdet;
	u8     measurement_index;
	u8     reserved;
} __packed;

union hif_indication_data {
	struct hif_rx_stats rx_stats;
	struct hif_tx_power_loop_info tx_power_loop_info;
	u8     raw_data[1];
};

+7 −0
Original line number Diff line number Diff line
@@ -278,6 +278,13 @@ static int hif_generic_indication(struct wfx_dev *wdev,
		       sizeof(wdev->rx_stats));
		mutex_unlock(&wdev->rx_stats_lock);
		return 0;
	case HIF_GENERIC_INDICATION_TYPE_TX_POWER_LOOP_INFO:
		mutex_lock(&wdev->tx_power_loop_info_lock);
		memcpy(&wdev->tx_power_loop_info,
		       &body->indication_data.tx_power_loop_info,
		       sizeof(wdev->tx_power_loop_info));
		mutex_unlock(&wdev->tx_power_loop_info_lock);
		return 0;
	default:
		dev_err(wdev->dev, "generic_indication: unknown indication type: %#.8x\n",
			type);
+2 −0
Original line number Diff line number Diff line
@@ -274,6 +274,7 @@ static void wfx_free_common(void *data)
{
	struct wfx_dev *wdev = data;

	mutex_destroy(&wdev->tx_power_loop_info_lock);
	mutex_destroy(&wdev->rx_stats_lock);
	mutex_destroy(&wdev->conf_mutex);
	ieee80211_free_hw(wdev->hw);
@@ -344,6 +345,7 @@ struct wfx_dev *wfx_init_common(struct device *dev,

	mutex_init(&wdev->conf_mutex);
	mutex_init(&wdev->rx_stats_lock);
	mutex_init(&wdev->tx_power_loop_info_lock);
	init_completion(&wdev->firmware_ready);
	INIT_DELAYED_WORK(&wdev->cooling_timeout_work,
			  wfx_cooling_timeout_work);
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ struct wfx_dev {

	struct hif_rx_stats	rx_stats;
	struct mutex		rx_stats_lock;
	struct hif_tx_power_loop_info tx_power_loop_info;
	struct mutex		tx_power_loop_info_lock;
};

struct wfx_vif {