Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft sd8787 debugfs #33

Merged
merged 1 commit into from
Aug 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/net/wireless/mwl8787/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mwl8787_sdio-objs := main.o tx.o rx.o cmd.o sdio.o scan.o event.o
mwl8787_sdio-objs := main.o tx.o rx.o cmd.o sdio.o scan.o event.o debugfs.o
mwl8787_sdio-$(CONFIG_NL80211_TESTMODE) += testmode.o

obj-$(CONFIG_MWL8787) += mwl8787_sdio.o
Expand Down
69 changes: 69 additions & 0 deletions drivers/net/wireless/mwl8787/debugfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include <linux/debugfs.h>
#include "mwl8787.h"
#include "sdio.h"

static ssize_t
mwl8787_scratch_read(struct file *file, char __user *ubuf,
size_t count, loff_t *ppos)
{
struct mwl8787_priv *priv =
(struct mwl8787_priv *) file->private_data;

char buf[17] = {};
int pos = 0, ret = 0;
u64 reg_value;

/* read scratch reg */
ret = mwl8787_read_scratch_area(priv, &reg_value);

if (ret) {
ret = -EINVAL;
goto done;
}

pos += snprintf(buf, sizeof(buf), "%016llx\n", reg_value);

ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
done:
return ret;
}

#define MWL8787_DFS_ADD_FILE(name) \
debugfs_create_file(#name, 0644, priv->dfs_dev_dir, \
priv, &mwl8787_dfs_##name##_fops); \


#define MWL8787_DFS_FILE_READ_OPS(name) \
static const struct file_operations mwl8787_dfs_##name##_fops = { \
.read = mwl8787_##name##_read, \
.open = simple_open, \
};

MWL8787_DFS_FILE_READ_OPS(scratch);

/*
* This function creates the debugfs directory and files.
*/
void
mwl8787_dev_debugfs_init(struct mwl8787_priv *priv)
{
if (!priv)
return;

priv->dfs_dev_dir = debugfs_create_dir("mwl8787",
priv->hw->wiphy->debugfsdir);

MWL8787_DFS_ADD_FILE(scratch);
}

/*
* This function removes the debugfs directory and files
*/
void
mwl8787_dev_debugfs_remove(struct mwl8787_priv *priv)
{
if (!priv)
return;

debugfs_remove_recursive(priv->dfs_dev_dir);
}
1 change: 1 addition & 0 deletions drivers/net/wireless/mwl8787/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "mwl8787.h"
#include "fw.h"
#include "sdio.h"

#define CREATE_TRACE_POINTS
#include "trace.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/mwl8787/mwl8787.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct mwl8787_priv
struct sk_buff_head tx_queue;

struct ieee80211_channel *channel;
struct dentry *dfs_dev_dir;

/* sdio */
u32 ioport;
Expand Down
21 changes: 21 additions & 0 deletions drivers/net/wireless/mwl8787/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ mwl8787_sdio_poll_card_status(struct mwl8787_priv *priv, u8 bits)
return -1;
}

/*
* This function reads the scratch area used by firmware to report error codes.
*/
int mwl8787_read_scratch_area(struct mwl8787_priv *priv, u64 *dat)
{
u32 i;
u8 scrch;

for (i = 0; i < MWL8787_REG_SCRATCH_LEN; i++) {
if (mwl8787_read_reg(priv, MWL8787_REG_SCRATCH_START + i, &scrch))
return -1;
*dat = ((*dat << 8) | scrch);
}

return 0;
}

/*
* This function reads the firmware status.
*/
Expand Down Expand Up @@ -930,6 +947,9 @@ static void mwl8787_fw_cb(const struct firmware *fw, void *context)

/* FW loaded, so register with mac80211 */
ret = mwl8787_register(priv);

/* create debugfs */
mwl8787_dev_debugfs_init(priv);
if (ret)
goto disable;

Expand Down Expand Up @@ -1012,6 +1032,7 @@ static void mwl8787_sdio_remove(struct sdio_func *func)
sdio_release_host(func);

kfree(priv->mp_regs);
mwl8787_dev_debugfs_remove(priv);
mwl8787_free(priv);
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/mwl8787/sdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,15 @@
#define MWL8787_REG_POLL 0x30
#define MWL8787_REG_STATUS_0 0x60
#define MWL8787_REG_STATUS_1 0x61
#define MWL8787_REG_SCRATCH_START 0x62
#define MWL8787_REG_SCRATCH_LEN 0x8
#define MWL8787_REG_CARD_MISC_CFG 0x6c

#define MWL8787_SDIO_BLOCK_SIZE 256

int mwl8787_read_scratch_area(struct mwl8787_priv *priv, u64 *dat);
void mwl8787_dev_debugfs_init(struct mwl8787_priv *priv);
void mwl8787_dev_debugfs_remove(struct mwl8787_priv *priv);

enum mwl8787_sdio_type {
MWL8787_TYPE_DATA = 0,
Expand Down