wil6210: temperature measurement
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Wed, 13 Mar 2013 12:12:51 +0000 (14:12 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 13 Mar 2013 18:27:35 +0000 (14:27 -0400)
Firmware got support for temperature measurement.
There are 2 temperature sensors: MAC and radio

"not available" temperature - reported by FW as 0 or ~0

Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/wil6210/debugfs.c
drivers/net/wireless/ath/wil6210/wil6210.h
drivers/net/wireless/ath/wil6210/wmi.c

index 1e709bfb63a31ec83dac65f830d216ed2aac6442..4be07f5e22b991b6223caadf99ff2c6faf3db664 100644 (file)
@@ -521,6 +521,49 @@ static const struct file_operations fops_ssid = {
        .open  = simple_open,
 };
 
+/*---------temp------------*/
+static void print_temp(struct seq_file *s, const char *prefix, u32 t)
+{
+       switch (t) {
+       case 0:
+       case ~(u32)0:
+               seq_printf(s, "%s N/A\n", prefix);
+       break;
+       default:
+               seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
+               break;
+       }
+}
+
+static int wil_temp_debugfs_show(struct seq_file *s, void *data)
+{
+       struct wil6210_priv *wil = s->private;
+       u32 t_m, t_r;
+
+       int rc = wmi_get_temperature(wil, &t_m, &t_r);
+       if (rc) {
+               seq_printf(s, "Failed\n");
+               return 0;
+       }
+
+       print_temp(s, "MAC temperature   :", t_m);
+       print_temp(s, "Radio temperature :", t_r);
+
+       return 0;
+}
+
+static int wil_temp_seq_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, wil_temp_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations fops_temp = {
+       .open           = wil_temp_seq_open,
+       .release        = single_release,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+};
+
 /*----------------*/
 int wil6210_debugfs_init(struct wil6210_priv *wil)
 {
@@ -555,6 +598,7 @@ int wil6210_debugfs_init(struct wil6210_priv *wil)
        debugfs_create_file("mem_val", S_IRUGO, dbg, wil, &fops_memread);
 
        debugfs_create_file("reset", S_IWUSR, dbg, wil, &fops_reset);
+       debugfs_create_file("temp", S_IRUGO, dbg, wil, &fops_temp);
 
        wil->rgf_blob.data = (void * __force)wil->csr + 0;
        wil->rgf_blob.size = 0xa000;
index 3bbd86d54ba168b770e1d9da43c174e463138091..8f76ecd8a7e5e5ec0862b45053c254af66df9a62 100644 (file)
@@ -329,6 +329,7 @@ int wmi_echo(struct wil6210_priv *wil);
 int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 ie_len, const void *ie);
 int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring);
 int wmi_p2p_cfg(struct wil6210_priv *wil, int channel);
+int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
 
 int wil6210_init_irq(struct wil6210_priv *wil, int irq);
 void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
index 706ee9d86e61c4370fb156b32ca4c98b0f3d0967..45b04e383f9a1745e272ccfc8a8dd0abf79cfef9 100644 (file)
@@ -962,6 +962,31 @@ int wmi_rx_chain_add(struct wil6210_priv *wil, struct vring *vring)
        return rc;
 }
 
+int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r)
+{
+       int rc;
+       struct wmi_temp_sense_cmd cmd = {
+               .measure_marlon_m_en = cpu_to_le32(!!t_m),
+               .measure_marlon_r_en = cpu_to_le32(!!t_r),
+       };
+       struct {
+               struct wil6210_mbox_hdr_wmi wmi;
+               struct wmi_temp_sense_done_event evt;
+       } __packed reply;
+
+       rc = wmi_call(wil, WMI_TEMP_SENSE_CMDID, &cmd, sizeof(cmd),
+                     WMI_TEMP_SENSE_DONE_EVENTID, &reply, sizeof(reply), 100);
+       if (rc)
+               return rc;
+
+       if (t_m)
+               *t_m = le32_to_cpu(reply.evt.marlon_m_t1000);
+       if (t_r)
+               *t_r = le32_to_cpu(reply.evt.marlon_r_t1000);
+
+       return 0;
+}
+
 void wmi_event_flush(struct wil6210_priv *wil)
 {
        struct pending_wmi_event *evt, *t;