]> Git Repo - linux.git/blob - drivers/net/ethernet/mediatek/mtk_wed.h
block: add a sanity check for non-write flush/fua bios
[linux.git] / drivers / net / ethernet / mediatek / mtk_wed.h
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) 2021 Felix Fietkau <[email protected]> */
3
4 #ifndef __MTK_WED_PRIV_H
5 #define __MTK_WED_PRIV_H
6
7 #include <linux/soc/mediatek/mtk_wed.h>
8 #include <linux/debugfs.h>
9 #include <linux/regmap.h>
10 #include <linux/netdevice.h>
11
12 struct mtk_eth;
13 struct mtk_wed_wo;
14
15 struct mtk_wed_hw {
16         struct device_node *node;
17         struct mtk_eth *eth;
18         struct regmap *regs;
19         struct regmap *hifsys;
20         struct device *dev;
21         void __iomem *wdma;
22         phys_addr_t wdma_phy;
23         struct regmap *mirror;
24         struct dentry *debugfs_dir;
25         struct mtk_wed_device *wed_dev;
26         struct mtk_wed_wo *wed_wo;
27         u32 debugfs_reg;
28         u32 num_flows;
29         u8 version;
30         char dirname[5];
31         int irq;
32         int index;
33 };
34
35 struct mtk_wdma_info {
36         u8 wdma_idx;
37         u8 queue;
38         u16 wcid;
39         u8 bss;
40 };
41
42 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
43 static inline void
44 wed_w32(struct mtk_wed_device *dev, u32 reg, u32 val)
45 {
46         regmap_write(dev->hw->regs, reg, val);
47 }
48
49 static inline u32
50 wed_r32(struct mtk_wed_device *dev, u32 reg)
51 {
52         unsigned int val;
53
54         regmap_read(dev->hw->regs, reg, &val);
55
56         return val;
57 }
58
59 static inline void
60 wdma_w32(struct mtk_wed_device *dev, u32 reg, u32 val)
61 {
62         writel(val, dev->hw->wdma + reg);
63 }
64
65 static inline u32
66 wdma_r32(struct mtk_wed_device *dev, u32 reg)
67 {
68         return readl(dev->hw->wdma + reg);
69 }
70
71 static inline u32
72 wpdma_tx_r32(struct mtk_wed_device *dev, int ring, u32 reg)
73 {
74         if (!dev->tx_ring[ring].wpdma)
75                 return 0;
76
77         return readl(dev->tx_ring[ring].wpdma + reg);
78 }
79
80 static inline void
81 wpdma_tx_w32(struct mtk_wed_device *dev, int ring, u32 reg, u32 val)
82 {
83         if (!dev->tx_ring[ring].wpdma)
84                 return;
85
86         writel(val, dev->tx_ring[ring].wpdma + reg);
87 }
88
89 static inline u32
90 wpdma_rx_r32(struct mtk_wed_device *dev, int ring, u32 reg)
91 {
92         if (!dev->rx_ring[ring].wpdma)
93                 return 0;
94
95         return readl(dev->rx_ring[ring].wpdma + reg);
96 }
97
98 static inline void
99 wpdma_rx_w32(struct mtk_wed_device *dev, int ring, u32 reg, u32 val)
100 {
101         if (!dev->rx_ring[ring].wpdma)
102                 return;
103
104         writel(val, dev->rx_ring[ring].wpdma + reg);
105 }
106
107 static inline u32
108 wpdma_txfree_r32(struct mtk_wed_device *dev, u32 reg)
109 {
110         if (!dev->txfree_ring.wpdma)
111                 return 0;
112
113         return readl(dev->txfree_ring.wpdma + reg);
114 }
115
116 static inline void
117 wpdma_txfree_w32(struct mtk_wed_device *dev, u32 reg, u32 val)
118 {
119         if (!dev->txfree_ring.wpdma)
120                 return;
121
122         writel(val, dev->txfree_ring.wpdma + reg);
123 }
124
125 void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
126                     void __iomem *wdma, phys_addr_t wdma_phy,
127                     int index);
128 void mtk_wed_exit(void);
129 int mtk_wed_flow_add(int index);
130 void mtk_wed_flow_remove(int index);
131 #else
132 static inline void
133 mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
134                void __iomem *wdma, phys_addr_t wdma_phy,
135                int index)
136 {
137 }
138 static inline void
139 mtk_wed_exit(void)
140 {
141 }
142 static inline int mtk_wed_flow_add(int index)
143 {
144         return -EINVAL;
145 }
146 static inline void mtk_wed_flow_remove(int index)
147 {
148 }
149
150 #endif
151
152 #ifdef CONFIG_DEBUG_FS
153 void mtk_wed_hw_add_debugfs(struct mtk_wed_hw *hw);
154 #else
155 static inline void mtk_wed_hw_add_debugfs(struct mtk_wed_hw *hw)
156 {
157 }
158 #endif
159
160 #endif
This page took 0.042717 seconds and 4 git commands to generate.