18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * drivers/net/ethernet/ibm/emac/phy.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
88c2ecf20Sopenharmony_ci *                <benh@kernel.crashing.org>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Based on the arch/ppc version of the driver:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Benjamin Herrenschmidt <benh@kernel.crashing.org>
138c2ecf20Sopenharmony_ci * February 2003
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * This file basically duplicates sungem_phy.{c,h} with different PHYs
188c2ecf20Sopenharmony_ci * supported. I'm looking into merging that in a single mii layer more
198c2ecf20Sopenharmony_ci * flexible than mii.c
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#ifndef __IBM_NEWEMAC_PHY_H
238c2ecf20Sopenharmony_ci#define __IBM_NEWEMAC_PHY_H
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistruct mii_phy;
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* Operations supported by any kind of PHY */
288c2ecf20Sopenharmony_cistruct mii_phy_ops {
298c2ecf20Sopenharmony_ci	int (*init) (struct mii_phy * phy);
308c2ecf20Sopenharmony_ci	int (*suspend) (struct mii_phy * phy, int wol_options);
318c2ecf20Sopenharmony_ci	int (*setup_aneg) (struct mii_phy * phy, u32 advertise);
328c2ecf20Sopenharmony_ci	int (*setup_forced) (struct mii_phy * phy, int speed, int fd);
338c2ecf20Sopenharmony_ci	int (*poll_link) (struct mii_phy * phy);
348c2ecf20Sopenharmony_ci	int (*read_link) (struct mii_phy * phy);
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* Structure used to statically define an mii/gii based PHY */
388c2ecf20Sopenharmony_cistruct mii_phy_def {
398c2ecf20Sopenharmony_ci	u32 phy_id;		/* Concatenated ID1 << 16 | ID2 */
408c2ecf20Sopenharmony_ci	u32 phy_id_mask;	/* Significant bits */
418c2ecf20Sopenharmony_ci	u32 features;		/* Ethtool SUPPORTED_* defines or
428c2ecf20Sopenharmony_ci				   0 for autodetect */
438c2ecf20Sopenharmony_ci	int magic_aneg;		/* Autoneg does all speed test for us */
448c2ecf20Sopenharmony_ci	const char *name;
458c2ecf20Sopenharmony_ci	const struct mii_phy_ops *ops;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* An instance of a PHY, partially borrowed from mii_if_info */
498c2ecf20Sopenharmony_cistruct mii_phy {
508c2ecf20Sopenharmony_ci	struct mii_phy_def *def;
518c2ecf20Sopenharmony_ci	u32 advertising;	/* Ethtool ADVERTISED_* defines */
528c2ecf20Sopenharmony_ci	u32 features;		/* Copied from mii_phy_def.features
538c2ecf20Sopenharmony_ci				   or determined automaticaly */
548c2ecf20Sopenharmony_ci	int address;		/* PHY address */
558c2ecf20Sopenharmony_ci	int mode;		/* PHY mode */
568c2ecf20Sopenharmony_ci	int gpcs_address;	/* GPCS PHY address */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	/* 1: autoneg enabled, 0: disabled */
598c2ecf20Sopenharmony_ci	int autoneg;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	/* forced speed & duplex (no autoneg)
628c2ecf20Sopenharmony_ci	 * partner speed & duplex & pause (autoneg)
638c2ecf20Sopenharmony_ci	 */
648c2ecf20Sopenharmony_ci	int speed;
658c2ecf20Sopenharmony_ci	int duplex;
668c2ecf20Sopenharmony_ci	int pause;
678c2ecf20Sopenharmony_ci	int asym_pause;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	/* Provided by host chip */
708c2ecf20Sopenharmony_ci	struct net_device *dev;
718c2ecf20Sopenharmony_ci	int (*mdio_read) (struct net_device * dev, int addr, int reg);
728c2ecf20Sopenharmony_ci	void (*mdio_write) (struct net_device * dev, int addr, int reg,
738c2ecf20Sopenharmony_ci			    int val);
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* Pass in a struct mii_phy with dev, mdio_read and mdio_write
778c2ecf20Sopenharmony_ci * filled, the remaining fields will be filled on return
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ciint emac_mii_phy_probe(struct mii_phy *phy, int address);
808c2ecf20Sopenharmony_ciint emac_mii_reset_phy(struct mii_phy *phy);
818c2ecf20Sopenharmony_ciint emac_mii_reset_gpcs(struct mii_phy *phy);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#endif /* __IBM_NEWEMAC_PHY_H */
84