Messages in this thread Patch in this message | | | From | <> | Subject | [PATCH v2 3/4] net: ethernet: altera: move read write functions | Date | Thu, 21 Dec 2023 21:40:40 +0800 |
| |
From: Nagaraju DeepakX <deepakx.nagaraju@intel.com>
Move read write functions from altera_tse.h to altera_utils.h so it can be shared with future altera ethernet IP's.
Signed-off-by: Nagaraju DeepakX <deepakx.nagaraju@intel.com> Reviewed-by: Andy Schevchenko <andriy.schevchenko@linux.intel.com> Reviewed-by: Simon Horman <horms@kernel.org> --- drivers/net/ethernet/altera/altera_tse.h | 45 ------------------- .../net/ethernet/altera/altera_tse_ethtool.c | 1 + drivers/net/ethernet/altera/altera_utils.h | 43 ++++++++++++++++++ 3 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h index 82f2363a45cd..4874139e7cdf 100644 --- a/drivers/net/ethernet/altera/altera_tse.h +++ b/drivers/net/ethernet/altera/altera_tse.h @@ -483,49 +483,4 @@ struct altera_tse_private { */ void altera_tse_set_ethtool_ops(struct net_device *);
-static inline -u32 csrrd32(void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - return readl(paddr); -} - -static inline -u16 csrrd16(void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - return readw(paddr); -} - -static inline -u8 csrrd8(void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - return readb(paddr); -} - -static inline -void csrwr32(u32 val, void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - - writel(val, paddr); -} - -static inline -void csrwr16(u16 val, void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - - writew(val, paddr); -} - -static inline -void csrwr8(u8 val, void __iomem *mac, size_t offs) -{ - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); - - writeb(val, paddr); -} - #endif /* __ALTERA_TSE_H__ */ diff --git a/drivers/net/ethernet/altera/altera_tse_ethtool.c b/drivers/net/ethernet/altera/altera_tse_ethtool.c index 81313c85833e..d34373bac94a 100644 --- a/drivers/net/ethernet/altera/altera_tse_ethtool.c +++ b/drivers/net/ethernet/altera/altera_tse_ethtool.c @@ -22,6 +22,7 @@ #include <linux/phy.h>
#include "altera_tse.h" +#include "altera_utils.h"
#define TSE_STATS_LEN 31 #define TSE_NUM_REGS 128 diff --git a/drivers/net/ethernet/altera/altera_utils.h b/drivers/net/ethernet/altera/altera_utils.h index 3c2e32fb7389..c3f09c5257f7 100644 --- a/drivers/net/ethernet/altera/altera_utils.h +++ b/drivers/net/ethernet/altera/altera_utils.h @@ -7,6 +7,7 @@ #define __ALTERA_UTILS_H__
#include <linux/compiler.h> +#include <linux/io.h> #include <linux/types.h>
void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); @@ -14,4 +15,46 @@ void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask); int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask);
+static inline u32 csrrd32(void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + return readl(paddr); +} + +static inline u16 csrrd16(void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + return readw(paddr); +} + +static inline u8 csrrd8(void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + return readb(paddr); +} + +static inline void csrwr32(u32 val, void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + writel(val, paddr); +} + +static inline void csrwr16(u16 val, void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + writew(val, paddr); +} + +static inline void csrwr8(u8 val, void __iomem *mac, size_t offs) +{ + void __iomem *paddr = mac + offs; + + writeb(val, paddr); +} + #endif /* __ALTERA_UTILS_H__*/ -- 2.26.2
| |