Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2011 Freescale Semiconductor, Inc. |
Florinel Iordache | a618a5a | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 4 | * Copyright 2020 NXP |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 5 | * 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 Glass | 992b603 | 2020-07-19 10:15:39 -0600 | [diff] [blame] | 13 | #include <string.h> |
| 14 | |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 15 | typedef enum { |
Marek Behún | 8758453 | 2022-04-07 00:33:04 +0200 | [diff] [blame] | 16 | PHY_INTERFACE_MODE_NA, /* don't touch */ |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 17 | PHY_INTERFACE_MODE_INTERNAL, |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 18 | PHY_INTERFACE_MODE_MII, |
| 19 | PHY_INTERFACE_MODE_GMII, |
| 20 | PHY_INTERFACE_MODE_SGMII, |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 21 | PHY_INTERFACE_MODE_TBI, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 22 | PHY_INTERFACE_MODE_REVMII, |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 23 | PHY_INTERFACE_MODE_RMII, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 24 | PHY_INTERFACE_MODE_REVRMII, |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 25 | PHY_INTERFACE_MODE_RGMII, |
| 26 | PHY_INTERFACE_MODE_RGMII_ID, |
| 27 | PHY_INTERFACE_MODE_RGMII_RXID, |
| 28 | PHY_INTERFACE_MODE_RGMII_TXID, |
| 29 | PHY_INTERFACE_MODE_RTBI, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 30 | PHY_INTERFACE_MODE_SMII, |
| 31 | PHY_INTERFACE_MODE_XGMII, |
| 32 | PHY_INTERFACE_MODE_XLGMII, |
| 33 | PHY_INTERFACE_MODE_MOCA, |
| 34 | PHY_INTERFACE_MODE_QSGMII, |
| 35 | PHY_INTERFACE_MODE_TRGMII, |
| 36 | PHY_INTERFACE_MODE_100BASEX, |
Stefan Chulski | 6a0218d | 2021-05-03 08:08:44 +0200 | [diff] [blame] | 37 | PHY_INTERFACE_MODE_1000BASEX, |
| 38 | PHY_INTERFACE_MODE_2500BASEX, |
Marek Vasut | 24b8e48 | 2023-03-21 18:25:53 +0100 | [diff] [blame] | 39 | PHY_INTERFACE_MODE_5GBASER, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 40 | PHY_INTERFACE_MODE_RXAUI, |
| 41 | PHY_INTERFACE_MODE_XAUI, |
| 42 | /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */ |
| 43 | PHY_INTERFACE_MODE_10GBASER, |
| 44 | PHY_INTERFACE_MODE_25GBASER, |
| 45 | PHY_INTERFACE_MODE_USXGMII, |
| 46 | /* 10GBASE-KR - with Clause 73 AN */ |
| 47 | PHY_INTERFACE_MODE_10GKR, |
| 48 | PHY_INTERFACE_MODE_QUSGMII, |
| 49 | PHY_INTERFACE_MODE_1000BASEKX, |
| 50 | #if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A) |
| 51 | /* LX2160A SERDES modes */ |
Priyanka Jain | afaa0cb | 2018-08-27 15:15:19 +0530 | [diff] [blame] | 52 | PHY_INTERFACE_MODE_25G_AUI, |
| 53 | PHY_INTERFACE_MODE_XLAUI, |
| 54 | PHY_INTERFACE_MODE_CAUI2, |
| 55 | PHY_INTERFACE_MODE_CAUI4, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 56 | #endif |
| 57 | #if defined(CONFIG_PHY_NCSI) |
Samuel Mendoza-Jonas | b069c4a | 2019-06-18 11:37:18 +1000 | [diff] [blame] | 58 | PHY_INTERFACE_MODE_NCSI, |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 59 | #endif |
Marek Behún | 21a1836 | 2022-04-07 00:33:02 +0200 | [diff] [blame] | 60 | PHY_INTERFACE_MODE_MAX, |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 61 | } phy_interface_t; |
| 62 | |
| 63 | static const char * const phy_interface_strings[] = { |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 64 | [PHY_INTERFACE_MODE_NA] = "", |
| 65 | [PHY_INTERFACE_MODE_INTERNAL] = "internal", |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 66 | [PHY_INTERFACE_MODE_MII] = "mii", |
| 67 | [PHY_INTERFACE_MODE_GMII] = "gmii", |
| 68 | [PHY_INTERFACE_MODE_SGMII] = "sgmii", |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 69 | [PHY_INTERFACE_MODE_TBI] = "tbi", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 70 | [PHY_INTERFACE_MODE_REVMII] = "rev-mii", |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 71 | [PHY_INTERFACE_MODE_RMII] = "rmii", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 72 | [PHY_INTERFACE_MODE_REVRMII] = "rev-rmii", |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 73 | [PHY_INTERFACE_MODE_RGMII] = "rgmii", |
| 74 | [PHY_INTERFACE_MODE_RGMII_ID] = "rgmii-id", |
| 75 | [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid", |
| 76 | [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid", |
| 77 | [PHY_INTERFACE_MODE_RTBI] = "rtbi", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 78 | [PHY_INTERFACE_MODE_SMII] = "smii", |
| 79 | [PHY_INTERFACE_MODE_XGMII] = "xgmii", |
| 80 | [PHY_INTERFACE_MODE_XLGMII] = "xlgmii", |
| 81 | [PHY_INTERFACE_MODE_MOCA] = "moca", |
| 82 | [PHY_INTERFACE_MODE_QSGMII] = "qsgmii", |
| 83 | [PHY_INTERFACE_MODE_TRGMII] = "trgmii", |
Stefan Chulski | 6a0218d | 2021-05-03 08:08:44 +0200 | [diff] [blame] | 84 | [PHY_INTERFACE_MODE_1000BASEX] = "1000base-x", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 85 | [PHY_INTERFACE_MODE_1000BASEKX] = "1000base-kx", |
Stefan Chulski | 6a0218d | 2021-05-03 08:08:44 +0200 | [diff] [blame] | 86 | [PHY_INTERFACE_MODE_2500BASEX] = "2500base-x", |
Marek Vasut | 24b8e48 | 2023-03-21 18:25:53 +0100 | [diff] [blame] | 87 | [PHY_INTERFACE_MODE_5GBASER] = "5gbase-r", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 88 | [PHY_INTERFACE_MODE_RXAUI] = "rxaui", |
| 89 | [PHY_INTERFACE_MODE_XAUI] = "xaui", |
| 90 | [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", |
| 91 | [PHY_INTERFACE_MODE_25GBASER] = "25gbase-r", |
| 92 | [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", |
| 93 | [PHY_INTERFACE_MODE_10GKR] = "10gbase-kr", |
| 94 | [PHY_INTERFACE_MODE_100BASEX] = "100base-x", |
| 95 | [PHY_INTERFACE_MODE_QUSGMII] = "qusgmii", |
| 96 | #if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A) |
| 97 | /* LX2160A SERDES modes */ |
Priyanka Jain | afaa0cb | 2018-08-27 15:15:19 +0530 | [diff] [blame] | 98 | [PHY_INTERFACE_MODE_25G_AUI] = "25g-aui", |
| 99 | [PHY_INTERFACE_MODE_XLAUI] = "xlaui4", |
| 100 | [PHY_INTERFACE_MODE_CAUI2] = "caui2", |
| 101 | [PHY_INTERFACE_MODE_CAUI4] = "caui4", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 102 | #endif |
| 103 | #if defined(CONFIG_PHY_NCSI) |
Samuel Mendoza-Jonas | b069c4a | 2019-06-18 11:37:18 +1000 | [diff] [blame] | 104 | [PHY_INTERFACE_MODE_NCSI] = "NC-SI", |
Marek Vasut | adc3fdc | 2023-03-21 18:25:54 +0100 | [diff] [blame] | 105 | #endif |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 106 | }; |
| 107 | |
Florinel Iordache | a618a5a | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 108 | /* Backplane modes: |
| 109 | * are considered a sub-type of phy_interface_t: XGMII |
| 110 | * and are specified in "phy-connection-type" with one of the following strings |
| 111 | */ |
| 112 | static const char * const backplane_mode_strings[] = { |
| 113 | "10gbase-kr", |
| 114 | "40gbase-kr4", |
| 115 | }; |
| 116 | |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 117 | static inline const char *phy_string_for_interface(phy_interface_t i) |
| 118 | { |
| 119 | /* Default to unknown */ |
Tim Harvey | bcf1ba8 | 2022-05-10 15:49:10 -0700 | [diff] [blame] | 120 | if (i >= PHY_INTERFACE_MODE_MAX) |
Marek Behún | 48631e4 | 2022-04-07 00:33:03 +0200 | [diff] [blame] | 121 | i = PHY_INTERFACE_MODE_NA; |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 122 | |
| 123 | return phy_interface_strings[i]; |
| 124 | } |
| 125 | |
Florinel Iordache | a618a5a | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 126 | static inline bool is_backplane_mode(const char *phyconn) |
| 127 | { |
| 128 | int i; |
| 129 | |
| 130 | if (!phyconn) |
| 131 | return false; |
| 132 | for (i = 0; i < ARRAY_SIZE(backplane_mode_strings); i++) { |
| 133 | if (!strcmp(phyconn, backplane_mode_strings[i])) |
| 134 | return true; |
| 135 | } |
| 136 | return false; |
| 137 | } |
| 138 | |
Joe Hershberger | f5581fb | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 139 | #endif /* _PHY_INTERFACE_H */ |