diff options
Diffstat (limited to 'drivers/net/chelsio/cphy.h')
-rw-r--r-- | drivers/net/chelsio/cphy.h | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h index 79d855e267e0..1f095a9fc739 100644 --- a/drivers/net/chelsio/cphy.h +++ b/drivers/net/chelsio/cphy.h | |||
@@ -43,10 +43,11 @@ | |||
43 | 43 | ||
44 | struct mdio_ops { | 44 | struct mdio_ops { |
45 | void (*init)(adapter_t *adapter, const struct board_info *bi); | 45 | void (*init)(adapter_t *adapter, const struct board_info *bi); |
46 | int (*read)(adapter_t *adapter, int phy_addr, int mmd_addr, | 46 | int (*read)(struct net_device *dev, int phy_addr, int mmd_addr, |
47 | int reg_addr, unsigned int *val); | 47 | u16 reg_addr); |
48 | int (*write)(adapter_t *adapter, int phy_addr, int mmd_addr, | 48 | int (*write)(struct net_device *dev, int phy_addr, int mmd_addr, |
49 | int reg_addr, unsigned int val); | 49 | u16 reg_addr, u16 val); |
50 | unsigned mode_support; | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | /* PHY interrupt types */ | 53 | /* PHY interrupt types */ |
@@ -83,11 +84,12 @@ struct cphy_ops { | |||
83 | int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex); | 84 | int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex); |
84 | int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, | 85 | int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed, |
85 | int *duplex, int *fc); | 86 | int *duplex, int *fc); |
87 | |||
88 | u32 mmds; | ||
86 | }; | 89 | }; |
87 | 90 | ||
88 | /* A PHY instance */ | 91 | /* A PHY instance */ |
89 | struct cphy { | 92 | struct cphy { |
90 | int addr; /* PHY address */ | ||
91 | int state; /* Link status state machine */ | 93 | int state; /* Link status state machine */ |
92 | adapter_t *adapter; /* associated adapter */ | 94 | adapter_t *adapter; /* associated adapter */ |
93 | 95 | ||
@@ -101,56 +103,61 @@ struct cphy { | |||
101 | u32 elmer_gpo; | 103 | u32 elmer_gpo; |
102 | 104 | ||
103 | const struct cphy_ops *ops; /* PHY operations */ | 105 | const struct cphy_ops *ops; /* PHY operations */ |
104 | int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr, | 106 | struct mdio_if_info mdio; |
105 | int reg_addr, unsigned int *val); | ||
106 | int (*mdio_write)(adapter_t *adapter, int phy_addr, int mmd_addr, | ||
107 | int reg_addr, unsigned int val); | ||
108 | struct cphy_instance *instance; | 107 | struct cphy_instance *instance; |
109 | }; | 108 | }; |
110 | 109 | ||
111 | /* Convenience MDIO read/write wrappers */ | 110 | /* Convenience MDIO read/write wrappers */ |
112 | static inline int mdio_read(struct cphy *cphy, int mmd, int reg, | 111 | static inline int cphy_mdio_read(struct cphy *cphy, int mmd, int reg, |
113 | unsigned int *valp) | 112 | unsigned int *valp) |
114 | { | 113 | { |
115 | return cphy->mdio_read(cphy->adapter, cphy->addr, mmd, reg, valp); | 114 | int rc = cphy->mdio.mdio_read(cphy->mdio.dev, cphy->mdio.prtad, mmd, |
115 | reg); | ||
116 | *valp = (rc >= 0) ? rc : -1; | ||
117 | return (rc >= 0) ? 0 : rc; | ||
116 | } | 118 | } |
117 | 119 | ||
118 | static inline int mdio_write(struct cphy *cphy, int mmd, int reg, | 120 | static inline int cphy_mdio_write(struct cphy *cphy, int mmd, int reg, |
119 | unsigned int val) | 121 | unsigned int val) |
120 | { | 122 | { |
121 | return cphy->mdio_write(cphy->adapter, cphy->addr, mmd, reg, val); | 123 | return cphy->mdio.mdio_write(cphy->mdio.dev, cphy->mdio.prtad, mmd, |
124 | reg, val); | ||
122 | } | 125 | } |
123 | 126 | ||
124 | static inline int simple_mdio_read(struct cphy *cphy, int reg, | 127 | static inline int simple_mdio_read(struct cphy *cphy, int reg, |
125 | unsigned int *valp) | 128 | unsigned int *valp) |
126 | { | 129 | { |
127 | return mdio_read(cphy, 0, reg, valp); | 130 | return cphy_mdio_read(cphy, MDIO_DEVAD_NONE, reg, valp); |
128 | } | 131 | } |
129 | 132 | ||
130 | static inline int simple_mdio_write(struct cphy *cphy, int reg, | 133 | static inline int simple_mdio_write(struct cphy *cphy, int reg, |
131 | unsigned int val) | 134 | unsigned int val) |
132 | { | 135 | { |
133 | return mdio_write(cphy, 0, reg, val); | 136 | return cphy_mdio_write(cphy, MDIO_DEVAD_NONE, reg, val); |
134 | } | 137 | } |
135 | 138 | ||
136 | /* Convenience initializer */ | 139 | /* Convenience initializer */ |
137 | static inline void cphy_init(struct cphy *phy, adapter_t *adapter, | 140 | static inline void cphy_init(struct cphy *phy, struct net_device *dev, |
138 | int phy_addr, struct cphy_ops *phy_ops, | 141 | int phy_addr, struct cphy_ops *phy_ops, |
139 | const struct mdio_ops *mdio_ops) | 142 | const struct mdio_ops *mdio_ops) |
140 | { | 143 | { |
144 | struct adapter *adapter = netdev_priv(dev); | ||
141 | phy->adapter = adapter; | 145 | phy->adapter = adapter; |
142 | phy->addr = phy_addr; | ||
143 | phy->ops = phy_ops; | 146 | phy->ops = phy_ops; |
144 | if (mdio_ops) { | 147 | if (mdio_ops) { |
145 | phy->mdio_read = mdio_ops->read; | 148 | phy->mdio.prtad = phy_addr; |
146 | phy->mdio_write = mdio_ops->write; | 149 | phy->mdio.mmds = phy_ops->mmds; |
150 | phy->mdio.mode_support = mdio_ops->mode_support; | ||
151 | phy->mdio.mdio_read = mdio_ops->read; | ||
152 | phy->mdio.mdio_write = mdio_ops->write; | ||
147 | } | 153 | } |
154 | phy->mdio.dev = dev; | ||
148 | } | 155 | } |
149 | 156 | ||
150 | /* Operations of the PHY-instance factory */ | 157 | /* Operations of the PHY-instance factory */ |
151 | struct gphy { | 158 | struct gphy { |
152 | /* Construct a PHY instance with the given PHY address */ | 159 | /* Construct a PHY instance with the given PHY address */ |
153 | struct cphy *(*create)(adapter_t *adapter, int phy_addr, | 160 | struct cphy *(*create)(struct net_device *dev, int phy_addr, |
154 | const struct mdio_ops *mdio_ops); | 161 | const struct mdio_ops *mdio_ops); |
155 | 162 | ||
156 | /* | 163 | /* |