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