Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b81297fb authored by Tzahi Sabo's avatar Tzahi Sabo Committed by Maya Erez
Browse files

wil6210: add support for reading multiple RFs temperature via debugfs



Base-band chips support multi RFs chips. Add support for reading
multiple RFs temperature via debugfs.

Change-Id: Iedad126509049ef084c3d04f65a6d7f6347b38ec
Signed-off-by: default avatarTzahi Sabo <stzahi@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Git-commit: 9b586118730e1b86dc3c8d8523effc712c5a2bfc
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git


[merez@codeaurora.org: trivial merge conflicts]
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
parent 47d6a244
Loading
Loading
Loading
Loading
+33 −9
Original line number Diff line number Diff line
@@ -1451,7 +1451,7 @@ static void print_temp(struct seq_file *s, const char *prefix, s32 t)
{
	switch (t) {
	case 0:
	case ~(u32)0:
	case WMI_INVALID_TEMPERATURE:
		seq_printf(s, "%s N/A\n", prefix);
	break;
	default:
@@ -1464,17 +1464,41 @@ static void print_temp(struct seq_file *s, const char *prefix, s32 t)
static int wil_temp_debugfs_show(struct seq_file *s, void *data)
{
	struct wil6210_priv *wil = s->private;
	s32 t_m, t_r;
	int rc = wmi_get_temperature(wil, &t_m, &t_r);
	int rc, i;

	if (test_bit(WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF,
		     wil->fw_capabilities)) {
		struct wmi_temp_sense_all_done_event sense_all_evt;

		wil_dbg_misc(wil,
			     "WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF is supported");
		rc = wmi_get_all_temperatures(wil, &sense_all_evt);
		if (rc) {
			seq_puts(s, "Failed\n");
			return 0;
		}
		print_temp(s, "T_mac   =",
			   le32_to_cpu(sense_all_evt.baseband_t1000));
		seq_printf(s, "Connected RFs [0x%08x]\n",
			   sense_all_evt.rf_bitmap);
		for (i = 0; i < WMI_MAX_XIF_PORTS_NUM; i++) {
			seq_printf(s, "RF[%d]   = ", i);
			print_temp(s, "",
				   le32_to_cpu(sense_all_evt.rf_t1000[i]));
		}
	} else {
		s32 t_m, t_r;

		wil_dbg_misc(wil,
			     "WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF is not supported");
		rc = wmi_get_temperature(wil, &t_m, &t_r);
		if (rc) {
			seq_puts(s, "Failed\n");
			return 0;
		}
		print_temp(s, "T_mac   =", t_m);
		print_temp(s, "T_radio =", t_r);

	}
	return 0;
}

+3 −0
Original line number Diff line number Diff line
@@ -1275,6 +1275,9 @@ int wmi_rx_chain_add(struct wil6210_priv *wil, struct wil_ring *vring);
int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie);
int wmi_rxon(struct wil6210_priv *wil, bool on);
int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
int wmi_get_all_temperatures(struct wil6210_priv *wil,
			     struct wmi_temp_sense_all_done_event
			     *sense_all_evt);
int wmi_disconnect_sta(struct wil6210_vif *vif, const u8 *mac, u16 reason,
		       bool del_sta);
int wmi_addba(struct wil6210_priv *wil, u8 mid,
+42 −0
Original line number Diff line number Diff line
@@ -482,6 +482,8 @@ static const char *cmdid2name(u16 cmdid)
		return "WMI_RESET_SPI_SLAVE_CMD";
	case WMI_RBUFCAP_CFG_CMDID:
		return "WMI_RBUFCAP_CFG_CMD";
	case WMI_TEMP_SENSE_ALL_CMDID:
		return "WMI_TEMP_SENSE_ALL_CMDID";
	default:
		return "Untracked CMD";
	}
@@ -632,6 +634,8 @@ static const char *eventid2name(u16 eventid)
		return "WMI_RESET_SPI_SLAVE_EVENT";
	case WMI_RBUFCAP_CFG_EVENTID:
		return "WMI_RBUFCAP_CFG_EVENT";
	case WMI_TEMP_SENSE_ALL_DONE_EVENTID:
		return "WMI_TEMP_SENSE_ALL_DONE_EVENTID";
	default:
		return "Untracked EVENT";
	}
@@ -2738,6 +2742,44 @@ int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_bb, u32 *t_rf)
	return 0;
}

int wmi_get_all_temperatures(struct wil6210_priv *wil,
			     struct wmi_temp_sense_all_done_event
			     *sense_all_evt)
{
	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
	int rc;
	struct wmi_temp_sense_all_cmd cmd = {
		.measure_baseband_en = true,
		.measure_rf_en = true,
		.measure_mode = TEMPERATURE_MEASURE_NOW,
	};
	struct {
		struct wmi_cmd_hdr wmi;
		struct wmi_temp_sense_all_done_event evt;
	} __packed reply;

	if (!sense_all_evt) {
		wil_err(wil, "Invalid sense_all_evt value\n");
		return -EINVAL;
	}

	memset(&reply, 0, sizeof(reply));
	reply.evt.status = WMI_FW_STATUS_FAILURE;
	rc = wmi_call(wil, WMI_TEMP_SENSE_ALL_CMDID, vif->mid, &cmd,
		      sizeof(cmd), WMI_TEMP_SENSE_ALL_DONE_EVENTID,
		      &reply, sizeof(reply), WIL_WMI_CALL_GENERAL_TO_MS);
	if (rc)
		return rc;

	if (reply.evt.status == WMI_FW_STATUS_FAILURE) {
		wil_err(wil, "Failed geting TEMP_SENSE_ALL\n");
		return -EINVAL;
	}

	memcpy(sense_all_evt, &reply.evt, sizeof(reply.evt));
	return 0;
}

