1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*****************************************************************************
6 * $Date: 2005/06/21 18:29:47 $ *
8 * part of the Chelsio 10Gb Ethernet Driver. *
11 * http://www.chelsio.com *
13 * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
14 * All rights reserved. *
16 * Maintainers: maintainers@chelsio.com *
18 * Authors: Dimitrios Michailidis <dm@chelsio.com> *
19 * Tina Yang <tainay@chelsio.com> *
20 * Felix Marti <felix@chelsio.com> *
21 * Scott Bardone <sbardone@chelsio.com> *
22 * Kurt Ottaway <kottaway@chelsio.com> *
23 * Frank DiMambro <frank@chelsio.com> *
27 ****************************************************************************/
35 void (*init)(adapter_t *adapter, const struct board_info *bi);
36 int (*read)(struct net_device *dev, int phy_addr, int mmd_addr,
38 int (*write)(struct net_device *dev, int phy_addr, int mmd_addr,
39 u16 reg_addr, u16 val);
40 unsigned mode_support;
43 /* PHY interrupt types */
45 cphy_cause_link_change = 0x1,
46 cphy_cause_error = 0x2,
47 cphy_cause_fifo_error = 0x3
52 PHY_AUTONEG_RDY = 0x2,
60 void (*destroy)(struct cphy *);
61 int (*reset)(struct cphy *, int wait);
63 int (*interrupt_enable)(struct cphy *);
64 int (*interrupt_disable)(struct cphy *);
65 int (*interrupt_clear)(struct cphy *);
66 int (*interrupt_handler)(struct cphy *);
68 int (*autoneg_enable)(struct cphy *);
69 int (*autoneg_disable)(struct cphy *);
70 int (*autoneg_restart)(struct cphy *);
72 int (*advertise)(struct cphy *phy, unsigned int advertise_map);
73 int (*set_loopback)(struct cphy *, int on);
74 int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex);
75 int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
76 int *duplex, int *fc);
83 int state; /* Link status state machine */
84 adapter_t *adapter; /* associated adapter */
86 struct delayed_work phy_update;
95 const struct cphy_ops *ops; /* PHY operations */
96 struct mdio_if_info mdio;
97 struct cphy_instance *instance;
100 /* Convenience MDIO read/write wrappers */
101 static inline int cphy_mdio_read(struct cphy *cphy, int mmd, int reg,
104 int rc = cphy->mdio.mdio_read(cphy->mdio.dev, cphy->mdio.prtad, mmd,
106 *valp = (rc >= 0) ? rc : -1;
107 return (rc >= 0) ? 0 : rc;
110 static inline int cphy_mdio_write(struct cphy *cphy, int mmd, int reg,
113 return cphy->mdio.mdio_write(cphy->mdio.dev, cphy->mdio.prtad, mmd,
117 static inline int simple_mdio_read(struct cphy *cphy, int reg,
120 return cphy_mdio_read(cphy, MDIO_DEVAD_NONE, reg, valp);
123 static inline int simple_mdio_write(struct cphy *cphy, int reg,
126 return cphy_mdio_write(cphy, MDIO_DEVAD_NONE, reg, val);
129 /* Convenience initializer */
130 static inline void cphy_init(struct cphy *phy, struct net_device *dev,
131 int phy_addr, const struct cphy_ops *phy_ops,
132 const struct mdio_ops *mdio_ops)
134 struct adapter *adapter = netdev_priv(dev);
135 phy->adapter = adapter;
138 phy->mdio.prtad = phy_addr;
139 phy->mdio.mmds = phy_ops->mmds;
140 phy->mdio.mode_support = mdio_ops->mode_support;
141 phy->mdio.mdio_read = mdio_ops->read;
142 phy->mdio.mdio_write = mdio_ops->write;
147 /* Operations of the PHY-instance factory */
149 /* Construct a PHY instance with the given PHY address */
150 struct cphy *(*create)(struct net_device *dev, int phy_addr,
151 const struct mdio_ops *mdio_ops);
154 * Reset the PHY chip. This resets the whole PHY chip, not individual
157 int (*reset)(adapter_t *adapter);
160 extern const struct gphy t1_my3126_ops;
161 extern const struct gphy t1_mv88e1xxx_ops;
162 extern const struct gphy t1_vsc8244_ops;
163 extern const struct gphy t1_mv88x201x_ops;
165 #endif /* _CXGB_CPHY_H_ */