blob: 59e119a6399b994909a402da95798517b944d158 [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>
14
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050015typedef enum {
16 PHY_INTERFACE_MODE_MII,
17 PHY_INTERFACE_MODE_GMII,
18 PHY_INTERFACE_MODE_SGMII,
19 PHY_INTERFACE_MODE_SGMII_2500,
20 PHY_INTERFACE_MODE_QSGMII,
21 PHY_INTERFACE_MODE_TBI,
22 PHY_INTERFACE_MODE_RMII,
23 PHY_INTERFACE_MODE_RGMII,
24 PHY_INTERFACE_MODE_RGMII_ID,
25 PHY_INTERFACE_MODE_RGMII_RXID,
26 PHY_INTERFACE_MODE_RGMII_TXID,
27 PHY_INTERFACE_MODE_RTBI,
Stefan Chulski6a0218d2021-05-03 08:08:44 +020028 PHY_INTERFACE_MODE_1000BASEX,
29 PHY_INTERFACE_MODE_2500BASEX,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050030 PHY_INTERFACE_MODE_XGMII,
31 PHY_INTERFACE_MODE_XAUI,
32 PHY_INTERFACE_MODE_RXAUI,
33 PHY_INTERFACE_MODE_SFI,
34 PHY_INTERFACE_MODE_INTERNAL,
Priyanka Jainafaa0cb2018-08-27 15:15:19 +053035 PHY_INTERFACE_MODE_25G_AUI,
36 PHY_INTERFACE_MODE_XLAUI,
37 PHY_INTERFACE_MODE_CAUI2,
38 PHY_INTERFACE_MODE_CAUI4,
Samuel Mendoza-Jonasb069c4a2019-06-18 11:37:18 +100039 PHY_INTERFACE_MODE_NCSI,
Vladimir Oltean6a6e4022021-09-18 15:32:34 +030040 PHY_INTERFACE_MODE_10GBASER,
Alex Marginean5219f682019-11-14 18:28:28 +020041 PHY_INTERFACE_MODE_USXGMII,
Marek Behún48631e42022-04-07 00:33:03 +020042 PHY_INTERFACE_MODE_NA, /* Must be last */
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050043
Marek Behún21a18362022-04-07 00:33:02 +020044 PHY_INTERFACE_MODE_MAX,
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050045} phy_interface_t;
46
47static const char * const phy_interface_strings[] = {
48 [PHY_INTERFACE_MODE_MII] = "mii",
49 [PHY_INTERFACE_MODE_GMII] = "gmii",
50 [PHY_INTERFACE_MODE_SGMII] = "sgmii",
51 [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500",
52 [PHY_INTERFACE_MODE_QSGMII] = "qsgmii",
53 [PHY_INTERFACE_MODE_TBI] = "tbi",
54 [PHY_INTERFACE_MODE_RMII] = "rmii",
55 [PHY_INTERFACE_MODE_RGMII] = "rgmii",
56 [PHY_INTERFACE_MODE_RGMII_ID] = "rgmii-id",
57 [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
58 [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
59 [PHY_INTERFACE_MODE_RTBI] = "rtbi",
Stefan Chulski6a0218d2021-05-03 08:08:44 +020060 [PHY_INTERFACE_MODE_1000BASEX] = "1000base-x",
61 [PHY_INTERFACE_MODE_2500BASEX] = "2500base-x",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050062 [PHY_INTERFACE_MODE_XGMII] = "xgmii",
63 [PHY_INTERFACE_MODE_XAUI] = "xaui",
64 [PHY_INTERFACE_MODE_RXAUI] = "rxaui",
65 [PHY_INTERFACE_MODE_SFI] = "sfi",
66 [PHY_INTERFACE_MODE_INTERNAL] = "internal",
Priyanka Jainafaa0cb2018-08-27 15:15:19 +053067 [PHY_INTERFACE_MODE_25G_AUI] = "25g-aui",
68 [PHY_INTERFACE_MODE_XLAUI] = "xlaui4",
69 [PHY_INTERFACE_MODE_CAUI2] = "caui2",
70 [PHY_INTERFACE_MODE_CAUI4] = "caui4",
Samuel Mendoza-Jonasb069c4a2019-06-18 11:37:18 +100071 [PHY_INTERFACE_MODE_NCSI] = "NC-SI",
Vladimir Oltean6a6e4022021-09-18 15:32:34 +030072 [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r",
Alex Marginean5219f682019-11-14 18:28:28 +020073 [PHY_INTERFACE_MODE_USXGMII] = "usxgmii",
Marek Behún48631e42022-04-07 00:33:03 +020074 [PHY_INTERFACE_MODE_NA] = "",
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050075};
76
Florinel Iordachea618a5a2020-03-16 15:35:59 +020077/* Backplane modes:
78 * are considered a sub-type of phy_interface_t: XGMII
79 * and are specified in "phy-connection-type" with one of the following strings
80 */
81static const char * const backplane_mode_strings[] = {
82 "10gbase-kr",
83 "40gbase-kr4",
84};
85
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050086static inline const char *phy_string_for_interface(phy_interface_t i)
87{
88 /* Default to unknown */
Marek Behún48631e42022-04-07 00:33:03 +020089 if (i > PHY_INTERFACE_MODE_NA)
90 i = PHY_INTERFACE_MODE_NA;
Joe Hershbergerf5581fb2018-07-17 15:02:30 -050091
92 return phy_interface_strings[i];
93}
94
Florinel Iordachea618a5a2020-03-16 15:35:59 +020095static inline bool is_backplane_mode(const char *phyconn)
96{
97 int i;
98
99 if (!phyconn)
100 return false;
101 for (i = 0; i < ARRAY_SIZE(backplane_mode_strings); i++) {
102 if (!strcmp(phyconn, backplane_mode_strings[i]))
103 return true;
104 }
105 return false;
106}
107
Joe Hershbergerf5581fb2018-07-17 15:02:30 -0500108#endif /* _PHY_INTERFACE_H */