This source file includes following definitions.
- dwmac_pcs_isr
- dwmac_rane
- dwmac_ctrl_ane
- dwmac_get_adv_lp
1
2
3
4
5
6
7
8
9 #ifndef __STMMAC_PCS_H__
10 #define __STMMAC_PCS_H__
11
12 #include <linux/slab.h>
13 #include <linux/io.h>
14 #include "common.h"
15
16
17 #define GMAC_AN_CTRL(x) (x)
18 #define GMAC_AN_STATUS(x) (x + 0x4)
19 #define GMAC_ANE_ADV(x) (x + 0x8)
20 #define GMAC_ANE_LPA(x) (x + 0xc)
21 #define GMAC_ANE_EXP(x) (x + 0x10)
22 #define GMAC_TBI(x) (x + 0x14)
23
24
25 #define GMAC_AN_CTRL_RAN BIT(9)
26 #define GMAC_AN_CTRL_ANE BIT(12)
27 #define GMAC_AN_CTRL_ELE BIT(14)
28 #define GMAC_AN_CTRL_ECD BIT(16)
29 #define GMAC_AN_CTRL_LR BIT(17)
30 #define GMAC_AN_CTRL_SGMRAL BIT(18)
31
32
33 #define GMAC_AN_STATUS_LS BIT(2)
34 #define GMAC_AN_STATUS_ANA BIT(3)
35 #define GMAC_AN_STATUS_ANC BIT(5)
36 #define GMAC_AN_STATUS_ES BIT(8)
37
38
39 #define GMAC_ANE_FD BIT(5)
40 #define GMAC_ANE_HD BIT(6)
41 #define GMAC_ANE_PSE GENMASK(8, 7)
42 #define GMAC_ANE_PSE_SHIFT 7
43 #define GMAC_ANE_RFE GENMASK(13, 12)
44 #define GMAC_ANE_RFE_SHIFT 12
45 #define GMAC_ANE_ACK BIT(14)
46
47
48
49
50
51
52
53
54
55
56 static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg,
57 unsigned int intr_status,
58 struct stmmac_extra_stats *x)
59 {
60 u32 val = readl(ioaddr + GMAC_AN_STATUS(reg));
61
62 if (intr_status & PCS_ANE_IRQ) {
63 x->irq_pcs_ane_n++;
64 if (val & GMAC_AN_STATUS_ANC)
65 pr_info("stmmac_pcs: ANE process completed\n");
66 }
67
68 if (intr_status & PCS_LINK_IRQ) {
69 x->irq_pcs_link_n++;
70 if (val & GMAC_AN_STATUS_LS)
71 pr_info("stmmac_pcs: Link Up\n");
72 else
73 pr_info("stmmac_pcs: Link Down\n");
74 }
75 }
76
77
78
79
80
81
82
83
84 static inline void dwmac_rane(void __iomem *ioaddr, u32 reg, bool restart)
85 {
86 u32 value = readl(ioaddr + GMAC_AN_CTRL(reg));
87
88 if (restart)
89 value |= GMAC_AN_CTRL_RAN;
90
91 writel(value, ioaddr + GMAC_AN_CTRL(reg));
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105 static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane,
106 bool srgmi_ral, bool loopback)
107 {
108 u32 value = readl(ioaddr + GMAC_AN_CTRL(reg));
109
110
111 if (ane)
112 value |= GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_RAN;
113
114
115
116
117 if (srgmi_ral)
118 value |= GMAC_AN_CTRL_SGMRAL;
119
120 if (loopback)
121 value |= GMAC_AN_CTRL_ELE;
122
123 writel(value, ioaddr + GMAC_AN_CTRL(reg));
124 }
125
126
127
128
129
130
131
132
133
134 static inline void dwmac_get_adv_lp(void __iomem *ioaddr, u32 reg,
135 struct rgmii_adv *adv_lp)
136 {
137 u32 value = readl(ioaddr + GMAC_ANE_ADV(reg));
138
139 if (value & GMAC_ANE_FD)
140 adv_lp->duplex = DUPLEX_FULL;
141 if (value & GMAC_ANE_HD)
142 adv_lp->duplex |= DUPLEX_HALF;
143
144 adv_lp->pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT;
145
146 value = readl(ioaddr + GMAC_ANE_LPA(reg));
147
148 if (value & GMAC_ANE_FD)
149 adv_lp->lp_duplex = DUPLEX_FULL;
150 if (value & GMAC_ANE_HD)
151 adv_lp->lp_duplex = DUPLEX_HALF;
152
153 adv_lp->lp_pause = (value & GMAC_ANE_PSE) >> GMAC_ANE_PSE_SHIFT;
154 }
155 #endif