gpio-nct5104d: fix compilation with kernel 6.6
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 716-v6.9-08-net-phy-qcom-move-common-qca808x-LED-define-to-share.patch
1 From ee9d9807bee0e6af8ca2a4db6f0d1dc0e5b41f44 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Tue, 6 Feb 2024 18:31:11 +0100
4 Subject: [PATCH 08/10] net: phy: qcom: move common qca808x LED define to
5 shared header
6
7 The LED implementation of qca808x and qca807x is the same but qca807x
8 supports also Fiber port and have different hw control bits for Fiber
9 port.
10
11 In preparation for qca807x introduction, move all the common define to
12 shared header.
13
14 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
15 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/phy/qcom/qca808x.c | 65 ----------------------------------
19 drivers/net/phy/qcom/qcom.h | 65 ++++++++++++++++++++++++++++++++++
20 2 files changed, 65 insertions(+), 65 deletions(-)
21
22 --- a/drivers/net/phy/qcom/qca808x.c
23 +++ b/drivers/net/phy/qcom/qca808x.c
24 @@ -62,29 +62,6 @@
25 #define QCA808X_DBG_AN_TEST 0xb
26 #define QCA808X_HIBERNATION_EN BIT(15)
27
28 -#define QCA808X_MMD7_LED_GLOBAL 0x8073
29 -#define QCA808X_LED_BLINK_1 GENMASK(11, 6)
30 -#define QCA808X_LED_BLINK_2 GENMASK(5, 0)
31 -/* Values are the same for both BLINK_1 and BLINK_2 */
32 -#define QCA808X_LED_BLINK_FREQ_MASK GENMASK(5, 3)
33 -#define QCA808X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0)
34 -#define QCA808X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1)
35 -#define QCA808X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2)
36 -#define QCA808X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3)
37 -#define QCA808X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4)
38 -#define QCA808X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5)
39 -#define QCA808X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6)
40 -#define QCA808X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7)
41 -#define QCA808X_LED_BLINK_DUTY_MASK GENMASK(2, 0)
42 -#define QCA808X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0)
43 -#define QCA808X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1)
44 -#define QCA808X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2)
45 -#define QCA808X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3)
46 -#define QCA808X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4)
47 -#define QCA808X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5)
48 -#define QCA808X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6)
49 -#define QCA808X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7)
50 -
51 #define QCA808X_MMD7_LED2_CTRL 0x8074
52 #define QCA808X_MMD7_LED2_FORCE_CTRL 0x8075
53 #define QCA808X_MMD7_LED1_CTRL 0x8076
54 @@ -92,51 +69,9 @@
55 #define QCA808X_MMD7_LED0_CTRL 0x8078
56 #define QCA808X_MMD7_LED_CTRL(x) (0x8078 - ((x) * 2))
57
58 -/* LED hw control pattern is the same for every LED */
59 -#define QCA808X_LED_PATTERN_MASK GENMASK(15, 0)
60 -#define QCA808X_LED_SPEED2500_ON BIT(15)
61 -#define QCA808X_LED_SPEED2500_BLINK BIT(14)
62 -/* Follow blink trigger even if duplex or speed condition doesn't match */
63 -#define QCA808X_LED_BLINK_CHECK_BYPASS BIT(13)
64 -#define QCA808X_LED_FULL_DUPLEX_ON BIT(12)
65 -#define QCA808X_LED_HALF_DUPLEX_ON BIT(11)
66 -#define QCA808X_LED_TX_BLINK BIT(10)
67 -#define QCA808X_LED_RX_BLINK BIT(9)
68 -#define QCA808X_LED_TX_ON_10MS BIT(8)
69 -#define QCA808X_LED_RX_ON_10MS BIT(7)
70 -#define QCA808X_LED_SPEED1000_ON BIT(6)
71 -#define QCA808X_LED_SPEED100_ON BIT(5)
72 -#define QCA808X_LED_SPEED10_ON BIT(4)
73 -#define QCA808X_LED_COLLISION_BLINK BIT(3)
74 -#define QCA808X_LED_SPEED1000_BLINK BIT(2)
75 -#define QCA808X_LED_SPEED100_BLINK BIT(1)
76 -#define QCA808X_LED_SPEED10_BLINK BIT(0)
77 -
78 #define QCA808X_MMD7_LED0_FORCE_CTRL 0x8079
79 #define QCA808X_MMD7_LED_FORCE_CTRL(x) (0x8079 - ((x) * 2))
80
81 -/* LED force ctrl is the same for every LED
82 - * No documentation exist for this, not even internal one
83 - * with NDA as QCOM gives only info about configuring
84 - * hw control pattern rules and doesn't indicate any way
85 - * to force the LED to specific mode.
86 - * These define comes from reverse and testing and maybe
87 - * lack of some info or some info are not entirely correct.
88 - * For the basic LED control and hw control these finding
89 - * are enough to support LED control in all the required APIs.
90 - *
91 - * On doing some comparison with implementation with qca807x,
92 - * it was found that it's 1:1 equal to it and confirms all the
93 - * reverse done. It was also found further specification with the
94 - * force mode and the blink modes.
95 - */
96 -#define QCA808X_LED_FORCE_EN BIT(15)
97 -#define QCA808X_LED_FORCE_MODE_MASK GENMASK(14, 13)
98 -#define QCA808X_LED_FORCE_BLINK_1 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3)
99 -#define QCA808X_LED_FORCE_BLINK_2 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2)
100 -#define QCA808X_LED_FORCE_ON FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1)
101 -#define QCA808X_LED_FORCE_OFF FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0)
102 -
103 #define QCA808X_MMD7_LED_POLARITY_CTRL 0x901a
104 /* QSDK sets by default 0x46 to this reg that sets BIT 6 for
105 * LED to active high. It's not clear what BIT 3 and BIT 4 does.
106 --- a/drivers/net/phy/qcom/qcom.h
107 +++ b/drivers/net/phy/qcom/qcom.h
108 @@ -103,6 +103,71 @@
109 /* Added for reference of existence but should be handled by wait_for_completion already */
110 #define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3))
111
112 +#define QCA808X_MMD7_LED_GLOBAL 0x8073
113 +#define QCA808X_LED_BLINK_1 GENMASK(11, 6)
114 +#define QCA808X_LED_BLINK_2 GENMASK(5, 0)
115 +/* Values are the same for both BLINK_1 and BLINK_2 */
116 +#define QCA808X_LED_BLINK_FREQ_MASK GENMASK(5, 3)
117 +#define QCA808X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0)
118 +#define QCA808X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1)
119 +#define QCA808X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2)
120 +#define QCA808X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3)
121 +#define QCA808X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4)
122 +#define QCA808X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5)
123 +#define QCA808X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6)
124 +#define QCA808X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7)
125 +#define QCA808X_LED_BLINK_DUTY_MASK GENMASK(2, 0)
126 +#define QCA808X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0)
127 +#define QCA808X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1)
128 +#define QCA808X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2)
129 +#define QCA808X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3)
130 +#define QCA808X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4)
131 +#define QCA808X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5)
132 +#define QCA808X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6)
133 +#define QCA808X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7)
134 +
135 +/* LED hw control pattern is the same for every LED */
136 +#define QCA808X_LED_PATTERN_MASK GENMASK(15, 0)
137 +#define QCA808X_LED_SPEED2500_ON BIT(15)
138 +#define QCA808X_LED_SPEED2500_BLINK BIT(14)
139 +/* Follow blink trigger even if duplex or speed condition doesn't match */
140 +#define QCA808X_LED_BLINK_CHECK_BYPASS BIT(13)
141 +#define QCA808X_LED_FULL_DUPLEX_ON BIT(12)
142 +#define QCA808X_LED_HALF_DUPLEX_ON BIT(11)
143 +#define QCA808X_LED_TX_BLINK BIT(10)
144 +#define QCA808X_LED_RX_BLINK BIT(9)
145 +#define QCA808X_LED_TX_ON_10MS BIT(8)
146 +#define QCA808X_LED_RX_ON_10MS BIT(7)
147 +#define QCA808X_LED_SPEED1000_ON BIT(6)
148 +#define QCA808X_LED_SPEED100_ON BIT(5)
149 +#define QCA808X_LED_SPEED10_ON BIT(4)
150 +#define QCA808X_LED_COLLISION_BLINK BIT(3)
151 +#define QCA808X_LED_SPEED1000_BLINK BIT(2)
152 +#define QCA808X_LED_SPEED100_BLINK BIT(1)
153 +#define QCA808X_LED_SPEED10_BLINK BIT(0)
154 +
155 +/* LED force ctrl is the same for every LED
156 + * No documentation exist for this, not even internal one
157 + * with NDA as QCOM gives only info about configuring
158 + * hw control pattern rules and doesn't indicate any way
159 + * to force the LED to specific mode.
160 + * These define comes from reverse and testing and maybe
161 + * lack of some info or some info are not entirely correct.
162 + * For the basic LED control and hw control these finding
163 + * are enough to support LED control in all the required APIs.
164 + *
165 + * On doing some comparison with implementation with qca807x,
166 + * it was found that it's 1:1 equal to it and confirms all the
167 + * reverse done. It was also found further specification with the
168 + * force mode and the blink modes.
169 + */
170 +#define QCA808X_LED_FORCE_EN BIT(15)
171 +#define QCA808X_LED_FORCE_MODE_MASK GENMASK(14, 13)
172 +#define QCA808X_LED_FORCE_BLINK_1 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3)
173 +#define QCA808X_LED_FORCE_BLINK_2 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2)
174 +#define QCA808X_LED_FORCE_ON FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1)
175 +#define QCA808X_LED_FORCE_OFF FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0)
176 +
177 #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C
178 #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B
179 #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A