1 From 737eb75a815f9c08dcbb6631db57f4f4b0540a5b Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Tue, 6 Feb 2024 18:31:07 +0100
4 Subject: [PATCH 04/10] net: phy: qcom: move more function to shared library
6 Move more function to shared library in preparation for introduction of
7 new PHY Family qca807x that will make use of both functions from at803x
8 and qca808x as it's a transition PHY with some implementation of at803x
9 and some from the new qca808x.
11 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
15 drivers/net/phy/qcom/at803x.c | 35 -----
16 drivers/net/phy/qcom/qca808x.c | 205 ----------------------------
17 drivers/net/phy/qcom/qcom-phy-lib.c | 193 ++++++++++++++++++++++++++
18 drivers/net/phy/qcom/qcom.h | 51 +++++++
19 4 files changed, 244 insertions(+), 240 deletions(-)
21 --- a/drivers/net/phy/qcom/at803x.c
22 +++ b/drivers/net/phy/qcom/at803x.c
23 @@ -504,41 +504,6 @@ static void at803x_link_change_notify(st
27 -static int at803x_read_status(struct phy_device *phydev)
29 - struct at803x_ss_mask ss_mask = { 0 };
30 - int err, old_link = phydev->link;
32 - /* Update the link, but return if there was an error */
33 - err = genphy_update_link(phydev);
37 - /* why bother the PHY if nothing can have changed */
38 - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
41 - phydev->speed = SPEED_UNKNOWN;
42 - phydev->duplex = DUPLEX_UNKNOWN;
44 - phydev->asym_pause = 0;
46 - err = genphy_read_lpa(phydev);
50 - ss_mask.speed_mask = AT803X_SS_SPEED_MASK;
51 - ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK);
52 - err = at803x_read_specific_status(phydev, ss_mask);
56 - if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete)
57 - phy_resolve_aneg_pause(phydev);
62 static int at803x_config_aneg(struct phy_device *phydev)
64 struct at803x_priv *priv = phydev->priv;
65 --- a/drivers/net/phy/qcom/qca808x.c
66 +++ b/drivers/net/phy/qcom/qca808x.c
69 #include <linux/phy.h>
70 #include <linux/module.h>
71 -#include <linux/ethtool_netlink.h>
76 #define QCA808X_DBG_AN_TEST 0xb
77 #define QCA808X_HIBERNATION_EN BIT(15)
79 -#define QCA808X_CDT_ENABLE_TEST BIT(15)
80 -#define QCA808X_CDT_INTER_CHECK_DIS BIT(13)
81 -#define QCA808X_CDT_STATUS BIT(11)
82 -#define QCA808X_CDT_LENGTH_UNIT BIT(10)
84 -#define QCA808X_MMD3_CDT_STATUS 0x8064
85 -#define QCA808X_MMD3_CDT_DIAG_PAIR_A 0x8065
86 -#define QCA808X_MMD3_CDT_DIAG_PAIR_B 0x8066
87 -#define QCA808X_MMD3_CDT_DIAG_PAIR_C 0x8067
88 -#define QCA808X_MMD3_CDT_DIAG_PAIR_D 0x8068
89 -#define QCA808X_CDT_DIAG_LENGTH_SAME_SHORT GENMASK(15, 8)
90 -#define QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT GENMASK(7, 0)
92 -#define QCA808X_CDT_CODE_PAIR_A GENMASK(15, 12)
93 -#define QCA808X_CDT_CODE_PAIR_B GENMASK(11, 8)
94 -#define QCA808X_CDT_CODE_PAIR_C GENMASK(7, 4)
95 -#define QCA808X_CDT_CODE_PAIR_D GENMASK(3, 0)
97 -#define QCA808X_CDT_STATUS_STAT_TYPE GENMASK(1, 0)
98 -#define QCA808X_CDT_STATUS_STAT_FAIL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 0)
99 -#define QCA808X_CDT_STATUS_STAT_NORMAL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 1)
100 -#define QCA808X_CDT_STATUS_STAT_SAME_OPEN FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 2)
101 -#define QCA808X_CDT_STATUS_STAT_SAME_SHORT FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 3)
103 -#define QCA808X_CDT_STATUS_STAT_MDI GENMASK(3, 2)
104 -#define QCA808X_CDT_STATUS_STAT_MDI1 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 1)
105 -#define QCA808X_CDT_STATUS_STAT_MDI2 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 2)
106 -#define QCA808X_CDT_STATUS_STAT_MDI3 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 3)
108 -/* NORMAL are MDI with type set to 0 */
109 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI1
110 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
111 - QCA808X_CDT_STATUS_STAT_MDI1)
112 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
113 - QCA808X_CDT_STATUS_STAT_MDI1)
114 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI2
115 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
116 - QCA808X_CDT_STATUS_STAT_MDI2)
117 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
118 - QCA808X_CDT_STATUS_STAT_MDI2)
119 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI3
120 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
121 - QCA808X_CDT_STATUS_STAT_MDI3)
122 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
123 - QCA808X_CDT_STATUS_STAT_MDI3)
125 -/* Added for reference of existence but should be handled by wait_for_completion already */
126 -#define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3))
128 #define QCA808X_MMD7_LED_GLOBAL 0x8073
129 #define QCA808X_LED_BLINK_1 GENMASK(11, 6)
130 #define QCA808X_LED_BLINK_2 GENMASK(5, 0)
131 @@ -406,86 +356,6 @@ static int qca808x_soft_reset(struct phy
135 -static bool qca808x_cdt_fault_length_valid(int cdt_code)
137 - switch (cdt_code) {
138 - case QCA808X_CDT_STATUS_STAT_SAME_SHORT:
139 - case QCA808X_CDT_STATUS_STAT_SAME_OPEN:
140 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL:
141 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN:
142 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT:
143 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL:
144 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN:
145 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT:
146 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL:
147 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN:
148 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT:
155 -static int qca808x_cable_test_result_trans(int cdt_code)
157 - switch (cdt_code) {
158 - case QCA808X_CDT_STATUS_STAT_NORMAL:
159 - return ETHTOOL_A_CABLE_RESULT_CODE_OK;
160 - case QCA808X_CDT_STATUS_STAT_SAME_SHORT:
161 - return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT;
162 - case QCA808X_CDT_STATUS_STAT_SAME_OPEN:
163 - return ETHTOOL_A_CABLE_RESULT_CODE_OPEN;
164 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL:
165 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN:
166 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT:
167 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL:
168 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN:
169 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT:
170 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL:
171 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN:
172 - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT:
173 - return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT;
174 - case QCA808X_CDT_STATUS_STAT_FAIL:
176 - return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
180 -static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair,
184 - u32 cdt_length_reg = 0;
187 - case ETHTOOL_A_CABLE_PAIR_A:
188 - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_A;
190 - case ETHTOOL_A_CABLE_PAIR_B:
191 - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_B;
193 - case ETHTOOL_A_CABLE_PAIR_C:
194 - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_C;
196 - case ETHTOOL_A_CABLE_PAIR_D:
197 - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_D;
203 - val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg);
207 - if (result == ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT)
208 - val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_SAME_SHORT, val);
210 - val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT, val);
212 - return at803x_cdt_fault_length(val);
215 static int qca808x_cable_test_start(struct phy_device *phydev)
218 @@ -526,81 +396,6 @@ static int qca808x_cable_test_start(stru
223 -static int qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair,
226 - int length, result;
230 - case ETHTOOL_A_CABLE_PAIR_A:
231 - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status);
233 - case ETHTOOL_A_CABLE_PAIR_B:
234 - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status);
236 - case ETHTOOL_A_CABLE_PAIR_C:
237 - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status);
239 - case ETHTOOL_A_CABLE_PAIR_D:
240 - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status);
246 - result = qca808x_cable_test_result_trans(pair_code);
247 - ethnl_cable_test_result(phydev, pair, result);
249 - if (qca808x_cdt_fault_length_valid(pair_code)) {
250 - length = qca808x_cdt_fault_length(phydev, pair, result);
251 - ethnl_cable_test_fault_length(phydev, pair, length);
257 -static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished)
263 - val = QCA808X_CDT_ENABLE_TEST |
264 - QCA808X_CDT_LENGTH_UNIT;
265 - ret = at803x_cdt_start(phydev, val);
269 - ret = at803x_cdt_wait_for_completion(phydev, QCA808X_CDT_ENABLE_TEST);
273 - val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS);
277 - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val);
281 - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val);
285 - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val);
289 - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val);
298 static int qca808x_get_features(struct phy_device *phydev)
300 --- a/drivers/net/phy/qcom/qcom-phy-lib.c
301 +++ b/drivers/net/phy/qcom/qcom-phy-lib.c
304 #include <linux/netdevice.h>
305 #include <linux/etherdevice.h>
306 +#include <linux/ethtool_netlink.h>
310 @@ -311,6 +312,42 @@ int at803x_prepare_config_aneg(struct ph
312 EXPORT_SYMBOL_GPL(at803x_prepare_config_aneg);
314 +int at803x_read_status(struct phy_device *phydev)
316 + struct at803x_ss_mask ss_mask = { 0 };
317 + int err, old_link = phydev->link;
319 + /* Update the link, but return if there was an error */
320 + err = genphy_update_link(phydev);
324 + /* why bother the PHY if nothing can have changed */
325 + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
328 + phydev->speed = SPEED_UNKNOWN;
329 + phydev->duplex = DUPLEX_UNKNOWN;
331 + phydev->asym_pause = 0;
333 + err = genphy_read_lpa(phydev);
337 + ss_mask.speed_mask = AT803X_SS_SPEED_MASK;
338 + ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK);
339 + err = at803x_read_specific_status(phydev, ss_mask);
343 + if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete)
344 + phy_resolve_aneg_pause(phydev);
348 +EXPORT_SYMBOL_GPL(at803x_read_status);
350 static int at803x_get_downshift(struct phy_device *phydev, u8 *d)
353 @@ -427,3 +464,159 @@ int at803x_cdt_wait_for_completion(struc
354 return ret < 0 ? ret : 0;
356 EXPORT_SYMBOL_GPL(at803x_cdt_wait_for_completion);
358 +static bool qca808x_cdt_fault_length_valid(int cdt_code)
360 + switch (cdt_code) {
361 + case QCA808X_CDT_STATUS_STAT_SAME_SHORT:
362 + case QCA808X_CDT_STATUS_STAT_SAME_OPEN:
363 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL:
364 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN:
365 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT:
366 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL:
367 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN:
368 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT:
369 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL:
370 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN:
371 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT:
378 +static int qca808x_cable_test_result_trans(int cdt_code)
380 + switch (cdt_code) {
381 + case QCA808X_CDT_STATUS_STAT_NORMAL:
382 + return ETHTOOL_A_CABLE_RESULT_CODE_OK;
383 + case QCA808X_CDT_STATUS_STAT_SAME_SHORT:
384 + return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT;
385 + case QCA808X_CDT_STATUS_STAT_SAME_OPEN:
386 + return ETHTOOL_A_CABLE_RESULT_CODE_OPEN;
387 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL:
388 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN:
389 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT:
390 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL:
391 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN:
392 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT:
393 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL:
394 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN:
395 + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT:
396 + return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT;
397 + case QCA808X_CDT_STATUS_STAT_FAIL:
399 + return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
403 +static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair,
407 + u32 cdt_length_reg = 0;
410 + case ETHTOOL_A_CABLE_PAIR_A:
411 + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_A;
413 + case ETHTOOL_A_CABLE_PAIR_B:
414 + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_B;
416 + case ETHTOOL_A_CABLE_PAIR_C:
417 + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_C;
419 + case ETHTOOL_A_CABLE_PAIR_D:
420 + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_D;
426 + val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg);
430 + if (result == ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT)
431 + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_SAME_SHORT, val);
433 + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT, val);
435 + return at803x_cdt_fault_length(val);
438 +static int qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair,
441 + int length, result;
445 + case ETHTOOL_A_CABLE_PAIR_A:
446 + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status);
448 + case ETHTOOL_A_CABLE_PAIR_B:
449 + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status);
451 + case ETHTOOL_A_CABLE_PAIR_C:
452 + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status);
454 + case ETHTOOL_A_CABLE_PAIR_D:
455 + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status);
461 + result = qca808x_cable_test_result_trans(pair_code);
462 + ethnl_cable_test_result(phydev, pair, result);
464 + if (qca808x_cdt_fault_length_valid(pair_code)) {
465 + length = qca808x_cdt_fault_length(phydev, pair, result);
466 + ethnl_cable_test_fault_length(phydev, pair, length);
472 +int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished)
478 + val = QCA808X_CDT_ENABLE_TEST |
479 + QCA808X_CDT_LENGTH_UNIT;
480 + ret = at803x_cdt_start(phydev, val);
484 + ret = at803x_cdt_wait_for_completion(phydev, QCA808X_CDT_ENABLE_TEST);
488 + val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS);
492 + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val);
496 + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val);
500 + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val);
504 + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val);
512 +EXPORT_SYMBOL_GPL(qca808x_cable_test_get_status);
513 --- a/drivers/net/phy/qcom/qcom.h
514 +++ b/drivers/net/phy/qcom/qcom.h
516 #define AT803X_CDT_STATUS_STAT_MASK GENMASK(9, 8)
517 #define AT803X_CDT_STATUS_DELTA_TIME_MASK GENMASK(7, 0)
519 +#define QCA808X_CDT_ENABLE_TEST BIT(15)
520 +#define QCA808X_CDT_INTER_CHECK_DIS BIT(13)
521 +#define QCA808X_CDT_STATUS BIT(11)
522 +#define QCA808X_CDT_LENGTH_UNIT BIT(10)
524 +#define QCA808X_MMD3_CDT_STATUS 0x8064
525 +#define QCA808X_MMD3_CDT_DIAG_PAIR_A 0x8065
526 +#define QCA808X_MMD3_CDT_DIAG_PAIR_B 0x8066
527 +#define QCA808X_MMD3_CDT_DIAG_PAIR_C 0x8067
528 +#define QCA808X_MMD3_CDT_DIAG_PAIR_D 0x8068
529 +#define QCA808X_CDT_DIAG_LENGTH_SAME_SHORT GENMASK(15, 8)
530 +#define QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT GENMASK(7, 0)
532 +#define QCA808X_CDT_CODE_PAIR_A GENMASK(15, 12)
533 +#define QCA808X_CDT_CODE_PAIR_B GENMASK(11, 8)
534 +#define QCA808X_CDT_CODE_PAIR_C GENMASK(7, 4)
535 +#define QCA808X_CDT_CODE_PAIR_D GENMASK(3, 0)
537 +#define QCA808X_CDT_STATUS_STAT_TYPE GENMASK(1, 0)
538 +#define QCA808X_CDT_STATUS_STAT_FAIL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 0)
539 +#define QCA808X_CDT_STATUS_STAT_NORMAL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 1)
540 +#define QCA808X_CDT_STATUS_STAT_SAME_OPEN FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 2)
541 +#define QCA808X_CDT_STATUS_STAT_SAME_SHORT FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 3)
543 +#define QCA808X_CDT_STATUS_STAT_MDI GENMASK(3, 2)
544 +#define QCA808X_CDT_STATUS_STAT_MDI1 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 1)
545 +#define QCA808X_CDT_STATUS_STAT_MDI2 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 2)
546 +#define QCA808X_CDT_STATUS_STAT_MDI3 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 3)
548 +/* NORMAL are MDI with type set to 0 */
549 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI1
550 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
551 + QCA808X_CDT_STATUS_STAT_MDI1)
552 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
553 + QCA808X_CDT_STATUS_STAT_MDI1)
554 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI2
555 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
556 + QCA808X_CDT_STATUS_STAT_MDI2)
557 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
558 + QCA808X_CDT_STATUS_STAT_MDI2)
559 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI3
560 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\
561 + QCA808X_CDT_STATUS_STAT_MDI3)
562 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\
563 + QCA808X_CDT_STATUS_STAT_MDI3)
565 +/* Added for reference of existence but should be handled by wait_for_completion already */
566 +#define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3))
568 #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C
569 #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B
570 #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A
571 @@ -110,6 +159,7 @@ int at803x_read_specific_status(struct p
572 struct at803x_ss_mask ss_mask);
573 int at803x_config_mdix(struct phy_device *phydev, u8 ctrl);
574 int at803x_prepare_config_aneg(struct phy_device *phydev);
575 +int at803x_read_status(struct phy_device *phydev);
576 int at803x_get_tunable(struct phy_device *phydev,
577 struct ethtool_tunable *tuna, void *data);
578 int at803x_set_tunable(struct phy_device *phydev,
579 @@ -118,3 +168,4 @@ int at803x_cdt_fault_length(int dt);
580 int at803x_cdt_start(struct phy_device *phydev, u32 cdt_start);
581 int at803x_cdt_wait_for_completion(struct phy_device *phydev,
583 +int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished);