iwlwifi: mvm: add debugfs for prph reg read/write
authorEliad Peller <eliad@wizery.com>
Thu, 9 Jan 2014 11:12:54 +0000 (13:12 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Thu, 13 Feb 2014 11:45:11 +0000 (13:45 +0200)
Allow reading/writing prph registers.

The address is set in the first argument
of the write operation. second argument
is optional and can be used for writing.

e.g.
echo '0xA01234 0x99' > /sys/kernel/debug/ieee80211/phy0/iwlwifi/iwlmvm/prph_reg
will write 0x99 into reg 0xA01234

cat /sys/kernel/debug/ieee80211/phy0/iwlwifi/iwlmvm/prph_reg
will show its current value (probably 0x99)

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/iwlwifi/mvm/debugfs.c
drivers/net/wireless/iwlwifi/mvm/mvm.h

index 6853e5e..9b98337 100644 (file)
@@ -907,6 +907,49 @@ static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
        MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
 
+static ssize_t
+iwl_dbgfs_prph_reg_read(struct file *file,
+                       char __user *user_buf,
+                       size_t count, loff_t *ppos)
+{
+       struct iwl_mvm *mvm = file->private_data;
+       int pos = 0;
+       char buf[32];
+       const size_t bufsz = sizeof(buf);
+
+       if (!mvm->dbgfs_prph_reg_addr)
+               return -EINVAL;
+
+       pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
+               mvm->dbgfs_prph_reg_addr,
+               iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+}
+
+static ssize_t
+iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
+                        size_t count, loff_t *ppos)
+{
+       u8 args;
+       u32 value;
+
+       args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
+       /* if we only want to set the reg address - nothing more to do */
+       if (args == 1)
+               goto out;
+
+       /* otherwise, make sure we have both address and value */
+       if (args != 2)
+               return -EINVAL;
+
+       iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
+out:
+       return count;
+}
+
+MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
+
 /* Device wide debugfs entries */
 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
@@ -951,6 +994,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
        MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
        MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
                             S_IWUSR | S_IRUSR);
+       MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
        MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
 
 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
index bde8190..29d11d9 100644 (file)
@@ -518,6 +518,7 @@ struct iwl_mvm {
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        struct dentry *debugfs_dir;
        u32 dbgfs_sram_offset, dbgfs_sram_len;
+       u32 dbgfs_prph_reg_addr;
        bool disable_power_off;
        bool disable_power_off_d3;