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