int wmi_disconnect_sta(struct wil6210_vif *vif, const u8 *mac, u16 reason,
		       bool del_sta)
{
+39 −8
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#define WMI_PROX_RANGE_NUM		(3)
#define WMI_MAX_LOSS_DMG_BEACONS	(20)
#define MAX_NUM_OF_SECTORS		(128)
#define WMI_INVALID_TEMPERATURE		(0xFFFFFFFF)
#define WMI_SCHED_MAX_ALLOCS_PER_CMD	(4)
#define WMI_RF_DTYPE_LENGTH		(3)
#define WMI_RF_ETYPE_LENGTH		(3)
@@ -53,6 +54,7 @@
#define WMI_QOS_MAX_WEIGHT		50
#define WMI_QOS_SET_VIF_PRIORITY	(0xFF)
#define WMI_QOS_DEFAULT_PRIORITY	(WMI_QOS_NUM_OF_PRIORITY)
#define WMI_MAX_XIF_PORTS_NUM		(8)

/* Mailbox interface
 * used for commands and events
@@ -96,6 +98,7 @@ enum wmi_fw_capability {
	WMI_FW_CAPABILITY_TX_REQ_EXT			= 25,
	WMI_FW_CAPABILITY_CHANNEL_4			= 26,
	WMI_FW_CAPABILITY_IPA				= 27,
	WMI_FW_CAPABILITY_TEMPERATURE_ALL_RF		= 30,
	WMI_FW_CAPABILITY_MAX,
};

@@ -289,6 +292,7 @@ enum wmi_command_id {
	WMI_SET_VRING_PRIORITY_WEIGHT_CMDID		= 0xA10,
	WMI_SET_VRING_PRIORITY_CMDID			= 0xA11,
	WMI_RBUFCAP_CFG_CMDID				= 0xA12,
	WMI_TEMP_SENSE_ALL_CMDID			= 0xA13,
	WMI_SET_MAC_ADDRESS_CMDID			= 0xF003,
	WMI_ABORT_SCAN_CMDID				= 0xF007,
	WMI_SET_PROMISCUOUS_MODE_CMDID			= 0xF041,
@@ -1426,12 +1430,7 @@ struct wmi_rf_xpm_write_cmd {
	u8 data_bytes[0];
} __packed;

/* WMI_TEMP_SENSE_CMDID
 *
 * Measure MAC and radio temperatures
 *
 * Possible modes for temperature measurement
 */
/* Possible modes for temperature measurement */
enum wmi_temperature_measure_mode {
	TEMPERATURE_USE_OLD_VALUE	= 0x01,
	TEMPERATURE_MEASURE_NOW		= 0x02,
@@ -1964,6 +1963,14 @@ struct wmi_set_ap_slot_size_cmd {
	__le32 slot_size;
} __packed;

/* WMI_TEMP_SENSE_ALL_CMDID */
struct wmi_temp_sense_all_cmd {
	u8 measure_baseband_en;
	u8 measure_rf_en;
	u8 measure_mode;
	u8 reserved;
} __packed;

/* WMI Events
 * List of Events (target to host)
 */
@@ -2125,6 +2132,7 @@ enum wmi_event_id {
	WMI_SET_VRING_PRIORITY_WEIGHT_EVENTID		= 0x1A10,
	WMI_SET_VRING_PRIORITY_EVENTID			= 0x1A11,
	WMI_RBUFCAP_CFG_EVENTID				= 0x1A12,
	WMI_TEMP_SENSE_ALL_DONE_EVENTID			= 0x1A13,
	WMI_SET_CHANNEL_EVENTID				= 0x9000,
	WMI_ASSOC_REQ_EVENTID				= 0x9001,
	WMI_EAPOL_RX_EVENTID				= 0x9002,
@@ -2812,11 +2820,13 @@ struct wmi_fixed_scheduling_ul_config_event {
 */
struct wmi_temp_sense_done_event {
	/* Temperature times 1000 (actual temperature will be achieved by
	 * dividing the value by 1000)
	 * dividing the value by 1000). When temperature cannot be read from
	 * device return WMI_INVALID_TEMPERATURE
	 */
	__le32 baseband_t1000;
	/* Temperature times 1000 (actual temperature will be achieved by
	 * dividing the value by 1000)
	 * dividing the value by 1000). When temperature cannot be read from
	 * device return WMI_INVALID_TEMPERATURE
	 */
	__le32 rf_t1000;
} __packed;
@@ -4194,4 +4204,25 @@ struct wmi_set_vr_profile_event {
	u8 reserved[3];
} __packed;

/* WMI_TEMP_SENSE_ALL_DONE_EVENTID
 * Measure MAC and all radio temperatures
 */
struct wmi_temp_sense_all_done_event {
	/* enum wmi_fw_status */
	u8 status;
	/* Bitmap of connected RFs */
	u8 rf_bitmap;
	u8 reserved[2];
	/* Temperature times 1000 (actual temperature will be achieved by
	 * dividing the value by 1000). When temperature cannot be read from
	 * device return WMI_INVALID_TEMPERATURE
	 */
	__le32 rf_t1000[WMI_MAX_XIF_PORTS_NUM];
	/* Temperature times 1000 (actual temperature will be achieved by
	 * dividing the value by 1000). When temperature cannot be read from
	 * device return WMI_INVALID_TEMPERATURE
	 */
	__le32 baseband_t1000;
} __packed;

#endif /* __WILOCITY_WMI_H__ */