blob: b74f4ccd84ad240c08c275c482b1f0f4a75d8d8d [file] [log] [blame]
Joe Hershbergerf5581fb2018-07-17 15:02:30 -05001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2011 Freescale Semiconductor, Inc.
Florinel Iordachea618a5a2020-03-16 15:35:59 +02004 * Copyright 2020 NXP
Joe Hershbergerf5581fb2018-07-17 15:02:30 -05005 * Andy Fleming <afleming@gmail.com>
6 *
7 * This file pretty much stolen from Linux's mii.h/ethtool.h/phy.h
8 */
9
10#ifndef _PHY_INTERFACE_H
11#define _PHY_INTERFACE_H
12
Simon Glass992b6032020-07-19 10:15:39 -060013#include <string.h>
Tom Rinidec7ea02024-05-20 13:35:03 -060014#include <linux/kernel.h>
Simon Glass992b6032020-07-19 10:15:39 -060015
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050016typedef enum {
Marek Behún87584532022-04-07 00:33:04 +020017 PHY_INTERFACE_MODE_NA, /* don't touch */
Marek Vasutadc3fdc2023-03-21 18:25:54 +010018 PHY_INTERFACE_MODE_INTERNAL,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050019 PHY_INTERFACE_MODE_MII,
20 PHY_INTERFACE_MODE_GMII,
21 PHY_INTERFACE_MODE_SGMII,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050022 PHY_INTERFACE_MODE_TBI,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010023 PHY_INTERFACE_MODE_REVMII,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050024 PHY_INTERFACE_MODE_RMII,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010025 PHY_INTERFACE_MODE_REVRMII,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050026 PHY_INTERFACE_MODE_RGMII,
27 PHY_INTERFACE_MODE_RGMII_ID,
28 PHY_INTERFACE_MODE_RGMII_RXID,
29 PHY_INTERFACE_MODE_RGMII_TXID,
30 PHY_INTERFACE_MODE_RTBI,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010031 PHY_INTERFACE_MODE_SMII,
32 PHY_INTERFACE_MODE_XGMII,
33 PHY_INTERFACE_MODE_XLGMII,
34 PHY_INTERFACE_MODE_MOCA,
35 PHY_INTERFACE_MODE_QSGMII,
36 PHY_INTERFACE_MODE_TRGMII,
37 PHY_INTERFACE_MODE_100BASEX,
Stefan Chulski6a0218d2021-05-03 08:08:44 +020038 PHY_INTERFACE_MODE_1000BASEX,
39 PHY_INTERFACE_MODE_2500BASEX,
Marek Vasut24b8e482023-03-21 18:25:53 +010040 PHY_INTERFACE_MODE_5GBASER,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010041 PHY_INTERFACE_MODE_RXAUI,
42 PHY_INTERFACE_MODE_XAUI,
43 /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */
44 PHY_INTERFACE_MODE_10GBASER,
45 PHY_INTERFACE_MODE_25GBASER,
46 PHY_INTERFACE_MODE_USXGMII,
47 /* 10GBASE-KR - with Clause 73 AN */
48 PHY_INTERFACE_MODE_10GKR,
49 PHY_INTERFACE_MODE_QUSGMII,
50 PHY_INTERFACE_MODE_1000BASEKX,
51#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
52 /* LX2160A SERDES modes */
Priyanka Jainafaa0cb2018-08-27 15:15:19 +053053 PHY_INTERFACE_MODE_25G_AUI,
54 PHY_INTERFACE_MODE_XLAUI,
55 PHY_INTERFACE_MODE_CAUI2,
56 PHY_INTERFACE_MODE_CAUI4,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010057#endif
58#if defined(CONFIG_PHY_NCSI)
Samuel Mendoza-Jonasb069c4a2019-06-18 11:37:18 +100059 PHY_INTERFACE_MODE_NCSI,
Marek Vasutadc3fdc2023-03-21 18:25:54 +010060#endif
Marek Behún21a18362022-04-07 00:33:02 +020061 PHY_INTERFACE_MODE_MAX,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050062} phy_interface_t;
63
64static const char * const phy_interface_strings[] = {
Marek Vasutadc3fdc2023-03-21 18:25:54 +010065 [PHY_INTERFACE_MODE_NA] = "",
66 [PHY_INTERFACE_MODE_INTERNAL] = "internal",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050067 [PHY_INTERFACE_MODE_MII] = "mii",
68 [PHY_INTERFACE_MODE_GMII] = "gmii",
69 [PHY_INTERFACE_MODE_SGMII] = "sgmii",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050070 [PHY_INTERFACE_MODE_TBI] = "tbi",
Marek Vasutadc3fdc2023-03-21 18:25:54 +010071 [PHY_INTERFACE_MODE_REVMII] = "rev-mii",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050072 [PHY_INTERFACE_MODE_RMII] = "rmii",
Marek Vasutadc3fdc2023-03-21 18:25:54 +010073 [PHY_INTERFACE_MODE_REVRMII] = "rev-rmii",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050074 [PHY_INTERFACE_MODE_RGMII] = "rgmii",
75 [PHY_INTERFACE_MODE_RGMII_ID] = "rgmii-id",
76 [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
77 [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
78 [PHY_INTERFACE_MODE_RTBI] = "rtbi",
Marek Vasutadc3fdc2023-03-21 18:25:54 +010079 [PHY_INTERFACE_MODE_SMII] = "smii",
80 [PHY_INTERFACE_MODE_XGMII] = "xgmii",
81 [PHY_INTERFACE_MODE_XLGMII] = "xlgmii",
82 [PHY_INTERFACE_MODE_MOCA] = "moca",
83 [PHY_INTERFACE_MODE_QSGMII] = "qsgmii",
84 [PHY_INTERFACE_MODE_TRGMII] = "trgmii",
Stefan Chulski6a0218d2021-05-03 08:08:44 +020085 [PHY_INTERFACE_MODE_1000BASEX] = "1000base-x",
Marek Vasutadc3fdc2023-03-21 18:25:54 +010086 [PHY_INTERFACE_MODE_1000BASEKX] = "1000base-kx",
Stefan Chulski6a0218d2021-05-03 08:08:44 +020087 [PHY_INTERFACE_MODE_2500BASEX] = "2500base-x",
Marek Vasut24b8e482023-03-21 18:25:53 +010088 [PHY_INTERFACE_MODE_5GBASER] = "5gbase-r",
Marek Vasutadc3fdc2023-03-21 18:25:54 +010089 [PHY_INTERFACE_MODE_RXAUI] = "rxaui",
90 [PHY_INTERFACE_MODE_XAUI] = "xaui",
91 [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r",
92 [PHY_INTERFACE_MODE_25GBASER] = "25gbase-r",
93 [PHY_INTERFACE_MODE_USXGMII] = "usxgmii",
94 [PHY_INTERFACE_MODE_10GKR] = "10gbase-kr",
95 [PHY_INTERFACE_MODE_100BASEX] = "100base-x",
96 [PHY_INTERFACE_MODE_QUSGMII] = "qusgmii",
97#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
98 /* LX2160A SERDES modes */
Priyanka Jainafaa0cb2018-08-27 15:15:19 +053099 [PHY_INTERFACE_MODE_25G_AUI] = "25g-aui",
100 [PHY_INTERFACE_MODE_XLAUI] = "xlaui4",
101 [PHY_INTERFACE_MODE_CAUI2] = "caui2",
102 [PHY_INTERFACE_MODE_CAUI4] = "caui4",
Marek Vasutadc3fdc2023-03-21 18:25:54 +0100103#endif
104#if defined(CONFIG_PHY_NCSI)
Samuel Mendoza-Jonasb069c4a2019-06-18 11:37:18 +1000105 [PHY_INTERFACE_MODE_NCSI] = "NC-SI",
Marek Vasutadc3fdc2023-03-21 18:25:54 +0100106#endif
Joe Hershbergerf5581fb2018-07-17 15:02:30 -0500107};
108
Florinel Iordachea618a5a2020-03-16 15:35:59 +0200109/* Backplane modes:
110 * are considered a sub-type of phy_interface_t: XGMII
111 * and are specified in "phy-connection-type" with one of the following strings
112 */
113static const char * const backplane_mode_strings[] = {
114 "10gbase-kr",
115 "40gbase-kr4",
116};
117
Joe Hershbergerf5581fb2018-07-17 15:02:30 -0500118static inline const char *phy_string_for_interface(phy_interface_t i)
119{
120 /* Default to unknown */
Tim Harveybcf1ba82022-05-10 15:49:10 -0700121 if (i >= PHY_INTERFACE_MODE_MAX)
Marek Behún48631e42022-04-07 00:33:03 +0200122 i = PHY_INTERFACE_MODE_NA;
Joe Hershbergerf5581fb2018-07-17 15:02:30 -0500123
124 return phy_interface_strings[i];
125}
126
Florinel Iordachea618a5a2020-03-16 15:35:59 +0200127static inline bool is_backplane_mode(const char *phyconn)
128{
129 int i;
130
131 if (!phyconn)
132 return false;
133 for (i = 0; i < ARRAY_SIZE(backplane_mode_strings); i++) {
134 if (!strcmp(phyconn, backplane_mode_strings[i]))
135 return true;
136 }
137 return false;
138}
139
Joe Hershbergerf5581fb2018-07-17 15:02:30 -0500140#endif /* _PHY_INTERFACE_H */