1 /********************************************************************************
2 Copyright (C) 2016 Marvell International Ltd.
3 
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5 
6 *******************************************************************************/
7 #ifndef __MV_PHY_DXE_H__
8 #define __MV_PHY_DXE_H__
9 
10 #define MII_BMCR                       0x00  /* Basic mode control Register */
11 #define MII_BMSR                       0x01  /* Basic mode status Register  */
12 
13 /* BMCR */
14 #define BMCR_ANRESTART                 0x0200 /* 1 = Restart autonegotiation */
15 #define BMCR_ISOLATE                   0x0400 /* 0 = Isolate PHY */
16 #define BMCR_ANENABLE                  0x1000 /* 1 = Enable autonegotiation */
17 #define BMCR_RESET                     0x8000 /* 1 = Reset the PHY */
18 
19 /* BSMR */
20 #define BMSR_LSTATUS                   0x0004 /* 1 = Link up */
21 #define BMSR_ANEGCAPABLE               0x0008 /* 1 = Able to perform auto-neg */
22 #define BMSR_ANEGCOMPLETE              0x0020 /* 1 = Auto-neg complete */
23 
24 #define PHY_AUTONEGOTIATE_TIMEOUT      5000
25 
26 /* 88E1011 PHY Status Register */
27 #define MIIM_88E1xxx_PHY_STATUS        0x11
28 #define MIIM_88E1xxx_PHYSTAT_SPEED     0xc000
29 #define MIIM_88E1xxx_PHYSTAT_GBIT      0x8000
30 #define MIIM_88E1xxx_PHYSTAT_100       0x4000
31 #define MIIM_88E1xxx_PHYSTAT_DUPLEX    0x2000
32 #define MIIM_88E1xxx_PHYSTAT_SPDDONE   0x0800
33 #define MIIM_88E1xxx_PHYSTAT_LINK      0x0400
34 
35 /* 88E1111 Extended PHY Specific Control Register */
36 #define MIIM_88E1111_PHY_EXT_CR        0x14
37 #define MIIM_88E1111_RX_DELAY          0x80
38 #define MIIM_88E1111_TX_DELAY          0x02
39 
40 /* 88E1111 Extended PHY Specific Status Register */
41 #define MIIM_88E1111_PHY_EXT_SR               0x1b
42 #define MIIM_88E1111_HWCFG_MODE_MASK          0xf
43 #define MIIM_88E1111_HWCFG_MODE_COPPER_RGMII  0xb
44 #define MIIM_88E1111_HWCFG_MODE_FIBER_RGMII   0x3
45 #define MIIM_88E1111_HWCFG_MODE_SGMII_NO_CLK  0x4
46 #define MIIM_88E1111_HWCFG_MODE_COPPER_RTBI   0x9
47 #define MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO  0x8000
48 #define MIIM_88E1111_HWCFG_FIBER_COPPER_RES   0x2000
49 
50 typedef enum {
51   MV_PHY_DEVICE_1512,
52   MV_PHY_DEVICE_1112,
53   MV_PHY_DEVICE_ID_MAX
54 } MV_PHY_DEVICE_ID;
55 
56 typedef
57 EFI_STATUS
58 (*MV_PHY_DEVICE_INIT) (
59     IN CONST MARVELL_PHY_PROTOCOL *Snp,
60     IN OUT PHY_DEVICE *PhyDev
61     );
62 
63 typedef struct {
64   MV_PHY_DEVICE_ID DevId;
65   MV_PHY_DEVICE_INIT DevInit;
66 } MV_PHY_DEVICE;
67 
68 STATIC
69 EFI_STATUS
70 MvPhyInit1512 (
71     IN CONST MARVELL_PHY_PROTOCOL *Snp,
72     IN OUT PHY_DEVICE *PhyDev
73     );
74 
75 /**
76   Initialize Marvell 88E1112 PHY.
77 
78   @param[in]      MvPhyProtocol   Marvell PHY protocol instance.
79   @param[in out] *PhyDevice       PHY device structure.
80 
81 **/
82 STATIC
83 EFI_STATUS
84 MvPhyInit1112 (
85   IN CONST MARVELL_PHY_PROTOCOL  *MvPhyProtocol,
86   IN OUT PHY_DEVICE              *PhyDevice
87   );
88 
89 #endif
90