blob: a70e0fea54c4381b39115ef74fdf2b630aaa6626 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Eugene Surovegin37448f72005-10-10 16:58:14 -07002 * drivers/net/ibm_emac/ibm_emac_phy.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07004 * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07006 * Benjamin Herrenschmidt <benh@kernel.crashing.org>
7 * February 2003
8 *
9 * Minor additions by Eugene Surovegin <ebs@ebshome.net>, 2004
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This program is free software; you can redistribute it and/or modify it
Eugene Surovegin37448f72005-10-10 16:58:14 -070012 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 *
16 * This file basically duplicates sungem_phy.{c,h} with different PHYs
17 * supported. I'm looking into merging that in a single mii layer more
18 * flexible than mii.c
19 */
20
Eugene Surovegin37448f72005-10-10 16:58:14 -070021#ifndef _IBM_OCP_PHY_H_
22#define _IBM_OCP_PHY_H_
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24struct mii_phy;
25
26/* Operations supported by any kind of PHY */
27struct mii_phy_ops {
28 int (*init) (struct mii_phy * phy);
29 int (*suspend) (struct mii_phy * phy, int wol_options);
30 int (*setup_aneg) (struct mii_phy * phy, u32 advertise);
31 int (*setup_forced) (struct mii_phy * phy, int speed, int fd);
32 int (*poll_link) (struct mii_phy * phy);
33 int (*read_link) (struct mii_phy * phy);
34};
35
36/* Structure used to statically define an mii/gii based PHY */
37struct mii_phy_def {
38 u32 phy_id; /* Concatenated ID1 << 16 | ID2 */
39 u32 phy_id_mask; /* Significant bits */
Eugene Surovegin37448f72005-10-10 16:58:14 -070040 u32 features; /* Ethtool SUPPORTED_* defines or
41 0 for autodetect */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 int magic_aneg; /* Autoneg does all speed test for us */
43 const char *name;
44 const struct mii_phy_ops *ops;
45};
46
47/* An instance of a PHY, partially borrowed from mii_if_info */
48struct mii_phy {
49 struct mii_phy_def *def;
Eugene Surovegin37448f72005-10-10 16:58:14 -070050 u32 advertising; /* Ethtool ADVERTISED_* defines */
51 u32 features; /* Copied from mii_phy_def.features
52 or determined automaticaly */
53 int address; /* PHY address */
54 int mode; /* PHY mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56 /* 1: autoneg enabled, 0: disabled */
57 int autoneg;
58
59 /* forced speed & duplex (no autoneg)
60 * partner speed & duplex & pause (autoneg)
61 */
62 int speed;
63 int duplex;
64 int pause;
Eugene Surovegin37448f72005-10-10 16:58:14 -070065 int asym_pause;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 /* Provided by host chip */
68 struct net_device *dev;
Eugene Surovegin37448f72005-10-10 16:58:14 -070069 int (*mdio_read) (struct net_device * dev, int addr, int reg);
70 void (*mdio_write) (struct net_device * dev, int addr, int reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 int val);
72};
73
74/* Pass in a struct mii_phy with dev, mdio_read and mdio_write
75 * filled, the remaining fields will be filled on return
76 */
Eugene Surovegin37448f72005-10-10 16:58:14 -070077int mii_phy_probe(struct mii_phy *phy, int address);
78int mii_reset_phy(struct mii_phy *phy);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Eugene Surovegin37448f72005-10-10 16:58:14 -070080#endif /* _IBM_OCP_PHY_H_ */