summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-02-22 13:06:42 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-02-22 13:06:42 +0000
commitfe2aef14650a82bd5b94d0e516ad21ec00831939 (patch)
treebcac3e0ea51085944961cee39d7d5c7ea206db0c /target
parent487e30dc6bd06b4b20185e3a9be5401c7924710f (diff)
ramips: raeth: add debugfs support
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30680 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ramips/Kconfig4
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ramips/Makefile2
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_debugfs.c49
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_eth.h20
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_main.c17
-rw-r--r--target/linux/ramips/rt288x/config-3.21
-rw-r--r--target/linux/ramips/rt305x/config-3.21
-rw-r--r--target/linux/ramips/rt3883/config-3.21
8 files changed, 94 insertions, 1 deletions
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ramips/Kconfig b/target/linux/ramips/files/drivers/net/ethernet/ramips/Kconfig
index 08d7ad170..c821d5bd7 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ramips/Kconfig
+++ b/target/linux/ramips/files/drivers/net/ethernet/ramips/Kconfig
@@ -10,4 +10,8 @@ if NET_RAMIPS
config NET_RAMIPS_DEBUG
bool "Enable debug messages in the Ralink ethernet driver"
+config NET_RAMIPS_DEBUG_FS
+ bool "Enable debugfs support for the Ralink ethernet driver"
+ depends on DEBUG_FS
+
endif
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ramips/Makefile b/target/linux/ramips/files/drivers/net/ethernet/ramips/Makefile
index 59db90090..22c460d4d 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ramips/Makefile
+++ b/target/linux/ramips/files/drivers/net/ethernet/ramips/Makefile
@@ -4,4 +4,6 @@
ramips-y += ramips_main.o
+ramips-$(CONFIG_NET_RAMIPS_DEBUG_FS) += ramips_debugfs.o
+
obj-$(CONFIG_NET_RAMIPS) += ramips.o
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_debugfs.c b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_debugfs.c
new file mode 100644
index 000000000..8e06b744a
--- /dev/null
+++ b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_debugfs.c
@@ -0,0 +1,49 @@
+/*
+ * Ralink SoC ethernet driver debugfs code
+ *
+ * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/debugfs.h>
+#include <linux/phy.h>
+
+#include "ramips_eth.h"
+
+static struct dentry *raeth_debugfs_root;
+
+void raeth_debugfs_exit(struct raeth_priv *re)
+{
+ debugfs_remove_recursive(re->debug.debugfs_dir);
+}
+
+int raeth_debugfs_init(struct raeth_priv *re)
+{
+ re->debug.debugfs_dir = debugfs_create_dir(re->netdev->name,
+ raeth_debugfs_root);
+ if (!re->debug.debugfs_dir)
+ return -ENOMEM;
+
+ return 0;
+}
+
+int raeth_debugfs_root_init(void)
+{
+ if (raeth_debugfs_root)
+ return -EBUSY;
+
+ raeth_debugfs_root = debugfs_create_dir("raeth", NULL);
+ if (!raeth_debugfs_root)
+ return -ENOENT;
+
+ return 0;
+}
+
+void raeth_debugfs_root_exit(void)
+{
+ debugfs_remove(raeth_debugfs_root);
+ raeth_debugfs_root = NULL;
+}
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_eth.h b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_eth.h
index 1d151df68..ea3e92340 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_eth.h
+++ b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_eth.h
@@ -213,6 +213,10 @@ struct ramips_tx_dma {
unsigned int txd4;
} __packed __aligned(4);
+struct raeth_debug {
+ struct dentry *debugfs_dir;
+};
+
struct raeth_priv
{
dma_addr_t rx_desc_dma;
@@ -243,6 +247,22 @@ struct raeth_priv
int mii_irq[PHY_MAX_ADDR];
struct phy_device *phy_dev;
spinlock_t phy_lock;
+
+#ifdef CONFIG_NET_RAMIPS_DEBUG_FS
+ struct raeth_debug debug;
+#endif
};
+#ifdef CONFIG_NET_RAMIPS_DEBUG_FS
+int raeth_debugfs_root_init(void);
+void raeth_debugfs_root_exit(void);
+int raeth_debugfs_init(struct raeth_priv *re);
+void raeth_debugfs_exit(struct raeth_priv *re);
+#else
+static inline int raeth_debugfs_root_init(void) { return 0; }
+static inline void raeth_debugfs_root_exit(void) {}
+static inline int raeth_debugfs_init(struct raeth_priv *re) { return 0; }
+static inline void raeth_debugfs_exit(struct raeth_priv *re) {}
+#endif /* CONFIG_NET_RAMIPS_DEBUG_FS */
+
#endif /* RAMIPS_ETH_H */
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_main.c b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_main.c
index b9979fce5..26c98d85a 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_main.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ramips/ramips_main.c
@@ -874,8 +874,14 @@ ramips_eth_probe(struct net_device *dev)
if (err)
goto err_mdio_cleanup;
+ err = raeth_debugfs_init(re);
+ if (err)
+ goto err_phy_disconnect;
+
return 0;
+err_phy_disconnect:
+ ramips_phy_disconnect(re);
err_mdio_cleanup:
ramips_mdio_cleanup(re);
return err;
@@ -886,6 +892,7 @@ ramips_eth_uninit(struct net_device *dev)
{
struct raeth_priv *re = netdev_priv(dev);
+ raeth_debugfs_exit(re);
ramips_phy_disconnect(re);
ramips_mdio_cleanup(re);
}
@@ -992,9 +999,13 @@ ramips_eth_init(void)
{
int ret;
+ ret = raeth_debugfs_root_init();
+ if (ret)
+ goto err_out;
+
ret = rt305x_esw_init();
if (ret)
- return ret;
+ goto err_debugfs_exit;
ret = platform_driver_register(&ramips_eth_driver);
if (ret) {
@@ -1007,6 +1018,9 @@ ramips_eth_init(void)
esw_cleanup:
rt305x_esw_exit();
+err_debugfs_exit:
+ raeth_debugfs_root_exit();
+err_out:
return ret;
}
@@ -1015,6 +1029,7 @@ ramips_eth_cleanup(void)
{
platform_driver_unregister(&ramips_eth_driver);
rt305x_esw_exit();
+ raeth_debugfs_root_exit();
}
module_init(ramips_eth_init);
diff --git a/target/linux/ramips/rt288x/config-3.2 b/target/linux/ramips/rt288x/config-3.2
index 2e4596eb0..9f19f4eaf 100644
--- a/target/linux/ramips/rt288x/config-3.2
+++ b/target/linux/ramips/rt288x/config-3.2
@@ -82,6 +82,7 @@ CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_PER_CPU_KM=y
CONFIG_NET_RAMIPS=y
# CONFIG_NET_RAMIPS_DEBUG is not set
+# CONFIG_NET_RAMIPS_DEBUG_FS is not set
CONFIG_PAGEFLAGS_EXTENDED=y
CONFIG_PCI=y
CONFIG_PCI_DOMAINS=y
diff --git a/target/linux/ramips/rt305x/config-3.2 b/target/linux/ramips/rt305x/config-3.2
index dae7d61d8..c44dba389 100644
--- a/target/linux/ramips/rt305x/config-3.2
+++ b/target/linux/ramips/rt305x/config-3.2
@@ -81,6 +81,7 @@ CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_PER_CPU_KM=y
CONFIG_NET_RAMIPS=y
# CONFIG_NET_RAMIPS_DEBUG is not set
+# CONFIG_NET_RAMIPS_DEBUG_FS is not set
CONFIG_PAGEFLAGS_EXTENDED=y
CONFIG_PERF_USE_VMALLOC=y
CONFIG_PHYLIB=y
diff --git a/target/linux/ramips/rt3883/config-3.2 b/target/linux/ramips/rt3883/config-3.2
index ea43157e1..a716d766b 100644
--- a/target/linux/ramips/rt3883/config-3.2
+++ b/target/linux/ramips/rt3883/config-3.2
@@ -80,6 +80,7 @@ CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_PER_CPU_KM=y
CONFIG_NET_RAMIPS=y
# CONFIG_NET_RAMIPS_DEBUG is not set
+# CONFIG_NET_RAMIPS_DEBUG_FS is not set
CONFIG_PAGEFLAGS_EXTENDED=y
CONFIG_PCI=y
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y