xref: /openbmc/linux/drivers/net/ethernet/ibm/emac/phy.h (revision 9aa3283595451ca093500ff0977b106e1f465586)
1*9aa32835SJeff Kirsher /*
2*9aa32835SJeff Kirsher  * drivers/net/ibm_newemac/phy.h
3*9aa32835SJeff Kirsher  *
4*9aa32835SJeff Kirsher  * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
5*9aa32835SJeff Kirsher  *
6*9aa32835SJeff Kirsher  * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
7*9aa32835SJeff Kirsher  *                <benh@kernel.crashing.org>
8*9aa32835SJeff Kirsher  *
9*9aa32835SJeff Kirsher  * Based on the arch/ppc version of the driver:
10*9aa32835SJeff Kirsher  *
11*9aa32835SJeff Kirsher  * Benjamin Herrenschmidt <benh@kernel.crashing.org>
12*9aa32835SJeff Kirsher  * February 2003
13*9aa32835SJeff Kirsher  *
14*9aa32835SJeff Kirsher  * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004
15*9aa32835SJeff Kirsher  *
16*9aa32835SJeff Kirsher  * This program is free software; you can redistribute  it and/or modify it
17*9aa32835SJeff Kirsher  * under  the terms of  the GNU General  Public License as published by the
18*9aa32835SJeff Kirsher  * Free Software Foundation;  either version 2 of the  License, or (at your
19*9aa32835SJeff Kirsher  * option) any later version.
20*9aa32835SJeff Kirsher  *
21*9aa32835SJeff Kirsher  * This file basically duplicates sungem_phy.{c,h} with different PHYs
22*9aa32835SJeff Kirsher  * supported. I'm looking into merging that in a single mii layer more
23*9aa32835SJeff Kirsher  * flexible than mii.c
24*9aa32835SJeff Kirsher  */
25*9aa32835SJeff Kirsher 
26*9aa32835SJeff Kirsher #ifndef __IBM_NEWEMAC_PHY_H
27*9aa32835SJeff Kirsher #define __IBM_NEWEMAC_PHY_H
28*9aa32835SJeff Kirsher 
29*9aa32835SJeff Kirsher struct mii_phy;
30*9aa32835SJeff Kirsher 
31*9aa32835SJeff Kirsher /* Operations supported by any kind of PHY */
32*9aa32835SJeff Kirsher struct mii_phy_ops {
33*9aa32835SJeff Kirsher 	int (*init) (struct mii_phy * phy);
34*9aa32835SJeff Kirsher 	int (*suspend) (struct mii_phy * phy, int wol_options);
35*9aa32835SJeff Kirsher 	int (*setup_aneg) (struct mii_phy * phy, u32 advertise);
36*9aa32835SJeff Kirsher 	int (*setup_forced) (struct mii_phy * phy, int speed, int fd);
37*9aa32835SJeff Kirsher 	int (*poll_link) (struct mii_phy * phy);
38*9aa32835SJeff Kirsher 	int (*read_link) (struct mii_phy * phy);
39*9aa32835SJeff Kirsher };
40*9aa32835SJeff Kirsher 
41*9aa32835SJeff Kirsher /* Structure used to statically define an mii/gii based PHY */
42*9aa32835SJeff Kirsher struct mii_phy_def {
43*9aa32835SJeff Kirsher 	u32 phy_id;		/* Concatenated ID1 << 16 | ID2 */
44*9aa32835SJeff Kirsher 	u32 phy_id_mask;	/* Significant bits */
45*9aa32835SJeff Kirsher 	u32 features;		/* Ethtool SUPPORTED_* defines or
46*9aa32835SJeff Kirsher 				   0 for autodetect */
47*9aa32835SJeff Kirsher 	int magic_aneg;		/* Autoneg does all speed test for us */
48*9aa32835SJeff Kirsher 	const char *name;
49*9aa32835SJeff Kirsher 	const struct mii_phy_ops *ops;
50*9aa32835SJeff Kirsher };
51*9aa32835SJeff Kirsher 
52*9aa32835SJeff Kirsher /* An instance of a PHY, partially borrowed from mii_if_info */
53*9aa32835SJeff Kirsher struct mii_phy {
54*9aa32835SJeff Kirsher 	struct mii_phy_def *def;
55*9aa32835SJeff Kirsher 	u32 advertising;	/* Ethtool ADVERTISED_* defines */
56*9aa32835SJeff Kirsher 	u32 features;		/* Copied from mii_phy_def.features
57*9aa32835SJeff Kirsher 				   or determined automaticaly */
58*9aa32835SJeff Kirsher 	int address;		/* PHY address */
59*9aa32835SJeff Kirsher 	int mode;		/* PHY mode */
60*9aa32835SJeff Kirsher 	int gpcs_address;	/* GPCS PHY address */
61*9aa32835SJeff Kirsher 
62*9aa32835SJeff Kirsher 	/* 1: autoneg enabled, 0: disabled */
63*9aa32835SJeff Kirsher 	int autoneg;
64*9aa32835SJeff Kirsher 
65*9aa32835SJeff Kirsher 	/* forced speed & duplex (no autoneg)
66*9aa32835SJeff Kirsher 	 * partner speed & duplex & pause (autoneg)
67*9aa32835SJeff Kirsher 	 */
68*9aa32835SJeff Kirsher 	int speed;
69*9aa32835SJeff Kirsher 	int duplex;
70*9aa32835SJeff Kirsher 	int pause;
71*9aa32835SJeff Kirsher 	int asym_pause;
72*9aa32835SJeff Kirsher 
73*9aa32835SJeff Kirsher 	/* Provided by host chip */
74*9aa32835SJeff Kirsher 	struct net_device *dev;
75*9aa32835SJeff Kirsher 	int (*mdio_read) (struct net_device * dev, int addr, int reg);
76*9aa32835SJeff Kirsher 	void (*mdio_write) (struct net_device * dev, int addr, int reg,
77*9aa32835SJeff Kirsher 			    int val);
78*9aa32835SJeff Kirsher };
79*9aa32835SJeff Kirsher 
80*9aa32835SJeff Kirsher /* Pass in a struct mii_phy with dev, mdio_read and mdio_write
81*9aa32835SJeff Kirsher  * filled, the remaining fields will be filled on return
82*9aa32835SJeff Kirsher  */
83*9aa32835SJeff Kirsher int emac_mii_phy_probe(struct mii_phy *phy, int address);
84*9aa32835SJeff Kirsher int emac_mii_reset_phy(struct mii_phy *phy);
85*9aa32835SJeff Kirsher int emac_mii_reset_gpcs(struct mii_phy *phy);
86*9aa32835SJeff Kirsher 
87*9aa32835SJeff Kirsher #endif /* __IBM_NEWEMAC_PHY_H */
88