Joe Hershberger | f070b1a | 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 | 5d3bcdb | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 4 | * Copyright 2020 NXP |
Joe Hershberger | f070b1a | 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 | 2a64ada | 2020-07-19 10:15:39 -0600 | [diff] [blame] | 13 | #include <string.h> |
| 14 | |
Joe Hershberger | f070b1a | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 15 | typedef 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, |
| 28 | PHY_INTERFACE_MODE_XGMII, |
| 29 | PHY_INTERFACE_MODE_XAUI, |
| 30 | PHY_INTERFACE_MODE_RXAUI, |
| 31 | PHY_INTERFACE_MODE_SFI, |
| 32 | PHY_INTERFACE_MODE_INTERNAL, |
Priyanka Jain | 5b72398 | 2018-08-27 15:15:19 +0530 | [diff] [blame] | 33 | PHY_INTERFACE_MODE_25G_AUI, |
| 34 | PHY_INTERFACE_MODE_XLAUI, |
| 35 | PHY_INTERFACE_MODE_CAUI2, |
| 36 | PHY_INTERFACE_MODE_CAUI4, |
Samuel Mendoza-Jonas | e2ffeaa | 2019-06-18 11:37:18 +1000 | [diff] [blame] | 37 | PHY_INTERFACE_MODE_NCSI, |
Alex Marginean | 17285fc | 2019-11-14 18:28:28 +0200 | [diff] [blame] | 38 | PHY_INTERFACE_MODE_XFI, |
| 39 | PHY_INTERFACE_MODE_USXGMII, |
Joe Hershberger | f070b1a | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 40 | PHY_INTERFACE_MODE_NONE, /* Must be last */ |
| 41 | |
| 42 | PHY_INTERFACE_MODE_COUNT, |
| 43 | } phy_interface_t; |
| 44 | |
| 45 | static const char * const phy_interface_strings[] = { |
| 46 | [PHY_INTERFACE_MODE_MII] = "mii", |
| 47 | [PHY_INTERFACE_MODE_GMII] = "gmii", |
| 48 | [PHY_INTERFACE_MODE_SGMII] = "sgmii", |
| 49 | [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500", |
| 50 | [PHY_INTERFACE_MODE_QSGMII] = "qsgmii", |
| 51 | [PHY_INTERFACE_MODE_TBI] = "tbi", |
| 52 | [PHY_INTERFACE_MODE_RMII] = "rmii", |
| 53 | [PHY_INTERFACE_MODE_RGMII] = "rgmii", |
| 54 | [PHY_INTERFACE_MODE_RGMII_ID] = "rgmii-id", |
| 55 | [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid", |
| 56 | [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid", |
| 57 | [PHY_INTERFACE_MODE_RTBI] = "rtbi", |
| 58 | [PHY_INTERFACE_MODE_XGMII] = "xgmii", |
| 59 | [PHY_INTERFACE_MODE_XAUI] = "xaui", |
| 60 | [PHY_INTERFACE_MODE_RXAUI] = "rxaui", |
| 61 | [PHY_INTERFACE_MODE_SFI] = "sfi", |
| 62 | [PHY_INTERFACE_MODE_INTERNAL] = "internal", |
Priyanka Jain | 5b72398 | 2018-08-27 15:15:19 +0530 | [diff] [blame] | 63 | [PHY_INTERFACE_MODE_25G_AUI] = "25g-aui", |
| 64 | [PHY_INTERFACE_MODE_XLAUI] = "xlaui4", |
| 65 | [PHY_INTERFACE_MODE_CAUI2] = "caui2", |
| 66 | [PHY_INTERFACE_MODE_CAUI4] = "caui4", |
Samuel Mendoza-Jonas | e2ffeaa | 2019-06-18 11:37:18 +1000 | [diff] [blame] | 67 | [PHY_INTERFACE_MODE_NCSI] = "NC-SI", |
Alex Marginean | 17285fc | 2019-11-14 18:28:28 +0200 | [diff] [blame] | 68 | [PHY_INTERFACE_MODE_XFI] = "xfi", |
| 69 | [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", |
Joe Hershberger | f070b1a | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 70 | [PHY_INTERFACE_MODE_NONE] = "", |
| 71 | }; |
| 72 | |
Florinel Iordache | 5d3bcdb | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 73 | /* Backplane modes: |
| 74 | * are considered a sub-type of phy_interface_t: XGMII |
| 75 | * and are specified in "phy-connection-type" with one of the following strings |
| 76 | */ |
| 77 | static const char * const backplane_mode_strings[] = { |
| 78 | "10gbase-kr", |
| 79 | "40gbase-kr4", |
| 80 | }; |
| 81 | |
Joe Hershberger | f070b1a | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 82 | static inline const char *phy_string_for_interface(phy_interface_t i) |
| 83 | { |
| 84 | /* Default to unknown */ |
| 85 | if (i > PHY_INTERFACE_MODE_NONE) |
| 86 | i = PHY_INTERFACE_MODE_NONE; |
| 87 | |
| 88 | return phy_interface_strings[i]; |
| 89 | } |
| 90 | |
Florinel Iordache | 5d3bcdb | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 91 | static inline bool is_backplane_mode(const char *phyconn) |
| 92 | { |
| 93 | int i; |
| 94 | |
| 95 | if (!phyconn) |
| 96 | return false; |
| 97 | for (i = 0; i < ARRAY_SIZE(backplane_mode_strings); i++) { |
| 98 | if (!strcmp(phyconn, backplane_mode_strings[i])) |
| 99 | return true; |
| 100 | } |
| 101 | return false; |
| 102 | } |
| 103 | |
Joe Hershberger | f070b1a | 2018-07-17 15:02:30 -0500 | [diff] [blame] | 104 | #endif /* _PHY_INTERFACE_H */ |