diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-02-22 13:06:42 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-02-22 13:06:42 +0000 |
commit | 214216c04da637555f6571e787e2bb405a285dec (patch) | |
tree | cb2efbc3082f2858d9ae41f462d9c02aae274fa4 /target/linux/ramips | |
parent | c1e4d709fa36f903665c7a5661008dbbee73f56e (diff) | |
download | mtk-20170518-214216c04da637555f6571e787e2bb405a285dec.zip mtk-20170518-214216c04da637555f6571e787e2bb405a285dec.tar.gz mtk-20170518-214216c04da637555f6571e787e2bb405a285dec.tar.bz2 |
ramips: raeth: add debugfs support
SVN-Revision: 30680
Diffstat (limited to 'target/linux/ramips')
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 08d7ad1..c821d5b 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 59db900..22c460d 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 0000000..8e06b74 --- /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 1d151df..ea3e923 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 b9979fc..26c98d8 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 2e4596e..9f19f4e 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 dae7d61..c44dba3 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 ea43157..a716d76 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 |