1b6d90eb7SKip Macy /**************************************************************************
2*4d846d26SWarner Losh SPDX-License-Identifier: BSD-2-Clause
3b6d90eb7SKip Macy
4f2d8ff04SGeorge V. Neville-Neil Copyright (c) 2007-2009, Chelsio Inc.
5b6d90eb7SKip Macy All rights reserved.
6b6d90eb7SKip Macy
7b6d90eb7SKip Macy Redistribution and use in source and binary forms, with or without
8b6d90eb7SKip Macy modification, are permitted provided that the following conditions are met:
9b6d90eb7SKip Macy
10b6d90eb7SKip Macy 1. Redistributions of source code must retain the above copyright notice,
11b6d90eb7SKip Macy this list of conditions and the following disclaimer.
12b6d90eb7SKip Macy
1310faa568SKip Macy 2. Neither the name of the Chelsio Corporation nor the names of its
14b6d90eb7SKip Macy contributors may be used to endorse or promote products derived from
15b6d90eb7SKip Macy this software without specific prior written permission.
16b6d90eb7SKip Macy
17b6d90eb7SKip Macy THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18b6d90eb7SKip Macy AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19b6d90eb7SKip Macy IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20b6d90eb7SKip Macy ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21b6d90eb7SKip Macy LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22b6d90eb7SKip Macy CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23b6d90eb7SKip Macy SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24b6d90eb7SKip Macy INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25b6d90eb7SKip Macy CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26b6d90eb7SKip Macy ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27b6d90eb7SKip Macy POSSIBILITY OF SUCH DAMAGE.
28b6d90eb7SKip Macy
29b6d90eb7SKip Macy ***************************************************************************/
30b6d90eb7SKip Macy
31b6d90eb7SKip Macy #include <sys/cdefs.h>
3210faa568SKip Macy #include <cxgb_include.h>
33b6d90eb7SKip Macy
348e10660fSKip Macy #undef msleep
358e10660fSKip Macy #define msleep t3_os_sleep
368e10660fSKip Macy
37b6d90eb7SKip Macy enum {
389b4de886SKip Macy PMD_RSD = 10, /* PMA/PMD receive signal detect register */
399b4de886SKip Macy PCS_STAT1_X = 24, /* 10GBASE-X PCS status 1 register */
409b4de886SKip Macy PCS_STAT1_R = 32, /* 10GBASE-R PCS status 1 register */
419b4de886SKip Macy XS_LN_STAT = 24 /* XS lane status register */
429b4de886SKip Macy };
439b4de886SKip Macy
449b4de886SKip Macy enum {
45b6d90eb7SKip Macy AEL100X_TX_DISABLE = 9,
46b6d90eb7SKip Macy AEL100X_TX_CONFIG1 = 0xc002,
47c01f2b83SNavdeep Parhar
48b6d90eb7SKip Macy AEL1002_PWR_DOWN_HI = 0xc011,
49b6d90eb7SKip Macy AEL1002_PWR_DOWN_LO = 0xc012,
50b6d90eb7SKip Macy AEL1002_XFI_EQL = 0xc015,
51b6d90eb7SKip Macy AEL1002_LB_EN = 0xc017,
52c01f2b83SNavdeep Parhar
534af83c8cSKip Macy AEL_OPT_SETTINGS = 0xc017,
549b4de886SKip Macy AEL_I2C_CTRL = 0xc30a,
559b4de886SKip Macy AEL_I2C_DATA = 0xc30b,
569b4de886SKip Macy AEL_I2C_STAT = 0xc30c,
57c01f2b83SNavdeep Parhar
589b4de886SKip Macy AEL2005_GPIO_CTRL = 0xc214,
599b4de886SKip Macy AEL2005_GPIO_STAT = 0xc215,
60c01f2b83SNavdeep Parhar
61c01f2b83SNavdeep Parhar AEL2020_GPIO_INTR = 0xc103,
62c01f2b83SNavdeep Parhar AEL2020_GPIO_CTRL = 0xc108,
63c01f2b83SNavdeep Parhar AEL2020_GPIO_STAT = 0xc10c,
64c01f2b83SNavdeep Parhar AEL2020_GPIO_CFG = 0xc110,
65c01f2b83SNavdeep Parhar
66c01f2b83SNavdeep Parhar AEL2020_GPIO_SDA = 0,
67c01f2b83SNavdeep Parhar AEL2020_GPIO_MODDET = 1,
68c01f2b83SNavdeep Parhar AEL2020_GPIO_0 = 3,
69c01f2b83SNavdeep Parhar AEL2020_GPIO_1 = 2,
70c01f2b83SNavdeep Parhar AEL2020_GPIO_LSTAT = AEL2020_GPIO_1,
71b6d90eb7SKip Macy };
72b6d90eb7SKip Macy
739b4de886SKip Macy enum { edc_none, edc_sr, edc_twinax };
749b4de886SKip Macy
759b4de886SKip Macy /* PHY module I2C device address */
76f2d8ff04SGeorge V. Neville-Neil enum {
77f2d8ff04SGeorge V. Neville-Neil MODULE_DEV_ADDR = 0xa0,
78f2d8ff04SGeorge V. Neville-Neil SFF_DEV_ADDR = 0xa2,
79f2d8ff04SGeorge V. Neville-Neil };
80f2d8ff04SGeorge V. Neville-Neil
81f2d8ff04SGeorge V. Neville-Neil /* PHY transceiver type */
82f2d8ff04SGeorge V. Neville-Neil enum {
83f2d8ff04SGeorge V. Neville-Neil phy_transtype_unknown = 0,
84f2d8ff04SGeorge V. Neville-Neil phy_transtype_sfp = 3,
85f2d8ff04SGeorge V. Neville-Neil phy_transtype_xfp = 6,
86f2d8ff04SGeorge V. Neville-Neil };
879b4de886SKip Macy
889b4de886SKip Macy #define AEL2005_MODDET_IRQ 4
899b4de886SKip Macy
904af83c8cSKip Macy struct reg_val {
914af83c8cSKip Macy unsigned short mmd_addr;
924af83c8cSKip Macy unsigned short reg_addr;
934af83c8cSKip Macy unsigned short clear_bits;
944af83c8cSKip Macy unsigned short set_bits;
954af83c8cSKip Macy };
964af83c8cSKip Macy
97c01f2b83SNavdeep Parhar static int ael2xxx_get_module_type(struct cphy *phy, int delay_ms);
98837f41b0SGeorge V. Neville-Neil
set_phy_regs(struct cphy * phy,const struct reg_val * rv)994af83c8cSKip Macy static int set_phy_regs(struct cphy *phy, const struct reg_val *rv)
1004af83c8cSKip Macy {
1014af83c8cSKip Macy int err;
1024af83c8cSKip Macy
1034af83c8cSKip Macy for (err = 0; rv->mmd_addr && !err; rv++) {
1044af83c8cSKip Macy if (rv->clear_bits == 0xffff)
1054af83c8cSKip Macy err = mdio_write(phy, rv->mmd_addr, rv->reg_addr,
1064af83c8cSKip Macy rv->set_bits);
1074af83c8cSKip Macy else
1084af83c8cSKip Macy err = t3_mdio_change_bits(phy, rv->mmd_addr,
1094af83c8cSKip Macy rv->reg_addr, rv->clear_bits,
1104af83c8cSKip Macy rv->set_bits);
1114af83c8cSKip Macy }
1124af83c8cSKip Macy return err;
1134af83c8cSKip Macy }
1144af83c8cSKip Macy
ael100x_txon(struct cphy * phy)115b6d90eb7SKip Macy static void ael100x_txon(struct cphy *phy)
116b6d90eb7SKip Macy {
117b6d90eb7SKip Macy int tx_on_gpio = phy->addr == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL;
118b6d90eb7SKip Macy
1198e10660fSKip Macy msleep(100);
120b6d90eb7SKip Macy t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, 0, tx_on_gpio);
1218e10660fSKip Macy msleep(30);
122b6d90eb7SKip Macy }
123b6d90eb7SKip Macy
124c01f2b83SNavdeep Parhar /*
125c01f2b83SNavdeep Parhar * Read an 8-bit word from a device attached to the PHY's i2c bus.
126c01f2b83SNavdeep Parhar */
ael_i2c_rd(struct cphy * phy,int dev_addr,int word_addr)127f2d8ff04SGeorge V. Neville-Neil static int ael_i2c_rd(struct cphy *phy, int dev_addr, int word_addr)
128f2d8ff04SGeorge V. Neville-Neil {
129f2d8ff04SGeorge V. Neville-Neil int i, err;
130f2d8ff04SGeorge V. Neville-Neil unsigned int stat, data;
131f2d8ff04SGeorge V. Neville-Neil
132f2d8ff04SGeorge V. Neville-Neil err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL,
133f2d8ff04SGeorge V. Neville-Neil (dev_addr << 8) | (1 << 8) | word_addr);
134f2d8ff04SGeorge V. Neville-Neil if (err)
135f2d8ff04SGeorge V. Neville-Neil return err;
136f2d8ff04SGeorge V. Neville-Neil
137f2d8ff04SGeorge V. Neville-Neil for (i = 0; i < 200; i++) {
138f2d8ff04SGeorge V. Neville-Neil msleep(1);
139f2d8ff04SGeorge V. Neville-Neil err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat);
140f2d8ff04SGeorge V. Neville-Neil if (err)
141f2d8ff04SGeorge V. Neville-Neil return err;
142f2d8ff04SGeorge V. Neville-Neil if ((stat & 3) == 1) {
143f2d8ff04SGeorge V. Neville-Neil err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA,
144f2d8ff04SGeorge V. Neville-Neil &data);
145f2d8ff04SGeorge V. Neville-Neil if (err)
146f2d8ff04SGeorge V. Neville-Neil return err;
147f2d8ff04SGeorge V. Neville-Neil return data >> 8;
148f2d8ff04SGeorge V. Neville-Neil }
149f2d8ff04SGeorge V. Neville-Neil }
150c01f2b83SNavdeep Parhar CH_WARN(phy->adapter, "PHY %u i2c read of dev.addr %x.%x timed out\n",
151c01f2b83SNavdeep Parhar phy->addr, dev_addr, word_addr);
152f2d8ff04SGeorge V. Neville-Neil return -ETIMEDOUT;
153f2d8ff04SGeorge V. Neville-Neil }
154f2d8ff04SGeorge V. Neville-Neil
155c01f2b83SNavdeep Parhar /*
156c01f2b83SNavdeep Parhar * Write an 8-bit word to a device attached to the PHY's i2c bus.
157c01f2b83SNavdeep Parhar */
ael_i2c_wr(struct cphy * phy,int dev_addr,int word_addr,int data)158f2d8ff04SGeorge V. Neville-Neil static int ael_i2c_wr(struct cphy *phy, int dev_addr, int word_addr, int data)
159f2d8ff04SGeorge V. Neville-Neil {
160f2d8ff04SGeorge V. Neville-Neil int i, err;
161f2d8ff04SGeorge V. Neville-Neil unsigned int stat;
162f2d8ff04SGeorge V. Neville-Neil
163f2d8ff04SGeorge V. Neville-Neil err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, data);
164f2d8ff04SGeorge V. Neville-Neil if (err)
165f2d8ff04SGeorge V. Neville-Neil return err;
166f2d8ff04SGeorge V. Neville-Neil
167f2d8ff04SGeorge V. Neville-Neil err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL,
168f2d8ff04SGeorge V. Neville-Neil (dev_addr << 8) | word_addr);
169f2d8ff04SGeorge V. Neville-Neil if (err)
170f2d8ff04SGeorge V. Neville-Neil return err;
171f2d8ff04SGeorge V. Neville-Neil
172f2d8ff04SGeorge V. Neville-Neil for (i = 0; i < 200; i++) {
173f2d8ff04SGeorge V. Neville-Neil msleep(1);
174f2d8ff04SGeorge V. Neville-Neil err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat);
175f2d8ff04SGeorge V. Neville-Neil if (err)
176f2d8ff04SGeorge V. Neville-Neil return err;
177f2d8ff04SGeorge V. Neville-Neil if ((stat & 3) == 1)
178f2d8ff04SGeorge V. Neville-Neil return 0;
179f2d8ff04SGeorge V. Neville-Neil }
180c01f2b83SNavdeep Parhar CH_WARN(phy->adapter, "PHY %u i2c Write of dev.addr %x.%x = %#x timed out\n",
181c01f2b83SNavdeep Parhar phy->addr, dev_addr, word_addr, data);
182f2d8ff04SGeorge V. Neville-Neil return -ETIMEDOUT;
183f2d8ff04SGeorge V. Neville-Neil }
184f2d8ff04SGeorge V. Neville-Neil
get_phytrans_type(struct cphy * phy)185f2d8ff04SGeorge V. Neville-Neil static int get_phytrans_type(struct cphy *phy)
186f2d8ff04SGeorge V. Neville-Neil {
187f2d8ff04SGeorge V. Neville-Neil int v;
188f2d8ff04SGeorge V. Neville-Neil
189f2d8ff04SGeorge V. Neville-Neil v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 0);
190f2d8ff04SGeorge V. Neville-Neil if (v < 0)
191f2d8ff04SGeorge V. Neville-Neil return phy_transtype_unknown;
192f2d8ff04SGeorge V. Neville-Neil
193f2d8ff04SGeorge V. Neville-Neil return v;
194f2d8ff04SGeorge V. Neville-Neil }
195f2d8ff04SGeorge V. Neville-Neil
ael_laser_down(struct cphy * phy,int enable)196f2d8ff04SGeorge V. Neville-Neil static int ael_laser_down(struct cphy *phy, int enable)
197f2d8ff04SGeorge V. Neville-Neil {
198f2d8ff04SGeorge V. Neville-Neil int v, dev_addr;
199f2d8ff04SGeorge V. Neville-Neil
200f2d8ff04SGeorge V. Neville-Neil v = get_phytrans_type(phy);
201f2d8ff04SGeorge V. Neville-Neil if (v < 0)
202f2d8ff04SGeorge V. Neville-Neil return v;
203f2d8ff04SGeorge V. Neville-Neil
204f2d8ff04SGeorge V. Neville-Neil if (v == phy_transtype_sfp) {
205f2d8ff04SGeorge V. Neville-Neil /* Check SFF Soft TX disable is supported */
206f2d8ff04SGeorge V. Neville-Neil v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 93);
207f2d8ff04SGeorge V. Neville-Neil if (v < 0)
208f2d8ff04SGeorge V. Neville-Neil return v;
209f2d8ff04SGeorge V. Neville-Neil
210f2d8ff04SGeorge V. Neville-Neil v &= 0x40;
211f2d8ff04SGeorge V. Neville-Neil if (!v)
212f2d8ff04SGeorge V. Neville-Neil return v;
213f2d8ff04SGeorge V. Neville-Neil
214f2d8ff04SGeorge V. Neville-Neil dev_addr = SFF_DEV_ADDR;
215f2d8ff04SGeorge V. Neville-Neil } else if (v == phy_transtype_xfp)
216f2d8ff04SGeorge V. Neville-Neil dev_addr = MODULE_DEV_ADDR;
217f2d8ff04SGeorge V. Neville-Neil else
218f2d8ff04SGeorge V. Neville-Neil return v;
219f2d8ff04SGeorge V. Neville-Neil
220f2d8ff04SGeorge V. Neville-Neil v = ael_i2c_rd(phy, dev_addr, 110);
221f2d8ff04SGeorge V. Neville-Neil if (v < 0)
222f2d8ff04SGeorge V. Neville-Neil return v;
223f2d8ff04SGeorge V. Neville-Neil
224f2d8ff04SGeorge V. Neville-Neil if (enable)
225f2d8ff04SGeorge V. Neville-Neil v |= 0x40;
226f2d8ff04SGeorge V. Neville-Neil else
227f2d8ff04SGeorge V. Neville-Neil v &= ~0x40;
228f2d8ff04SGeorge V. Neville-Neil
229f2d8ff04SGeorge V. Neville-Neil v = ael_i2c_wr(phy, dev_addr, 110, v);
230f2d8ff04SGeorge V. Neville-Neil
231f2d8ff04SGeorge V. Neville-Neil return v;
232f2d8ff04SGeorge V. Neville-Neil }
233f2d8ff04SGeorge V. Neville-Neil
ael1002_power_down(struct cphy * phy,int enable)234b6d90eb7SKip Macy static int ael1002_power_down(struct cphy *phy, int enable)
235b6d90eb7SKip Macy {
236b6d90eb7SKip Macy int err;
237b6d90eb7SKip Macy
238b6d90eb7SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_DISABLE, !!enable);
239b6d90eb7SKip Macy if (!err)
240b6d90eb7SKip Macy err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR,
241b6d90eb7SKip Macy BMCR_PDOWN, enable ? BMCR_PDOWN : 0);
242b6d90eb7SKip Macy return err;
243b6d90eb7SKip Macy }
244b6d90eb7SKip Macy
ael1002_get_module_type(struct cphy * phy,int delay_ms)245837f41b0SGeorge V. Neville-Neil static int ael1002_get_module_type(struct cphy *phy, int delay_ms)
246837f41b0SGeorge V. Neville-Neil {
247837f41b0SGeorge V. Neville-Neil int v;
248837f41b0SGeorge V. Neville-Neil
249837f41b0SGeorge V. Neville-Neil if (delay_ms)
250837f41b0SGeorge V. Neville-Neil msleep(delay_ms);
251837f41b0SGeorge V. Neville-Neil
252c01f2b83SNavdeep Parhar v = ael2xxx_get_module_type(phy, delay_ms);
253837f41b0SGeorge V. Neville-Neil
254c01f2b83SNavdeep Parhar return (v == -ETIMEDOUT ? phy_modtype_none : v);
255837f41b0SGeorge V. Neville-Neil }
256837f41b0SGeorge V. Neville-Neil
ael1002_reset(struct cphy * phy,int wait)257b6d90eb7SKip Macy static int ael1002_reset(struct cphy *phy, int wait)
258b6d90eb7SKip Macy {
259b6d90eb7SKip Macy int err;
260b6d90eb7SKip Macy
261b6d90eb7SKip Macy if ((err = ael1002_power_down(phy, 0)) ||
262b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_CONFIG1, 1)) ||
263b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_HI, 0)) ||
264b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_LO, 0)) ||
265b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_XFI_EQL, 0x18)) ||
266b6d90eb7SKip Macy (err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL1002_LB_EN,
267b6d90eb7SKip Macy 0, 1 << 5)))
268b6d90eb7SKip Macy return err;
269837f41b0SGeorge V. Neville-Neil
270837f41b0SGeorge V. Neville-Neil err = ael1002_get_module_type(phy, 300);
271837f41b0SGeorge V. Neville-Neil if (err >= 0)
272837f41b0SGeorge V. Neville-Neil phy->modtype = err;
273837f41b0SGeorge V. Neville-Neil
274b6d90eb7SKip Macy return 0;
275b6d90eb7SKip Macy }
276b6d90eb7SKip Macy
ael1002_intr_noop(struct cphy * phy)277b6d90eb7SKip Macy static int ael1002_intr_noop(struct cphy *phy)
278b6d90eb7SKip Macy {
279b6d90eb7SKip Macy return 0;
280b6d90eb7SKip Macy }
281b6d90eb7SKip Macy
2829b4de886SKip Macy /*
2839b4de886SKip Macy * Get link status for a 10GBASE-R device.
2849b4de886SKip Macy */
get_link_status_r(struct cphy * phy,int * link_state,int * speed,int * duplex,int * fc)285a5eb009bSNavdeep Parhar static int get_link_status_r(struct cphy *phy, int *link_state, int *speed,
2869b4de886SKip Macy int *duplex, int *fc)
287b6d90eb7SKip Macy {
288a5eb009bSNavdeep Parhar if (link_state) {
2899b4de886SKip Macy unsigned int stat0, stat1, stat2;
2909b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0);
291b6d90eb7SKip Macy
2929b4de886SKip Macy if (!err)
2939b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_R, &stat1);
2949b4de886SKip Macy if (!err)
2959b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2);
296b6d90eb7SKip Macy if (err)
297b6d90eb7SKip Macy return err;
298bd1a9fbaSNavdeep Parhar
299a5eb009bSNavdeep Parhar stat0 &= 1;
300a5eb009bSNavdeep Parhar stat1 &= 1;
301a5eb009bSNavdeep Parhar stat2 = (stat2 >> 12) & 1;
302a5eb009bSNavdeep Parhar if (stat0 & stat1 & stat2)
303a5eb009bSNavdeep Parhar *link_state = PHY_LINK_UP;
304a5eb009bSNavdeep Parhar else if (stat0 == 1 && stat1 == 0 && stat2 == 1)
305a5eb009bSNavdeep Parhar *link_state = PHY_LINK_PARTIAL;
306a5eb009bSNavdeep Parhar else
307a5eb009bSNavdeep Parhar *link_state = PHY_LINK_DOWN;
308b6d90eb7SKip Macy }
309b6d90eb7SKip Macy if (speed)
310b6d90eb7SKip Macy *speed = SPEED_10000;
311b6d90eb7SKip Macy if (duplex)
312b6d90eb7SKip Macy *duplex = DUPLEX_FULL;
313b6d90eb7SKip Macy return 0;
314b6d90eb7SKip Macy }
315b6d90eb7SKip Macy
316b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED
317b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = {
318b6d90eb7SKip Macy ael1002_reset,
319b6d90eb7SKip Macy ael1002_intr_noop,
320b6d90eb7SKip Macy ael1002_intr_noop,
321b6d90eb7SKip Macy ael1002_intr_noop,
322b6d90eb7SKip Macy ael1002_intr_noop,
323b6d90eb7SKip Macy NULL,
324b6d90eb7SKip Macy NULL,
325b6d90eb7SKip Macy NULL,
326b6d90eb7SKip Macy NULL,
327b6d90eb7SKip Macy NULL,
3289b4de886SKip Macy get_link_status_r,
329b6d90eb7SKip Macy ael1002_power_down,
330b6d90eb7SKip Macy };
331b6d90eb7SKip Macy #else
332b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = {
333b6d90eb7SKip Macy .reset = ael1002_reset,
334b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop,
335b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop,
336b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop,
337b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop,
3389b4de886SKip Macy .get_link_status = get_link_status_r,
339b6d90eb7SKip Macy .power_down = ael1002_power_down,
340b6d90eb7SKip Macy };
341b6d90eb7SKip Macy #endif
342b6d90eb7SKip Macy
t3_ael1002_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)343c01f2b83SNavdeep Parhar int t3_ael1002_phy_prep(pinfo_t *pinfo, int phy_addr,
344b6d90eb7SKip Macy const struct mdio_ops *mdio_ops)
345b6d90eb7SKip Macy {
346837f41b0SGeorge V. Neville-Neil int err;
347c01f2b83SNavdeep Parhar struct cphy *phy = &pinfo->phy;
348837f41b0SGeorge V. Neville-Neil
349c01f2b83SNavdeep Parhar cphy_init(phy, pinfo->adapter, pinfo, phy_addr, &ael1002_ops, mdio_ops,
3508e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE,
35119905d6dSKip Macy "10GBASE-R");
352b6d90eb7SKip Macy ael100x_txon(phy);
353f2d8ff04SGeorge V. Neville-Neil ael_laser_down(phy, 0);
354837f41b0SGeorge V. Neville-Neil
355837f41b0SGeorge V. Neville-Neil err = ael1002_get_module_type(phy, 0);
356837f41b0SGeorge V. Neville-Neil if (err >= 0)
357837f41b0SGeorge V. Neville-Neil phy->modtype = err;
358837f41b0SGeorge V. Neville-Neil
3598e10660fSKip Macy return 0;
360b6d90eb7SKip Macy }
361b6d90eb7SKip Macy
ael1006_reset(struct cphy * phy,int wait)362b6d90eb7SKip Macy static int ael1006_reset(struct cphy *phy, int wait)
363b6d90eb7SKip Macy {
364f2d8ff04SGeorge V. Neville-Neil int err;
36590362409SGeorge V. Neville-Neil
366f2d8ff04SGeorge V. Neville-Neil err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait);
367f2d8ff04SGeorge V. Neville-Neil if (err)
368f2d8ff04SGeorge V. Neville-Neil return err;
36990362409SGeorge V. Neville-Neil
370f2d8ff04SGeorge V. Neville-Neil t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN,
371f2d8ff04SGeorge V. Neville-Neil F_GPIO6_OUT_VAL, 0);
372f2d8ff04SGeorge V. Neville-Neil
373f2d8ff04SGeorge V. Neville-Neil msleep(125);
374f2d8ff04SGeorge V. Neville-Neil
375f2d8ff04SGeorge V. Neville-Neil t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN,
376f2d8ff04SGeorge V. Neville-Neil F_GPIO6_OUT_VAL, F_GPIO6_OUT_VAL);
377f2d8ff04SGeorge V. Neville-Neil
378f2d8ff04SGeorge V. Neville-Neil msleep(125);
379f2d8ff04SGeorge V. Neville-Neil
380f2d8ff04SGeorge V. Neville-Neil err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait);
381f2d8ff04SGeorge V. Neville-Neil if (err)
382f2d8ff04SGeorge V. Neville-Neil return err;
383f2d8ff04SGeorge V. Neville-Neil
384f2d8ff04SGeorge V. Neville-Neil msleep(125);
385f2d8ff04SGeorge V. Neville-Neil
386f2d8ff04SGeorge V. Neville-Neil err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 1);
387f2d8ff04SGeorge V. Neville-Neil if (err)
388f2d8ff04SGeorge V. Neville-Neil return err;
389f2d8ff04SGeorge V. Neville-Neil
390f2d8ff04SGeorge V. Neville-Neil msleep(125);
391f2d8ff04SGeorge V. Neville-Neil
392f2d8ff04SGeorge V. Neville-Neil err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 0);
393f2d8ff04SGeorge V. Neville-Neil
394f2d8ff04SGeorge V. Neville-Neil return err;
395f2d8ff04SGeorge V. Neville-Neil
396b6d90eb7SKip Macy }
397b6d90eb7SKip Macy
398b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED
399b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = {
400b6d90eb7SKip Macy ael1006_reset,
4014af83c8cSKip Macy t3_phy_lasi_intr_enable,
4024af83c8cSKip Macy t3_phy_lasi_intr_disable,
4034af83c8cSKip Macy t3_phy_lasi_intr_clear,
4044af83c8cSKip Macy t3_phy_lasi_intr_handler,
405b6d90eb7SKip Macy NULL,
406b6d90eb7SKip Macy NULL,
407b6d90eb7SKip Macy NULL,
408b6d90eb7SKip Macy NULL,
409b6d90eb7SKip Macy NULL,
4109b4de886SKip Macy get_link_status_r,
411c01f2b83SNavdeep Parhar ael1002_power_down,
412b6d90eb7SKip Macy };
413b6d90eb7SKip Macy #else
414b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = {
415b6d90eb7SKip Macy .reset = ael1006_reset,
4164af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable,
4174af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable,
4184af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear,
4194af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler,
4209b4de886SKip Macy .get_link_status = get_link_status_r,
421c01f2b83SNavdeep Parhar .power_down = ael1002_power_down,
422b6d90eb7SKip Macy };
423b6d90eb7SKip Macy #endif
424b6d90eb7SKip Macy
t3_ael1006_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)425c01f2b83SNavdeep Parhar int t3_ael1006_phy_prep(pinfo_t *pinfo, int phy_addr,
426b6d90eb7SKip Macy const struct mdio_ops *mdio_ops)
427b6d90eb7SKip Macy {
428c01f2b83SNavdeep Parhar struct cphy *phy = &pinfo->phy;
429c01f2b83SNavdeep Parhar
430c01f2b83SNavdeep Parhar cphy_init(phy, pinfo->adapter, pinfo, phy_addr, &ael1006_ops, mdio_ops,
4318e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE,
4328e10660fSKip Macy "10GBASE-SR");
433c01f2b83SNavdeep Parhar phy->modtype = phy_modtype_sr;
434b6d90eb7SKip Macy ael100x_txon(phy);
4358e10660fSKip Macy return 0;
436b6d90eb7SKip Macy }
437b6d90eb7SKip Macy
438c01f2b83SNavdeep Parhar /*
439c01f2b83SNavdeep Parhar * Decode our module type.
440c01f2b83SNavdeep Parhar */
ael2xxx_get_module_type(struct cphy * phy,int delay_ms)441c01f2b83SNavdeep Parhar static int ael2xxx_get_module_type(struct cphy *phy, int delay_ms)
442c01f2b83SNavdeep Parhar {
443c01f2b83SNavdeep Parhar int v;
444c01f2b83SNavdeep Parhar
445c01f2b83SNavdeep Parhar if (delay_ms)
446c01f2b83SNavdeep Parhar msleep(delay_ms);
447c01f2b83SNavdeep Parhar
448c01f2b83SNavdeep Parhar v = get_phytrans_type(phy);
449c01f2b83SNavdeep Parhar if (v == phy_transtype_sfp) {
450c01f2b83SNavdeep Parhar /* SFP: see SFF-8472 for below */
451c01f2b83SNavdeep Parhar
452c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 3);
453c01f2b83SNavdeep Parhar if (v < 0)
454c01f2b83SNavdeep Parhar return v;
455c01f2b83SNavdeep Parhar
456c01f2b83SNavdeep Parhar if (v == 0x1)
457cd5c70b2SNavdeep Parhar goto twinax;
458c01f2b83SNavdeep Parhar if (v == 0x10)
459c01f2b83SNavdeep Parhar return phy_modtype_sr;
460c01f2b83SNavdeep Parhar if (v == 0x20)
461c01f2b83SNavdeep Parhar return phy_modtype_lr;
462c01f2b83SNavdeep Parhar if (v == 0x40)
463c01f2b83SNavdeep Parhar return phy_modtype_lrm;
464c01f2b83SNavdeep Parhar
465cd5c70b2SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 8);
466cd5c70b2SNavdeep Parhar if (v < 0)
467cd5c70b2SNavdeep Parhar return v;
468cd5c70b2SNavdeep Parhar if (v == 4) {
469cd5c70b2SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 60);
470cd5c70b2SNavdeep Parhar if (v < 0)
471cd5c70b2SNavdeep Parhar return v;
472cd5c70b2SNavdeep Parhar if (v & 0x1)
473cd5c70b2SNavdeep Parhar goto twinax;
474cd5c70b2SNavdeep Parhar }
475cd5c70b2SNavdeep Parhar
476c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 6);
477c01f2b83SNavdeep Parhar if (v < 0)
478c01f2b83SNavdeep Parhar return v;
479c01f2b83SNavdeep Parhar if (v != 4)
480c01f2b83SNavdeep Parhar return phy_modtype_unknown;
481c01f2b83SNavdeep Parhar
482c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 10);
483c01f2b83SNavdeep Parhar if (v < 0)
484c01f2b83SNavdeep Parhar return v;
485c01f2b83SNavdeep Parhar
486c01f2b83SNavdeep Parhar if (v & 0x80) {
487cd5c70b2SNavdeep Parhar twinax:
488c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 0x12);
489c01f2b83SNavdeep Parhar if (v < 0)
490c01f2b83SNavdeep Parhar return v;
491c01f2b83SNavdeep Parhar return v > 10 ? phy_modtype_twinax_long :
492c01f2b83SNavdeep Parhar phy_modtype_twinax;
493c01f2b83SNavdeep Parhar }
494c01f2b83SNavdeep Parhar } else if (v == phy_transtype_xfp) {
495c01f2b83SNavdeep Parhar /* XFP: See INF-8077i for details. */
496c01f2b83SNavdeep Parhar
497c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 127);
498c01f2b83SNavdeep Parhar if (v < 0)
499c01f2b83SNavdeep Parhar return v;
500c01f2b83SNavdeep Parhar
501c01f2b83SNavdeep Parhar if (v != 1) {
502c01f2b83SNavdeep Parhar /* XXX: set page select to table 1 yourself */
503c01f2b83SNavdeep Parhar return phy_modtype_unknown;
504c01f2b83SNavdeep Parhar }
505c01f2b83SNavdeep Parhar
506c01f2b83SNavdeep Parhar v = ael_i2c_rd(phy, MODULE_DEV_ADDR, 131);
507c01f2b83SNavdeep Parhar if (v < 0)
508c01f2b83SNavdeep Parhar return v;
509c01f2b83SNavdeep Parhar v &= 0xf0;
510c01f2b83SNavdeep Parhar if (v == 0x10)
511c01f2b83SNavdeep Parhar return phy_modtype_lrm;
512c01f2b83SNavdeep Parhar if (v == 0x40)
513c01f2b83SNavdeep Parhar return phy_modtype_lr;
514c01f2b83SNavdeep Parhar if (v == 0x80)
515c01f2b83SNavdeep Parhar return phy_modtype_sr;
516c01f2b83SNavdeep Parhar }
517c01f2b83SNavdeep Parhar
518c01f2b83SNavdeep Parhar return phy_modtype_unknown;
519c01f2b83SNavdeep Parhar }
520c01f2b83SNavdeep Parhar
521c01f2b83SNavdeep Parhar /*
522c01f2b83SNavdeep Parhar * Code to support the Aeluros/NetLogic 2005 10Gb PHY.
523c01f2b83SNavdeep Parhar */
ael2005_setup_sr_edc(struct cphy * phy)5244af83c8cSKip Macy static int ael2005_setup_sr_edc(struct cphy *phy)
5254af83c8cSKip Macy {
5269b4de886SKip Macy static struct reg_val regs[] = {
5279b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x181 },
5289b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc010, 0xffff, 0x448a },
5299b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5200 },
5309b4de886SKip Macy { 0, 0, 0, 0 }
5319b4de886SKip Macy };
5324af83c8cSKip Macy static u16 sr_edc[] = {
5334af83c8cSKip Macy 0xcc00, 0x2ff4,
5344af83c8cSKip Macy 0xcc01, 0x3cd4,
5354af83c8cSKip Macy 0xcc02, 0x2015,
5364af83c8cSKip Macy 0xcc03, 0x3105,
5374af83c8cSKip Macy 0xcc04, 0x6524,
5384af83c8cSKip Macy 0xcc05, 0x27ff,
5394af83c8cSKip Macy 0xcc06, 0x300f,
5404af83c8cSKip Macy 0xcc07, 0x2c8b,
5414af83c8cSKip Macy 0xcc08, 0x300b,
5424af83c8cSKip Macy 0xcc09, 0x4009,
5434af83c8cSKip Macy 0xcc0a, 0x400e,
5444af83c8cSKip Macy 0xcc0b, 0x2f72,
5454af83c8cSKip Macy 0xcc0c, 0x3002,
5464af83c8cSKip Macy 0xcc0d, 0x1002,
5474af83c8cSKip Macy 0xcc0e, 0x2172,
5484af83c8cSKip Macy 0xcc0f, 0x3012,
5494af83c8cSKip Macy 0xcc10, 0x1002,
5504af83c8cSKip Macy 0xcc11, 0x25d2,
5514af83c8cSKip Macy 0xcc12, 0x3012,
5524af83c8cSKip Macy 0xcc13, 0x1002,
5534af83c8cSKip Macy 0xcc14, 0xd01e,
5544af83c8cSKip Macy 0xcc15, 0x27d2,
5554af83c8cSKip Macy 0xcc16, 0x3012,
5564af83c8cSKip Macy 0xcc17, 0x1002,
5574af83c8cSKip Macy 0xcc18, 0x2004,
5584af83c8cSKip Macy 0xcc19, 0x3c84,
5594af83c8cSKip Macy 0xcc1a, 0x6436,
5604af83c8cSKip Macy 0xcc1b, 0x2007,
5614af83c8cSKip Macy 0xcc1c, 0x3f87,
5624af83c8cSKip Macy 0xcc1d, 0x8676,
5634af83c8cSKip Macy 0xcc1e, 0x40b7,
5644af83c8cSKip Macy 0xcc1f, 0xa746,
5654af83c8cSKip Macy 0xcc20, 0x4047,
5664af83c8cSKip Macy 0xcc21, 0x5673,
5674af83c8cSKip Macy 0xcc22, 0x2982,
5684af83c8cSKip Macy 0xcc23, 0x3002,
5694af83c8cSKip Macy 0xcc24, 0x13d2,
5704af83c8cSKip Macy 0xcc25, 0x8bbd,
5714af83c8cSKip Macy 0xcc26, 0x2862,
5724af83c8cSKip Macy 0xcc27, 0x3012,
5734af83c8cSKip Macy 0xcc28, 0x1002,
5744af83c8cSKip Macy 0xcc29, 0x2092,
5754af83c8cSKip Macy 0xcc2a, 0x3012,
5764af83c8cSKip Macy 0xcc2b, 0x1002,
5774af83c8cSKip Macy 0xcc2c, 0x5cc3,
5784af83c8cSKip Macy 0xcc2d, 0x314,
5794af83c8cSKip Macy 0xcc2e, 0x2942,
5804af83c8cSKip Macy 0xcc2f, 0x3002,
5814af83c8cSKip Macy 0xcc30, 0x1002,
5824af83c8cSKip Macy 0xcc31, 0xd019,
5834af83c8cSKip Macy 0xcc32, 0x2032,
5844af83c8cSKip Macy 0xcc33, 0x3012,
5854af83c8cSKip Macy 0xcc34, 0x1002,
5864af83c8cSKip Macy 0xcc35, 0x2a04,
5874af83c8cSKip Macy 0xcc36, 0x3c74,
5884af83c8cSKip Macy 0xcc37, 0x6435,
5894af83c8cSKip Macy 0xcc38, 0x2fa4,
5904af83c8cSKip Macy 0xcc39, 0x3cd4,
5914af83c8cSKip Macy 0xcc3a, 0x6624,
5924af83c8cSKip Macy 0xcc3b, 0x5563,
5934af83c8cSKip Macy 0xcc3c, 0x2d42,
5944af83c8cSKip Macy 0xcc3d, 0x3002,
5954af83c8cSKip Macy 0xcc3e, 0x13d2,
5964af83c8cSKip Macy 0xcc3f, 0x464d,
5974af83c8cSKip Macy 0xcc40, 0x2862,
5984af83c8cSKip Macy 0xcc41, 0x3012,
5994af83c8cSKip Macy 0xcc42, 0x1002,
6004af83c8cSKip Macy 0xcc43, 0x2032,
6014af83c8cSKip Macy 0xcc44, 0x3012,
6024af83c8cSKip Macy 0xcc45, 0x1002,
6034af83c8cSKip Macy 0xcc46, 0x2fb4,
6044af83c8cSKip Macy 0xcc47, 0x3cd4,
6054af83c8cSKip Macy 0xcc48, 0x6624,
6064af83c8cSKip Macy 0xcc49, 0x5563,
6074af83c8cSKip Macy 0xcc4a, 0x2d42,
6084af83c8cSKip Macy 0xcc4b, 0x3002,
6094af83c8cSKip Macy 0xcc4c, 0x13d2,
6104af83c8cSKip Macy 0xcc4d, 0x2ed2,
6114af83c8cSKip Macy 0xcc4e, 0x3002,
6124af83c8cSKip Macy 0xcc4f, 0x1002,
6134af83c8cSKip Macy 0xcc50, 0x2fd2,
6144af83c8cSKip Macy 0xcc51, 0x3002,
6154af83c8cSKip Macy 0xcc52, 0x1002,
6164af83c8cSKip Macy 0xcc53, 0x004,
6174af83c8cSKip Macy 0xcc54, 0x2942,
6184af83c8cSKip Macy 0xcc55, 0x3002,
6194af83c8cSKip Macy 0xcc56, 0x1002,
6204af83c8cSKip Macy 0xcc57, 0x2092,
6214af83c8cSKip Macy 0xcc58, 0x3012,
6224af83c8cSKip Macy 0xcc59, 0x1002,
6234af83c8cSKip Macy 0xcc5a, 0x5cc3,
6244af83c8cSKip Macy 0xcc5b, 0x317,
6254af83c8cSKip Macy 0xcc5c, 0x2f72,
6264af83c8cSKip Macy 0xcc5d, 0x3002,
6274af83c8cSKip Macy 0xcc5e, 0x1002,
6284af83c8cSKip Macy 0xcc5f, 0x2942,
6294af83c8cSKip Macy 0xcc60, 0x3002,
6304af83c8cSKip Macy 0xcc61, 0x1002,
6314af83c8cSKip Macy 0xcc62, 0x22cd,
6324af83c8cSKip Macy 0xcc63, 0x301d,
6334af83c8cSKip Macy 0xcc64, 0x2862,
6344af83c8cSKip Macy 0xcc65, 0x3012,
6354af83c8cSKip Macy 0xcc66, 0x1002,
6364af83c8cSKip Macy 0xcc67, 0x2ed2,
6374af83c8cSKip Macy 0xcc68, 0x3002,
6384af83c8cSKip Macy 0xcc69, 0x1002,
6394af83c8cSKip Macy 0xcc6a, 0x2d72,
6404af83c8cSKip Macy 0xcc6b, 0x3002,
6414af83c8cSKip Macy 0xcc6c, 0x1002,
6424af83c8cSKip Macy 0xcc6d, 0x628f,
6434af83c8cSKip Macy 0xcc6e, 0x2112,
6444af83c8cSKip Macy 0xcc6f, 0x3012,
6454af83c8cSKip Macy 0xcc70, 0x1002,
6464af83c8cSKip Macy 0xcc71, 0x5aa3,
6474af83c8cSKip Macy 0xcc72, 0x2dc2,
6484af83c8cSKip Macy 0xcc73, 0x3002,
6494af83c8cSKip Macy 0xcc74, 0x1312,
6504af83c8cSKip Macy 0xcc75, 0x6f72,
6514af83c8cSKip Macy 0xcc76, 0x1002,
6524af83c8cSKip Macy 0xcc77, 0x2807,
6534af83c8cSKip Macy 0xcc78, 0x31a7,
6544af83c8cSKip Macy 0xcc79, 0x20c4,
6554af83c8cSKip Macy 0xcc7a, 0x3c24,
6564af83c8cSKip Macy 0xcc7b, 0x6724,
6574af83c8cSKip Macy 0xcc7c, 0x1002,
6584af83c8cSKip Macy 0xcc7d, 0x2807,
6594af83c8cSKip Macy 0xcc7e, 0x3187,
6604af83c8cSKip Macy 0xcc7f, 0x20c4,
6614af83c8cSKip Macy 0xcc80, 0x3c24,
6624af83c8cSKip Macy 0xcc81, 0x6724,
6634af83c8cSKip Macy 0xcc82, 0x1002,
6644af83c8cSKip Macy 0xcc83, 0x2514,
6654af83c8cSKip Macy 0xcc84, 0x3c64,
6664af83c8cSKip Macy 0xcc85, 0x6436,
6674af83c8cSKip Macy 0xcc86, 0xdff4,
6684af83c8cSKip Macy 0xcc87, 0x6436,
6694af83c8cSKip Macy 0xcc88, 0x1002,
6704af83c8cSKip Macy 0xcc89, 0x40a4,
6714af83c8cSKip Macy 0xcc8a, 0x643c,
6724af83c8cSKip Macy 0xcc8b, 0x4016,
6734af83c8cSKip Macy 0xcc8c, 0x8c6c,
6744af83c8cSKip Macy 0xcc8d, 0x2b24,
6754af83c8cSKip Macy 0xcc8e, 0x3c24,
6764af83c8cSKip Macy 0xcc8f, 0x6435,
6774af83c8cSKip Macy 0xcc90, 0x1002,
6784af83c8cSKip Macy 0xcc91, 0x2b24,
6794af83c8cSKip Macy 0xcc92, 0x3c24,
6804af83c8cSKip Macy 0xcc93, 0x643a,
6814af83c8cSKip Macy 0xcc94, 0x4025,
6824af83c8cSKip Macy 0xcc95, 0x8a5a,
6834af83c8cSKip Macy 0xcc96, 0x1002,
6844af83c8cSKip Macy 0xcc97, 0x2731,
6854af83c8cSKip Macy 0xcc98, 0x3011,
6864af83c8cSKip Macy 0xcc99, 0x1001,
6874af83c8cSKip Macy 0xcc9a, 0xc7a0,
6884af83c8cSKip Macy 0xcc9b, 0x100,
6894af83c8cSKip Macy 0xcc9c, 0xc502,
6904af83c8cSKip Macy 0xcc9d, 0x53ac,
6914af83c8cSKip Macy 0xcc9e, 0xc503,
6924af83c8cSKip Macy 0xcc9f, 0xd5d5,
6934af83c8cSKip Macy 0xcca0, 0xc600,
6944af83c8cSKip Macy 0xcca1, 0x2a6d,
6954af83c8cSKip Macy 0xcca2, 0xc601,
6964af83c8cSKip Macy 0xcca3, 0x2a4c,
6974af83c8cSKip Macy 0xcca4, 0xc602,
6984af83c8cSKip Macy 0xcca5, 0x111,
6994af83c8cSKip Macy 0xcca6, 0xc60c,
7004af83c8cSKip Macy 0xcca7, 0x5900,
7014af83c8cSKip Macy 0xcca8, 0xc710,
7024af83c8cSKip Macy 0xcca9, 0x700,
7034af83c8cSKip Macy 0xccaa, 0xc718,
7044af83c8cSKip Macy 0xccab, 0x700,
7054af83c8cSKip Macy 0xccac, 0xc720,
7064af83c8cSKip Macy 0xccad, 0x4700,
7074af83c8cSKip Macy 0xccae, 0xc801,
7084af83c8cSKip Macy 0xccaf, 0x7f50,
7094af83c8cSKip Macy 0xccb0, 0xc802,
7104af83c8cSKip Macy 0xccb1, 0x7760,
7114af83c8cSKip Macy 0xccb2, 0xc803,
7124af83c8cSKip Macy 0xccb3, 0x7fce,
7134af83c8cSKip Macy 0xccb4, 0xc804,
7144af83c8cSKip Macy 0xccb5, 0x5700,
7154af83c8cSKip Macy 0xccb6, 0xc805,
7164af83c8cSKip Macy 0xccb7, 0x5f11,
7174af83c8cSKip Macy 0xccb8, 0xc806,
7184af83c8cSKip Macy 0xccb9, 0x4751,
7194af83c8cSKip Macy 0xccba, 0xc807,
7204af83c8cSKip Macy 0xccbb, 0x57e1,
7214af83c8cSKip Macy 0xccbc, 0xc808,
7224af83c8cSKip Macy 0xccbd, 0x2700,
7234af83c8cSKip Macy 0xccbe, 0xc809,
7244af83c8cSKip Macy 0xccbf, 0x000,
7254af83c8cSKip Macy 0xccc0, 0xc821,
7264af83c8cSKip Macy 0xccc1, 0x002,
7274af83c8cSKip Macy 0xccc2, 0xc822,
7284af83c8cSKip Macy 0xccc3, 0x014,
7294af83c8cSKip Macy 0xccc4, 0xc832,
7304af83c8cSKip Macy 0xccc5, 0x1186,
7314af83c8cSKip Macy 0xccc6, 0xc847,
7324af83c8cSKip Macy 0xccc7, 0x1e02,
7334af83c8cSKip Macy 0xccc8, 0xc013,
7344af83c8cSKip Macy 0xccc9, 0xf341,
7354af83c8cSKip Macy 0xccca, 0xc01a,
7364af83c8cSKip Macy 0xcccb, 0x446,
7374af83c8cSKip Macy 0xcccc, 0xc024,
7384af83c8cSKip Macy 0xcccd, 0x1000,
7394af83c8cSKip Macy 0xccce, 0xc025,
7404af83c8cSKip Macy 0xcccf, 0xa00,
7414af83c8cSKip Macy 0xccd0, 0xc026,
7424af83c8cSKip Macy 0xccd1, 0xc0c,
7434af83c8cSKip Macy 0xccd2, 0xc027,
7444af83c8cSKip Macy 0xccd3, 0xc0c,
7454af83c8cSKip Macy 0xccd4, 0xc029,
7464af83c8cSKip Macy 0xccd5, 0x0a0,
7474af83c8cSKip Macy 0xccd6, 0xc030,
7484af83c8cSKip Macy 0xccd7, 0xa00,
7494af83c8cSKip Macy 0xccd8, 0xc03c,
7504af83c8cSKip Macy 0xccd9, 0x01c,
7514af83c8cSKip Macy 0xccda, 0xc005,
7524af83c8cSKip Macy 0xccdb, 0x7a06,
7534af83c8cSKip Macy 0xccdc, 0x000,
7544af83c8cSKip Macy 0xccdd, 0x2731,
7554af83c8cSKip Macy 0xccde, 0x3011,
7564af83c8cSKip Macy 0xccdf, 0x1001,
7574af83c8cSKip Macy 0xcce0, 0xc620,
7584af83c8cSKip Macy 0xcce1, 0x000,
7594af83c8cSKip Macy 0xcce2, 0xc621,
7604af83c8cSKip Macy 0xcce3, 0x03f,
7614af83c8cSKip Macy 0xcce4, 0xc622,
7624af83c8cSKip Macy 0xcce5, 0x000,
7634af83c8cSKip Macy 0xcce6, 0xc623,
7644af83c8cSKip Macy 0xcce7, 0x000,
7654af83c8cSKip Macy 0xcce8, 0xc624,
7664af83c8cSKip Macy 0xcce9, 0x000,
7674af83c8cSKip Macy 0xccea, 0xc625,
7684af83c8cSKip Macy 0xcceb, 0x000,
7694af83c8cSKip Macy 0xccec, 0xc627,
7704af83c8cSKip Macy 0xcced, 0x000,
7714af83c8cSKip Macy 0xccee, 0xc628,
7724af83c8cSKip Macy 0xccef, 0x000,
7734af83c8cSKip Macy 0xccf0, 0xc62c,
7744af83c8cSKip Macy 0xccf1, 0x000,
7754af83c8cSKip Macy 0xccf2, 0x000,
7764af83c8cSKip Macy 0xccf3, 0x2806,
7774af83c8cSKip Macy 0xccf4, 0x3cb6,
7784af83c8cSKip Macy 0xccf5, 0xc161,
7794af83c8cSKip Macy 0xccf6, 0x6134,
7804af83c8cSKip Macy 0xccf7, 0x6135,
7814af83c8cSKip Macy 0xccf8, 0x5443,
7824af83c8cSKip Macy 0xccf9, 0x303,
7834af83c8cSKip Macy 0xccfa, 0x6524,
7844af83c8cSKip Macy 0xccfb, 0x00b,
7854af83c8cSKip Macy 0xccfc, 0x1002,
7864af83c8cSKip Macy 0xccfd, 0x2104,
7874af83c8cSKip Macy 0xccfe, 0x3c24,
7884af83c8cSKip Macy 0xccff, 0x2105,
7894af83c8cSKip Macy 0xcd00, 0x3805,
7904af83c8cSKip Macy 0xcd01, 0x6524,
7914af83c8cSKip Macy 0xcd02, 0xdff4,
7924af83c8cSKip Macy 0xcd03, 0x4005,
7934af83c8cSKip Macy 0xcd04, 0x6524,
7944af83c8cSKip Macy 0xcd05, 0x1002,
7954af83c8cSKip Macy 0xcd06, 0x5dd3,
7964af83c8cSKip Macy 0xcd07, 0x306,
7974af83c8cSKip Macy 0xcd08, 0x2ff7,
7984af83c8cSKip Macy 0xcd09, 0x38f7,
7994af83c8cSKip Macy 0xcd0a, 0x60b7,
8004af83c8cSKip Macy 0xcd0b, 0xdffd,
8014af83c8cSKip Macy 0xcd0c, 0x00a,
8024af83c8cSKip Macy 0xcd0d, 0x1002,
8034af83c8cSKip Macy 0xcd0e, 0
8044af83c8cSKip Macy };
8054af83c8cSKip Macy int i, err;
8064af83c8cSKip Macy
8079b4de886SKip Macy err = set_phy_regs(phy, regs);
8089b4de886SKip Macy if (err)
8099b4de886SKip Macy return err;
8109b4de886SKip Macy
8119b4de886SKip Macy msleep(50);
8129b4de886SKip Macy
8139b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2)
8144af83c8cSKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, sr_edc[i],
8154af83c8cSKip Macy sr_edc[i + 1]);
8169b4de886SKip Macy if (!err)
8179b4de886SKip Macy phy->priv = edc_sr;
8184af83c8cSKip Macy return err;
8194af83c8cSKip Macy }
8204af83c8cSKip Macy
ael2005_setup_twinax_edc(struct cphy * phy,int modtype)8219b4de886SKip Macy static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype)
8229b4de886SKip Macy {
8239b4de886SKip Macy static struct reg_val regs[] = {
8249b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5a00 },
8259b4de886SKip Macy { 0, 0, 0, 0 }
8269b4de886SKip Macy };
8279b4de886SKip Macy static struct reg_val preemphasis[] = {
8289b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc014, 0xffff, 0xfe16 },
8299b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc015, 0xffff, 0xa000 },
8309b4de886SKip Macy { 0, 0, 0, 0 }
8319b4de886SKip Macy };
8329b4de886SKip Macy static u16 twinax_edc[] = {
8339b4de886SKip Macy 0xcc00, 0x4009,
8349b4de886SKip Macy 0xcc01, 0x27ff,
8359b4de886SKip Macy 0xcc02, 0x300f,
8369b4de886SKip Macy 0xcc03, 0x40aa,
8379b4de886SKip Macy 0xcc04, 0x401c,
8389b4de886SKip Macy 0xcc05, 0x401e,
8399b4de886SKip Macy 0xcc06, 0x2ff4,
8409b4de886SKip Macy 0xcc07, 0x3cd4,
8419b4de886SKip Macy 0xcc08, 0x2035,
8429b4de886SKip Macy 0xcc09, 0x3145,
8439b4de886SKip Macy 0xcc0a, 0x6524,
8449b4de886SKip Macy 0xcc0b, 0x26a2,
8459b4de886SKip Macy 0xcc0c, 0x3012,
8469b4de886SKip Macy 0xcc0d, 0x1002,
8479b4de886SKip Macy 0xcc0e, 0x29c2,
8489b4de886SKip Macy 0xcc0f, 0x3002,
8499b4de886SKip Macy 0xcc10, 0x1002,
8509b4de886SKip Macy 0xcc11, 0x2072,
8519b4de886SKip Macy 0xcc12, 0x3012,
8529b4de886SKip Macy 0xcc13, 0x1002,
8539b4de886SKip Macy 0xcc14, 0x22cd,
8549b4de886SKip Macy 0xcc15, 0x301d,
8559b4de886SKip Macy 0xcc16, 0x2e52,
8569b4de886SKip Macy 0xcc17, 0x3012,
8579b4de886SKip Macy 0xcc18, 0x1002,
8589b4de886SKip Macy 0xcc19, 0x28e2,
8599b4de886SKip Macy 0xcc1a, 0x3002,
8609b4de886SKip Macy 0xcc1b, 0x1002,
8619b4de886SKip Macy 0xcc1c, 0x628f,
8629b4de886SKip Macy 0xcc1d, 0x2ac2,
8639b4de886SKip Macy 0xcc1e, 0x3012,
8649b4de886SKip Macy 0xcc1f, 0x1002,
8659b4de886SKip Macy 0xcc20, 0x5553,
8669b4de886SKip Macy 0xcc21, 0x2ae2,
8679b4de886SKip Macy 0xcc22, 0x3002,
8689b4de886SKip Macy 0xcc23, 0x1302,
8699b4de886SKip Macy 0xcc24, 0x401e,
8709b4de886SKip Macy 0xcc25, 0x2be2,
8719b4de886SKip Macy 0xcc26, 0x3012,
8729b4de886SKip Macy 0xcc27, 0x1002,
8739b4de886SKip Macy 0xcc28, 0x2da2,
8749b4de886SKip Macy 0xcc29, 0x3012,
8759b4de886SKip Macy 0xcc2a, 0x1002,
8769b4de886SKip Macy 0xcc2b, 0x2ba2,
8779b4de886SKip Macy 0xcc2c, 0x3002,
8789b4de886SKip Macy 0xcc2d, 0x1002,
8799b4de886SKip Macy 0xcc2e, 0x5ee3,
8809b4de886SKip Macy 0xcc2f, 0x305,
8819b4de886SKip Macy 0xcc30, 0x400e,
8829b4de886SKip Macy 0xcc31, 0x2bc2,
8839b4de886SKip Macy 0xcc32, 0x3002,
8849b4de886SKip Macy 0xcc33, 0x1002,
8859b4de886SKip Macy 0xcc34, 0x2b82,
8869b4de886SKip Macy 0xcc35, 0x3012,
8879b4de886SKip Macy 0xcc36, 0x1002,
8889b4de886SKip Macy 0xcc37, 0x5663,
8899b4de886SKip Macy 0xcc38, 0x302,
8909b4de886SKip Macy 0xcc39, 0x401e,
8919b4de886SKip Macy 0xcc3a, 0x6f72,
8929b4de886SKip Macy 0xcc3b, 0x1002,
8939b4de886SKip Macy 0xcc3c, 0x628f,
8949b4de886SKip Macy 0xcc3d, 0x2be2,
8959b4de886SKip Macy 0xcc3e, 0x3012,
8969b4de886SKip Macy 0xcc3f, 0x1002,
8979b4de886SKip Macy 0xcc40, 0x22cd,
8989b4de886SKip Macy 0xcc41, 0x301d,
8999b4de886SKip Macy 0xcc42, 0x2e52,
9009b4de886SKip Macy 0xcc43, 0x3012,
9019b4de886SKip Macy 0xcc44, 0x1002,
9029b4de886SKip Macy 0xcc45, 0x2522,
9039b4de886SKip Macy 0xcc46, 0x3012,
9049b4de886SKip Macy 0xcc47, 0x1002,
9059b4de886SKip Macy 0xcc48, 0x2da2,
9069b4de886SKip Macy 0xcc49, 0x3012,
9079b4de886SKip Macy 0xcc4a, 0x1002,
9089b4de886SKip Macy 0xcc4b, 0x2ca2,
9099b4de886SKip Macy 0xcc4c, 0x3012,
9109b4de886SKip Macy 0xcc4d, 0x1002,
9119b4de886SKip Macy 0xcc4e, 0x2fa4,
9129b4de886SKip Macy 0xcc4f, 0x3cd4,
9139b4de886SKip Macy 0xcc50, 0x6624,
9149b4de886SKip Macy 0xcc51, 0x410b,
9159b4de886SKip Macy 0xcc52, 0x56b3,
9169b4de886SKip Macy 0xcc53, 0x3c4,
9179b4de886SKip Macy 0xcc54, 0x2fb2,
9189b4de886SKip Macy 0xcc55, 0x3002,
9199b4de886SKip Macy 0xcc56, 0x1002,
9209b4de886SKip Macy 0xcc57, 0x220b,
9219b4de886SKip Macy 0xcc58, 0x303b,
9229b4de886SKip Macy 0xcc59, 0x56b3,
9239b4de886SKip Macy 0xcc5a, 0x3c3,
9249b4de886SKip Macy 0xcc5b, 0x866b,
9259b4de886SKip Macy 0xcc5c, 0x400c,
9269b4de886SKip Macy 0xcc5d, 0x23a2,
9279b4de886SKip Macy 0xcc5e, 0x3012,
9289b4de886SKip Macy 0xcc5f, 0x1002,
9299b4de886SKip Macy 0xcc60, 0x2da2,
9309b4de886SKip Macy 0xcc61, 0x3012,
9319b4de886SKip Macy 0xcc62, 0x1002,
9329b4de886SKip Macy 0xcc63, 0x2ca2,
9339b4de886SKip Macy 0xcc64, 0x3012,
9349b4de886SKip Macy 0xcc65, 0x1002,
9359b4de886SKip Macy 0xcc66, 0x2fb4,
9369b4de886SKip Macy 0xcc67, 0x3cd4,
9379b4de886SKip Macy 0xcc68, 0x6624,
9389b4de886SKip Macy 0xcc69, 0x56b3,
9399b4de886SKip Macy 0xcc6a, 0x3c3,
9409b4de886SKip Macy 0xcc6b, 0x866b,
9419b4de886SKip Macy 0xcc6c, 0x401c,
9429b4de886SKip Macy 0xcc6d, 0x2205,
9439b4de886SKip Macy 0xcc6e, 0x3035,
9449b4de886SKip Macy 0xcc6f, 0x5b53,
9459b4de886SKip Macy 0xcc70, 0x2c52,
9469b4de886SKip Macy 0xcc71, 0x3002,
9479b4de886SKip Macy 0xcc72, 0x13c2,
9489b4de886SKip Macy 0xcc73, 0x5cc3,
9499b4de886SKip Macy 0xcc74, 0x317,
9509b4de886SKip Macy 0xcc75, 0x2522,
9519b4de886SKip Macy 0xcc76, 0x3012,
9529b4de886SKip Macy 0xcc77, 0x1002,
9539b4de886SKip Macy 0xcc78, 0x2da2,
9549b4de886SKip Macy 0xcc79, 0x3012,
9559b4de886SKip Macy 0xcc7a, 0x1002,
9569b4de886SKip Macy 0xcc7b, 0x2b82,
9579b4de886SKip Macy 0xcc7c, 0x3012,
9589b4de886SKip Macy 0xcc7d, 0x1002,
9599b4de886SKip Macy 0xcc7e, 0x5663,
9609b4de886SKip Macy 0xcc7f, 0x303,
9619b4de886SKip Macy 0xcc80, 0x401e,
9629b4de886SKip Macy 0xcc81, 0x004,
9639b4de886SKip Macy 0xcc82, 0x2c42,
9649b4de886SKip Macy 0xcc83, 0x3012,
9659b4de886SKip Macy 0xcc84, 0x1002,
9669b4de886SKip Macy 0xcc85, 0x6f72,
9679b4de886SKip Macy 0xcc86, 0x1002,
9689b4de886SKip Macy 0xcc87, 0x628f,
9699b4de886SKip Macy 0xcc88, 0x2304,
9709b4de886SKip Macy 0xcc89, 0x3c84,
9719b4de886SKip Macy 0xcc8a, 0x6436,
9729b4de886SKip Macy 0xcc8b, 0xdff4,
9739b4de886SKip Macy 0xcc8c, 0x6436,
9749b4de886SKip Macy 0xcc8d, 0x2ff5,
9759b4de886SKip Macy 0xcc8e, 0x3005,
9769b4de886SKip Macy 0xcc8f, 0x8656,
9779b4de886SKip Macy 0xcc90, 0xdfba,
9789b4de886SKip Macy 0xcc91, 0x56a3,
9799b4de886SKip Macy 0xcc92, 0xd05a,
9809b4de886SKip Macy 0xcc93, 0x21c2,
9819b4de886SKip Macy 0xcc94, 0x3012,
9829b4de886SKip Macy 0xcc95, 0x1392,
9839b4de886SKip Macy 0xcc96, 0xd05a,
9849b4de886SKip Macy 0xcc97, 0x56a3,
9859b4de886SKip Macy 0xcc98, 0xdfba,
9869b4de886SKip Macy 0xcc99, 0x383,
9879b4de886SKip Macy 0xcc9a, 0x6f72,
9889b4de886SKip Macy 0xcc9b, 0x1002,
9899b4de886SKip Macy 0xcc9c, 0x28c5,
9909b4de886SKip Macy 0xcc9d, 0x3005,
9919b4de886SKip Macy 0xcc9e, 0x4178,
9929b4de886SKip Macy 0xcc9f, 0x5653,
9939b4de886SKip Macy 0xcca0, 0x384,
9949b4de886SKip Macy 0xcca1, 0x22b2,
9959b4de886SKip Macy 0xcca2, 0x3012,
9969b4de886SKip Macy 0xcca3, 0x1002,
9979b4de886SKip Macy 0xcca4, 0x2be5,
9989b4de886SKip Macy 0xcca5, 0x3005,
9999b4de886SKip Macy 0xcca6, 0x41e8,
10009b4de886SKip Macy 0xcca7, 0x5653,
10019b4de886SKip Macy 0xcca8, 0x382,
10029b4de886SKip Macy 0xcca9, 0x002,
10039b4de886SKip Macy 0xccaa, 0x4258,
10049b4de886SKip Macy 0xccab, 0x2474,
10059b4de886SKip Macy 0xccac, 0x3c84,
10069b4de886SKip Macy 0xccad, 0x6437,
10079b4de886SKip Macy 0xccae, 0xdff4,
10089b4de886SKip Macy 0xccaf, 0x6437,
10099b4de886SKip Macy 0xccb0, 0x2ff5,
10109b4de886SKip Macy 0xccb1, 0x3c05,
10119b4de886SKip Macy 0xccb2, 0x8757,
10129b4de886SKip Macy 0xccb3, 0xb888,
10139b4de886SKip Macy 0xccb4, 0x9787,
10149b4de886SKip Macy 0xccb5, 0xdff4,
10159b4de886SKip Macy 0xccb6, 0x6724,
10169b4de886SKip Macy 0xccb7, 0x866a,
10179b4de886SKip Macy 0xccb8, 0x6f72,
10189b4de886SKip Macy 0xccb9, 0x1002,
10199b4de886SKip Macy 0xccba, 0x2d01,
10209b4de886SKip Macy 0xccbb, 0x3011,
10219b4de886SKip Macy 0xccbc, 0x1001,
10229b4de886SKip Macy 0xccbd, 0xc620,
10239b4de886SKip Macy 0xccbe, 0x14e5,
10249b4de886SKip Macy 0xccbf, 0xc621,
10259b4de886SKip Macy 0xccc0, 0xc53d,
10269b4de886SKip Macy 0xccc1, 0xc622,
10279b4de886SKip Macy 0xccc2, 0x3cbe,
10289b4de886SKip Macy 0xccc3, 0xc623,
10299b4de886SKip Macy 0xccc4, 0x4452,
10309b4de886SKip Macy 0xccc5, 0xc624,
10319b4de886SKip Macy 0xccc6, 0xc5c5,
10329b4de886SKip Macy 0xccc7, 0xc625,
10339b4de886SKip Macy 0xccc8, 0xe01e,
10349b4de886SKip Macy 0xccc9, 0xc627,
10359b4de886SKip Macy 0xccca, 0x000,
10369b4de886SKip Macy 0xcccb, 0xc628,
10379b4de886SKip Macy 0xcccc, 0x000,
10389b4de886SKip Macy 0xcccd, 0xc62b,
10399b4de886SKip Macy 0xccce, 0x000,
10409b4de886SKip Macy 0xcccf, 0xc62c,
10419b4de886SKip Macy 0xccd0, 0x000,
10429b4de886SKip Macy 0xccd1, 0x000,
10439b4de886SKip Macy 0xccd2, 0x2d01,
10449b4de886SKip Macy 0xccd3, 0x3011,
10459b4de886SKip Macy 0xccd4, 0x1001,
10469b4de886SKip Macy 0xccd5, 0xc620,
10479b4de886SKip Macy 0xccd6, 0x000,
10489b4de886SKip Macy 0xccd7, 0xc621,
10499b4de886SKip Macy 0xccd8, 0x000,
10509b4de886SKip Macy 0xccd9, 0xc622,
10519b4de886SKip Macy 0xccda, 0x0ce,
10529b4de886SKip Macy 0xccdb, 0xc623,
10539b4de886SKip Macy 0xccdc, 0x07f,
10549b4de886SKip Macy 0xccdd, 0xc624,
10559b4de886SKip Macy 0xccde, 0x032,
10569b4de886SKip Macy 0xccdf, 0xc625,
10579b4de886SKip Macy 0xcce0, 0x000,
10589b4de886SKip Macy 0xcce1, 0xc627,
10599b4de886SKip Macy 0xcce2, 0x000,
10609b4de886SKip Macy 0xcce3, 0xc628,
10619b4de886SKip Macy 0xcce4, 0x000,
10629b4de886SKip Macy 0xcce5, 0xc62b,
10639b4de886SKip Macy 0xcce6, 0x000,
10649b4de886SKip Macy 0xcce7, 0xc62c,
10659b4de886SKip Macy 0xcce8, 0x000,
10669b4de886SKip Macy 0xcce9, 0x000,
10679b4de886SKip Macy 0xccea, 0x2d01,
10689b4de886SKip Macy 0xcceb, 0x3011,
10699b4de886SKip Macy 0xccec, 0x1001,
10709b4de886SKip Macy 0xcced, 0xc502,
10719b4de886SKip Macy 0xccee, 0x609f,
10729b4de886SKip Macy 0xccef, 0xc600,
10739b4de886SKip Macy 0xccf0, 0x2a6e,
10749b4de886SKip Macy 0xccf1, 0xc601,
10759b4de886SKip Macy 0xccf2, 0x2a2c,
10769b4de886SKip Macy 0xccf3, 0xc60c,
10779b4de886SKip Macy 0xccf4, 0x5400,
10789b4de886SKip Macy 0xccf5, 0xc710,
10799b4de886SKip Macy 0xccf6, 0x700,
10809b4de886SKip Macy 0xccf7, 0xc718,
10819b4de886SKip Macy 0xccf8, 0x700,
10829b4de886SKip Macy 0xccf9, 0xc720,
10839b4de886SKip Macy 0xccfa, 0x4700,
10849b4de886SKip Macy 0xccfb, 0xc728,
10859b4de886SKip Macy 0xccfc, 0x700,
10869b4de886SKip Macy 0xccfd, 0xc729,
10879b4de886SKip Macy 0xccfe, 0x1207,
10889b4de886SKip Macy 0xccff, 0xc801,
10899b4de886SKip Macy 0xcd00, 0x7f50,
10909b4de886SKip Macy 0xcd01, 0xc802,
10919b4de886SKip Macy 0xcd02, 0x7760,
10929b4de886SKip Macy 0xcd03, 0xc803,
10939b4de886SKip Macy 0xcd04, 0x7fce,
10949b4de886SKip Macy 0xcd05, 0xc804,
10959b4de886SKip Macy 0xcd06, 0x520e,
10969b4de886SKip Macy 0xcd07, 0xc805,
10979b4de886SKip Macy 0xcd08, 0x5c11,
10989b4de886SKip Macy 0xcd09, 0xc806,
10999b4de886SKip Macy 0xcd0a, 0x3c51,
11009b4de886SKip Macy 0xcd0b, 0xc807,
11019b4de886SKip Macy 0xcd0c, 0x4061,
11029b4de886SKip Macy 0xcd0d, 0xc808,
11039b4de886SKip Macy 0xcd0e, 0x49c1,
11049b4de886SKip Macy 0xcd0f, 0xc809,
11059b4de886SKip Macy 0xcd10, 0x3840,
11069b4de886SKip Macy 0xcd11, 0xc80a,
11079b4de886SKip Macy 0xcd12, 0x000,
11089b4de886SKip Macy 0xcd13, 0xc821,
11099b4de886SKip Macy 0xcd14, 0x002,
11109b4de886SKip Macy 0xcd15, 0xc822,
11119b4de886SKip Macy 0xcd16, 0x046,
11129b4de886SKip Macy 0xcd17, 0xc844,
11139b4de886SKip Macy 0xcd18, 0x182f,
11149b4de886SKip Macy 0xcd19, 0xc013,
11159b4de886SKip Macy 0xcd1a, 0xf341,
11169b4de886SKip Macy 0xcd1b, 0xc01a,
11179b4de886SKip Macy 0xcd1c, 0x446,
11189b4de886SKip Macy 0xcd1d, 0xc024,
11199b4de886SKip Macy 0xcd1e, 0x1000,
11209b4de886SKip Macy 0xcd1f, 0xc025,
11219b4de886SKip Macy 0xcd20, 0xa00,
11229b4de886SKip Macy 0xcd21, 0xc026,
11239b4de886SKip Macy 0xcd22, 0xc0c,
11249b4de886SKip Macy 0xcd23, 0xc027,
11259b4de886SKip Macy 0xcd24, 0xc0c,
11269b4de886SKip Macy 0xcd25, 0xc029,
11279b4de886SKip Macy 0xcd26, 0x0a0,
11289b4de886SKip Macy 0xcd27, 0xc030,
11299b4de886SKip Macy 0xcd28, 0xa00,
11309b4de886SKip Macy 0xcd29, 0xc03c,
11319b4de886SKip Macy 0xcd2a, 0x01c,
11329b4de886SKip Macy 0xcd2b, 0x000,
11339b4de886SKip Macy 0xcd2c, 0x2b84,
11349b4de886SKip Macy 0xcd2d, 0x3c74,
11359b4de886SKip Macy 0xcd2e, 0x6435,
11369b4de886SKip Macy 0xcd2f, 0xdff4,
11379b4de886SKip Macy 0xcd30, 0x6435,
11389b4de886SKip Macy 0xcd31, 0x2806,
11399b4de886SKip Macy 0xcd32, 0x3006,
11409b4de886SKip Macy 0xcd33, 0x8565,
11419b4de886SKip Macy 0xcd34, 0x2b24,
11429b4de886SKip Macy 0xcd35, 0x3c24,
11439b4de886SKip Macy 0xcd36, 0x6436,
11449b4de886SKip Macy 0xcd37, 0x1002,
11459b4de886SKip Macy 0xcd38, 0x2b24,
11469b4de886SKip Macy 0xcd39, 0x3c24,
11479b4de886SKip Macy 0xcd3a, 0x6436,
11489b4de886SKip Macy 0xcd3b, 0x4045,
11499b4de886SKip Macy 0xcd3c, 0x8656,
11509b4de886SKip Macy 0xcd3d, 0x1002,
11519b4de886SKip Macy 0xcd3e, 0x2807,
11529b4de886SKip Macy 0xcd3f, 0x31a7,
11539b4de886SKip Macy 0xcd40, 0x20c4,
11549b4de886SKip Macy 0xcd41, 0x3c24,
11559b4de886SKip Macy 0xcd42, 0x6724,
11569b4de886SKip Macy 0xcd43, 0x1002,
11579b4de886SKip Macy 0xcd44, 0x2807,
11589b4de886SKip Macy 0xcd45, 0x3187,
11599b4de886SKip Macy 0xcd46, 0x20c4,
11609b4de886SKip Macy 0xcd47, 0x3c24,
11619b4de886SKip Macy 0xcd48, 0x6724,
11629b4de886SKip Macy 0xcd49, 0x1002,
11639b4de886SKip Macy 0xcd4a, 0x2514,
11649b4de886SKip Macy 0xcd4b, 0x3c64,
11659b4de886SKip Macy 0xcd4c, 0x6436,
11669b4de886SKip Macy 0xcd4d, 0xdff4,
11679b4de886SKip Macy 0xcd4e, 0x6436,
11689b4de886SKip Macy 0xcd4f, 0x1002,
11699b4de886SKip Macy 0xcd50, 0x2806,
11709b4de886SKip Macy 0xcd51, 0x3cb6,
11719b4de886SKip Macy 0xcd52, 0xc161,
11729b4de886SKip Macy 0xcd53, 0x6134,
11739b4de886SKip Macy 0xcd54, 0x6135,
11749b4de886SKip Macy 0xcd55, 0x5443,
11759b4de886SKip Macy 0xcd56, 0x303,
11769b4de886SKip Macy 0xcd57, 0x6524,
11779b4de886SKip Macy 0xcd58, 0x00b,
11789b4de886SKip Macy 0xcd59, 0x1002,
11799b4de886SKip Macy 0xcd5a, 0xd019,
11809b4de886SKip Macy 0xcd5b, 0x2104,
11819b4de886SKip Macy 0xcd5c, 0x3c24,
11829b4de886SKip Macy 0xcd5d, 0x2105,
11839b4de886SKip Macy 0xcd5e, 0x3805,
11849b4de886SKip Macy 0xcd5f, 0x6524,
11859b4de886SKip Macy 0xcd60, 0xdff4,
11869b4de886SKip Macy 0xcd61, 0x4005,
11879b4de886SKip Macy 0xcd62, 0x6524,
11889b4de886SKip Macy 0xcd63, 0x2e8d,
11899b4de886SKip Macy 0xcd64, 0x303d,
11909b4de886SKip Macy 0xcd65, 0x5dd3,
11919b4de886SKip Macy 0xcd66, 0x306,
11929b4de886SKip Macy 0xcd67, 0x2ff7,
11939b4de886SKip Macy 0xcd68, 0x38f7,
11949b4de886SKip Macy 0xcd69, 0x60b7,
11959b4de886SKip Macy 0xcd6a, 0xdffd,
11969b4de886SKip Macy 0xcd6b, 0x00a,
11979b4de886SKip Macy 0xcd6c, 0x1002,
11989b4de886SKip Macy 0xcd6d, 0
11999b4de886SKip Macy };
12009b4de886SKip Macy int i, err;
12019b4de886SKip Macy
12029b4de886SKip Macy err = set_phy_regs(phy, regs);
12039b4de886SKip Macy if (!err && modtype == phy_modtype_twinax_long)
12049b4de886SKip Macy err = set_phy_regs(phy, preemphasis);
12059b4de886SKip Macy if (err)
12069b4de886SKip Macy return err;
12079b4de886SKip Macy
12089b4de886SKip Macy msleep(50);
12099b4de886SKip Macy
12109b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2)
12119b4de886SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i],
12129b4de886SKip Macy twinax_edc[i + 1]);
12139b4de886SKip Macy if (!err)
12149b4de886SKip Macy phy->priv = edc_twinax;
12159b4de886SKip Macy return err;
12169b4de886SKip Macy }
12179b4de886SKip Macy
ael2005_get_module_type(struct cphy * phy,int delay_ms)1218c01f2b83SNavdeep Parhar static int ael2005_get_module_type(struct cphy *phy, int delay_ms)
12199b4de886SKip Macy {
12209b4de886SKip Macy int v;
1221c01f2b83SNavdeep Parhar unsigned int stat;
12229b4de886SKip Macy
1223c01f2b83SNavdeep Parhar v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat);
1224c01f2b83SNavdeep Parhar if (v)
12259b4de886SKip Macy return v;
12269b4de886SKip Macy
1227c01f2b83SNavdeep Parhar if (stat & (1 << 8)) /* module absent */
1228c01f2b83SNavdeep Parhar return phy_modtype_none;
12299b4de886SKip Macy
1230c01f2b83SNavdeep Parhar return ael2xxx_get_module_type(phy, delay_ms);
12319b4de886SKip Macy }
12329b4de886SKip Macy
ael2005_intr_enable(struct cphy * phy)12339b4de886SKip Macy static int ael2005_intr_enable(struct cphy *phy)
12349b4de886SKip Macy {
12359b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200);
12369b4de886SKip Macy return err ? err : t3_phy_lasi_intr_enable(phy);
12379b4de886SKip Macy }
12389b4de886SKip Macy
ael2005_intr_disable(struct cphy * phy)12399b4de886SKip Macy static int ael2005_intr_disable(struct cphy *phy)
12409b4de886SKip Macy {
12419b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x100);
12429b4de886SKip Macy return err ? err : t3_phy_lasi_intr_disable(phy);
12439b4de886SKip Macy }
12449b4de886SKip Macy
ael2005_intr_clear(struct cphy * phy)12459b4de886SKip Macy static int ael2005_intr_clear(struct cphy *phy)
12469b4de886SKip Macy {
12479b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0xd00);
12489b4de886SKip Macy return err ? err : t3_phy_lasi_intr_clear(phy);
12499b4de886SKip Macy }
12509b4de886SKip Macy
ael2005_reset(struct cphy * phy,int wait)12514af83c8cSKip Macy static int ael2005_reset(struct cphy *phy, int wait)
12524af83c8cSKip Macy {
12534af83c8cSKip Macy static struct reg_val regs0[] = {
12544af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc001, 0, 1 << 5 },
12554af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc017, 0, 1 << 5 },
12564af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc013, 0xffff, 0xf341 },
12574af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 },
12584af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8100 },
12594af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 },
12604af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0 },
12614af83c8cSKip Macy { 0, 0, 0, 0 }
12624af83c8cSKip Macy };
12634af83c8cSKip Macy static struct reg_val regs1[] = {
12644af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca00, 0xffff, 0x0080 },
12654af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0 },
12664af83c8cSKip Macy { 0, 0, 0, 0 }
12674af83c8cSKip Macy };
12684af83c8cSKip Macy
1269c01f2b83SNavdeep Parhar int err;
1270c01f2b83SNavdeep Parhar unsigned int lasi_ctrl;
12719b4de886SKip Macy
12729b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl);
12739b4de886SKip Macy if (err)
12749b4de886SKip Macy return err;
12754af83c8cSKip Macy
12764af83c8cSKip Macy err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 0);
12774af83c8cSKip Macy if (err)
12784af83c8cSKip Macy return err;
12794af83c8cSKip Macy
12804af83c8cSKip Macy msleep(125);
12819b4de886SKip Macy phy->priv = edc_none;
12824af83c8cSKip Macy err = set_phy_regs(phy, regs0);
12834af83c8cSKip Macy if (err)
12844af83c8cSKip Macy return err;
12854af83c8cSKip Macy
12864af83c8cSKip Macy msleep(50);
12874af83c8cSKip Macy
1288837f41b0SGeorge V. Neville-Neil err = ael2005_get_module_type(phy, 0);
12899b4de886SKip Macy if (err < 0)
12909b4de886SKip Macy return err;
12919b4de886SKip Macy phy->modtype = (u8)err;
12929b4de886SKip Macy
12931fa10c92SNavdeep Parhar if (err == phy_modtype_none)
12940bbdea77SGeorge V. Neville-Neil err = 0;
12950bbdea77SGeorge V. Neville-Neil else if (err == phy_modtype_twinax || err == phy_modtype_twinax_long)
12969b4de886SKip Macy err = ael2005_setup_twinax_edc(phy, err);
12979b4de886SKip Macy else
12984af83c8cSKip Macy err = ael2005_setup_sr_edc(phy);
12994af83c8cSKip Macy if (err)
13004af83c8cSKip Macy return err;
13014af83c8cSKip Macy
13029b4de886SKip Macy err = set_phy_regs(phy, regs1);
13039b4de886SKip Macy if (err)
13049b4de886SKip Macy return err;
13059b4de886SKip Macy
13069b4de886SKip Macy /* reset wipes out interrupts, reenable them if they were on */
13079b4de886SKip Macy if (lasi_ctrl & 1)
13089b4de886SKip Macy err = ael2005_intr_enable(phy);
13099b4de886SKip Macy return err;
13109b4de886SKip Macy }
13119b4de886SKip Macy
ael2005_intr_handler(struct cphy * phy)13129b4de886SKip Macy static int ael2005_intr_handler(struct cphy *phy)
13139b4de886SKip Macy {
13149b4de886SKip Macy unsigned int stat;
13159b4de886SKip Macy int ret, edc_needed, cause = 0;
13169b4de886SKip Macy
13179b4de886SKip Macy ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_STAT, &stat);
13189b4de886SKip Macy if (ret)
13199b4de886SKip Macy return ret;
13209b4de886SKip Macy
13219b4de886SKip Macy if (stat & AEL2005_MODDET_IRQ) {
13229b4de886SKip Macy ret = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL,
13239b4de886SKip Macy 0xd00);
13249b4de886SKip Macy if (ret)
13259b4de886SKip Macy return ret;
13269b4de886SKip Macy
13279b4de886SKip Macy /* modules have max 300 ms init time after hot plug */
1328837f41b0SGeorge V. Neville-Neil ret = ael2005_get_module_type(phy, 300);
13299b4de886SKip Macy if (ret < 0)
13309b4de886SKip Macy return ret;
13319b4de886SKip Macy
13329b4de886SKip Macy phy->modtype = (u8)ret;
13339b4de886SKip Macy if (ret == phy_modtype_none)
13349b4de886SKip Macy edc_needed = phy->priv; /* on unplug retain EDC */
13359b4de886SKip Macy else if (ret == phy_modtype_twinax ||
13369b4de886SKip Macy ret == phy_modtype_twinax_long)
13379b4de886SKip Macy edc_needed = edc_twinax;
13389b4de886SKip Macy else
13399b4de886SKip Macy edc_needed = edc_sr;
13409b4de886SKip Macy
13419b4de886SKip Macy if (edc_needed != phy->priv) {
13429b4de886SKip Macy ret = ael2005_reset(phy, 0);
13439b4de886SKip Macy return ret ? ret : cphy_cause_module_change;
13449b4de886SKip Macy }
13459b4de886SKip Macy cause = cphy_cause_module_change;
13469b4de886SKip Macy }
13479b4de886SKip Macy
13489b4de886SKip Macy ret = t3_phy_lasi_intr_handler(phy);
1349f2d8ff04SGeorge V. Neville-Neil if (ret < 0)
1350f2d8ff04SGeorge V. Neville-Neil return ret;
1351f2d8ff04SGeorge V. Neville-Neil
1352f2d8ff04SGeorge V. Neville-Neil ret |= cause;
1353a5eb009bSNavdeep Parhar if (!ret)
1354f2d8ff04SGeorge V. Neville-Neil ret |= cphy_cause_link_change;
1355f2d8ff04SGeorge V. Neville-Neil return ret;
13564af83c8cSKip Macy }
13574af83c8cSKip Macy
13584af83c8cSKip Macy static struct cphy_ops ael2005_ops = {
1359c01f2b83SNavdeep Parhar #ifdef C99_NOT_SUPPORTED
13604af83c8cSKip Macy ael2005_reset,
13619b4de886SKip Macy ael2005_intr_enable,
13629b4de886SKip Macy ael2005_intr_disable,
13639b4de886SKip Macy ael2005_intr_clear,
13649b4de886SKip Macy ael2005_intr_handler,
13654af83c8cSKip Macy NULL,
13664af83c8cSKip Macy NULL,
13674af83c8cSKip Macy NULL,
13684af83c8cSKip Macy NULL,
13694af83c8cSKip Macy NULL,
13709b4de886SKip Macy get_link_status_r,
13714af83c8cSKip Macy ael1002_power_down,
13724af83c8cSKip Macy #else
13734af83c8cSKip Macy .reset = ael2005_reset,
13749b4de886SKip Macy .intr_enable = ael2005_intr_enable,
13759b4de886SKip Macy .intr_disable = ael2005_intr_disable,
13769b4de886SKip Macy .intr_clear = ael2005_intr_clear,
13779b4de886SKip Macy .intr_handler = ael2005_intr_handler,
13789b4de886SKip Macy .get_link_status = get_link_status_r,
13794af83c8cSKip Macy .power_down = ael1002_power_down,
13804af83c8cSKip Macy #endif
1381c01f2b83SNavdeep Parhar };
13824af83c8cSKip Macy
t3_ael2005_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)1383c01f2b83SNavdeep Parhar int t3_ael2005_phy_prep(pinfo_t *pinfo, int phy_addr,
13844af83c8cSKip Macy const struct mdio_ops *mdio_ops)
13854af83c8cSKip Macy {
1386837f41b0SGeorge V. Neville-Neil int err;
1387c01f2b83SNavdeep Parhar struct cphy *phy = &pinfo->phy;
1388c01f2b83SNavdeep Parhar
1389c01f2b83SNavdeep Parhar cphy_init(phy, pinfo->adapter, pinfo, phy_addr, &ael2005_ops, mdio_ops,
13909b4de886SKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE |
13919b4de886SKip Macy SUPPORTED_IRQ, "10GBASE-R");
13924af83c8cSKip Macy msleep(125);
1393f2d8ff04SGeorge V. Neville-Neil ael_laser_down(phy, 0);
1394837f41b0SGeorge V. Neville-Neil
1395837f41b0SGeorge V. Neville-Neil err = ael2005_get_module_type(phy, 0);
1396837f41b0SGeorge V. Neville-Neil if (err >= 0)
1397837f41b0SGeorge V. Neville-Neil phy->modtype = err;
1398837f41b0SGeorge V. Neville-Neil
13994af83c8cSKip Macy return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL_OPT_SETTINGS, 0,
14004af83c8cSKip Macy 1 << 5);
14014af83c8cSKip Macy }
14024af83c8cSKip Macy
14039b4de886SKip Macy /*
1404c01f2b83SNavdeep Parhar * Setup EDC and other parameters for operation with an optical module.
1405c01f2b83SNavdeep Parhar */
ael2020_setup_sr_edc(struct cphy * phy)1406c01f2b83SNavdeep Parhar static int ael2020_setup_sr_edc(struct cphy *phy)
1407c01f2b83SNavdeep Parhar {
1408c01f2b83SNavdeep Parhar static struct reg_val regs[] = {
1409c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xcc01, 0xffff, 0x488a },
1410c01f2b83SNavdeep Parhar
1411c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xcb1b, 0xffff, 0x0200 },
1412c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xcb1c, 0xffff, 0x00f0 },
1413c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xcc06, 0xffff, 0x00e0 },
1414c01f2b83SNavdeep Parhar
1415c01f2b83SNavdeep Parhar /* end */
1416c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1417c01f2b83SNavdeep Parhar };
1418c01f2b83SNavdeep Parhar int err;
1419c01f2b83SNavdeep Parhar
1420c01f2b83SNavdeep Parhar err = set_phy_regs(phy, regs);
1421c01f2b83SNavdeep Parhar msleep(50);
1422c01f2b83SNavdeep Parhar if (err)
1423c01f2b83SNavdeep Parhar return err;
1424c01f2b83SNavdeep Parhar
1425c01f2b83SNavdeep Parhar phy->priv = edc_sr;
1426c01f2b83SNavdeep Parhar return 0;
1427c01f2b83SNavdeep Parhar }
1428c01f2b83SNavdeep Parhar
1429c01f2b83SNavdeep Parhar /*
1430c01f2b83SNavdeep Parhar * Setup EDC and other parameters for operation with an TWINAX module.
1431c01f2b83SNavdeep Parhar */
ael2020_setup_twinax_edc(struct cphy * phy,int modtype)1432c01f2b83SNavdeep Parhar static int ael2020_setup_twinax_edc(struct cphy *phy, int modtype)
1433c01f2b83SNavdeep Parhar {
1434c01f2b83SNavdeep Parhar static struct reg_val uCclock40MHz[] = {
1435c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xff28, 0xffff, 0x4001 },
1436c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xff2a, 0xffff, 0x0002 },
1437c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1438c01f2b83SNavdeep Parhar };
1439c01f2b83SNavdeep Parhar
1440c01f2b83SNavdeep Parhar static struct reg_val uCclockActivate[] = {
1441c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xd000, 0xffff, 0x5200 },
1442c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1443c01f2b83SNavdeep Parhar };
1444c01f2b83SNavdeep Parhar
1445c01f2b83SNavdeep Parhar static struct reg_val uCactivate[] = {
1446c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xd080, 0xffff, 0x0100 },
1447c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xd092, 0xffff, 0x0000 },
1448c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1449c01f2b83SNavdeep Parhar };
1450c01f2b83SNavdeep Parhar
1451c01f2b83SNavdeep Parhar static u16 twinax_edc[] = {
1452c01f2b83SNavdeep Parhar 0xd800, 0x4009,
1453c01f2b83SNavdeep Parhar 0xd801, 0x2fff,
1454c01f2b83SNavdeep Parhar 0xd802, 0x300f,
1455c01f2b83SNavdeep Parhar 0xd803, 0x40aa,
1456c01f2b83SNavdeep Parhar 0xd804, 0x401c,
1457c01f2b83SNavdeep Parhar 0xd805, 0x401e,
145883179d39SNavdeep Parhar 0xd806, 0x20c5,
145983179d39SNavdeep Parhar 0xd807, 0x3c05,
146083179d39SNavdeep Parhar 0xd808, 0x6536,
146183179d39SNavdeep Parhar 0xd809, 0x2fe4,
146283179d39SNavdeep Parhar 0xd80a, 0x3dc4,
146383179d39SNavdeep Parhar 0xd80b, 0x6624,
146483179d39SNavdeep Parhar 0xd80c, 0x2ff4,
146583179d39SNavdeep Parhar 0xd80d, 0x3dc4,
146683179d39SNavdeep Parhar 0xd80e, 0x2035,
146783179d39SNavdeep Parhar 0xd80f, 0x30a5,
146883179d39SNavdeep Parhar 0xd810, 0x6524,
146983179d39SNavdeep Parhar 0xd811, 0x2ca2,
147083179d39SNavdeep Parhar 0xd812, 0x3012,
1471c01f2b83SNavdeep Parhar 0xd813, 0x1002,
147283179d39SNavdeep Parhar 0xd814, 0x27e2,
147383179d39SNavdeep Parhar 0xd815, 0x3022,
1474c01f2b83SNavdeep Parhar 0xd816, 0x1002,
147583179d39SNavdeep Parhar 0xd817, 0x28d2,
1476c01f2b83SNavdeep Parhar 0xd818, 0x3022,
1477c01f2b83SNavdeep Parhar 0xd819, 0x1002,
147883179d39SNavdeep Parhar 0xd81a, 0x2892,
1479c01f2b83SNavdeep Parhar 0xd81b, 0x3012,
1480c01f2b83SNavdeep Parhar 0xd81c, 0x1002,
148183179d39SNavdeep Parhar 0xd81d, 0x24e2,
1482c01f2b83SNavdeep Parhar 0xd81e, 0x3022,
1483c01f2b83SNavdeep Parhar 0xd81f, 0x1002,
148483179d39SNavdeep Parhar 0xd820, 0x27e2,
148583179d39SNavdeep Parhar 0xd821, 0x3012,
148683179d39SNavdeep Parhar 0xd822, 0x1002,
148783179d39SNavdeep Parhar 0xd823, 0x2422,
148883179d39SNavdeep Parhar 0xd824, 0x3022,
148983179d39SNavdeep Parhar 0xd825, 0x1002,
149083179d39SNavdeep Parhar 0xd826, 0x22cd,
149183179d39SNavdeep Parhar 0xd827, 0x301d,
149283179d39SNavdeep Parhar 0xd828, 0x28f2,
149383179d39SNavdeep Parhar 0xd829, 0x3022,
149483179d39SNavdeep Parhar 0xd82a, 0x1002,
149583179d39SNavdeep Parhar 0xd82b, 0x5553,
149683179d39SNavdeep Parhar 0xd82c, 0x0307,
149783179d39SNavdeep Parhar 0xd82d, 0x2572,
149883179d39SNavdeep Parhar 0xd82e, 0x3022,
149983179d39SNavdeep Parhar 0xd82f, 0x1002,
150083179d39SNavdeep Parhar 0xd830, 0x21a2,
1501c01f2b83SNavdeep Parhar 0xd831, 0x3012,
1502c01f2b83SNavdeep Parhar 0xd832, 0x1002,
150383179d39SNavdeep Parhar 0xd833, 0x4016,
150483179d39SNavdeep Parhar 0xd834, 0x5e63,
150583179d39SNavdeep Parhar 0xd835, 0x0344,
150683179d39SNavdeep Parhar 0xd836, 0x21a2,
150783179d39SNavdeep Parhar 0xd837, 0x3012,
150883179d39SNavdeep Parhar 0xd838, 0x1002,
150983179d39SNavdeep Parhar 0xd839, 0x400e,
151083179d39SNavdeep Parhar 0xd83a, 0x2572,
1511c01f2b83SNavdeep Parhar 0xd83b, 0x3022,
1512c01f2b83SNavdeep Parhar 0xd83c, 0x1002,
151383179d39SNavdeep Parhar 0xd83d, 0x2b22,
151483179d39SNavdeep Parhar 0xd83e, 0x3012,
1515c01f2b83SNavdeep Parhar 0xd83f, 0x1002,
151683179d39SNavdeep Parhar 0xd840, 0x2842,
151783179d39SNavdeep Parhar 0xd841, 0x3022,
151883179d39SNavdeep Parhar 0xd842, 0x1002,
151983179d39SNavdeep Parhar 0xd843, 0x26e2,
152083179d39SNavdeep Parhar 0xd844, 0x3022,
152183179d39SNavdeep Parhar 0xd845, 0x1002,
152283179d39SNavdeep Parhar 0xd846, 0x2fa4,
152383179d39SNavdeep Parhar 0xd847, 0x3dc4,
152483179d39SNavdeep Parhar 0xd848, 0x6624,
152583179d39SNavdeep Parhar 0xd849, 0x2e8b,
152683179d39SNavdeep Parhar 0xd84a, 0x303b,
152783179d39SNavdeep Parhar 0xd84b, 0x56b3,
152883179d39SNavdeep Parhar 0xd84c, 0x03c6,
152983179d39SNavdeep Parhar 0xd84d, 0x866b,
153083179d39SNavdeep Parhar 0xd84e, 0x400c,
153183179d39SNavdeep Parhar 0xd84f, 0x2782,
153283179d39SNavdeep Parhar 0xd850, 0x3012,
153383179d39SNavdeep Parhar 0xd851, 0x1002,
153483179d39SNavdeep Parhar 0xd852, 0x2c4b,
153583179d39SNavdeep Parhar 0xd853, 0x309b,
153683179d39SNavdeep Parhar 0xd854, 0x56b3,
153783179d39SNavdeep Parhar 0xd855, 0x03c3,
153883179d39SNavdeep Parhar 0xd856, 0x866b,
153983179d39SNavdeep Parhar 0xd857, 0x400c,
154083179d39SNavdeep Parhar 0xd858, 0x22a2,
154183179d39SNavdeep Parhar 0xd859, 0x3022,
154283179d39SNavdeep Parhar 0xd85a, 0x1002,
154383179d39SNavdeep Parhar 0xd85b, 0x2842,
154483179d39SNavdeep Parhar 0xd85c, 0x3022,
154583179d39SNavdeep Parhar 0xd85d, 0x1002,
154683179d39SNavdeep Parhar 0xd85e, 0x26e2,
154783179d39SNavdeep Parhar 0xd85f, 0x3022,
154883179d39SNavdeep Parhar 0xd860, 0x1002,
154983179d39SNavdeep Parhar 0xd861, 0x2fb4,
155083179d39SNavdeep Parhar 0xd862, 0x3dc4,
155183179d39SNavdeep Parhar 0xd863, 0x6624,
155283179d39SNavdeep Parhar 0xd864, 0x56b3,
155383179d39SNavdeep Parhar 0xd865, 0x03c3,
155483179d39SNavdeep Parhar 0xd866, 0x866b,
155583179d39SNavdeep Parhar 0xd867, 0x401c,
155683179d39SNavdeep Parhar 0xd868, 0x2c45,
155783179d39SNavdeep Parhar 0xd869, 0x3095,
155883179d39SNavdeep Parhar 0xd86a, 0x5b53,
155983179d39SNavdeep Parhar 0xd86b, 0x23d2,
1560c01f2b83SNavdeep Parhar 0xd86c, 0x3012,
156183179d39SNavdeep Parhar 0xd86d, 0x13c2,
156283179d39SNavdeep Parhar 0xd86e, 0x5cc3,
156383179d39SNavdeep Parhar 0xd86f, 0x2782,
156483179d39SNavdeep Parhar 0xd870, 0x3012,
156583179d39SNavdeep Parhar 0xd871, 0x1312,
156683179d39SNavdeep Parhar 0xd872, 0x2b22,
156783179d39SNavdeep Parhar 0xd873, 0x3012,
156883179d39SNavdeep Parhar 0xd874, 0x1002,
156983179d39SNavdeep Parhar 0xd875, 0x2842,
157083179d39SNavdeep Parhar 0xd876, 0x3022,
157183179d39SNavdeep Parhar 0xd877, 0x1002,
157283179d39SNavdeep Parhar 0xd878, 0x2622,
157383179d39SNavdeep Parhar 0xd879, 0x3022,
157483179d39SNavdeep Parhar 0xd87a, 0x1002,
157583179d39SNavdeep Parhar 0xd87b, 0x21a2,
157683179d39SNavdeep Parhar 0xd87c, 0x3012,
157783179d39SNavdeep Parhar 0xd87d, 0x1002,
157883179d39SNavdeep Parhar 0xd87e, 0x628f,
157983179d39SNavdeep Parhar 0xd87f, 0x2985,
158083179d39SNavdeep Parhar 0xd880, 0x33a5,
158183179d39SNavdeep Parhar 0xd881, 0x26e2,
158283179d39SNavdeep Parhar 0xd882, 0x3022,
158383179d39SNavdeep Parhar 0xd883, 0x1002,
158483179d39SNavdeep Parhar 0xd884, 0x5653,
158583179d39SNavdeep Parhar 0xd885, 0x03d2,
158683179d39SNavdeep Parhar 0xd886, 0x401e,
158783179d39SNavdeep Parhar 0xd887, 0x6f72,
158883179d39SNavdeep Parhar 0xd888, 0x1002,
158983179d39SNavdeep Parhar 0xd889, 0x628f,
159083179d39SNavdeep Parhar 0xd88a, 0x2304,
159183179d39SNavdeep Parhar 0xd88b, 0x3c84,
159283179d39SNavdeep Parhar 0xd88c, 0x6436,
159383179d39SNavdeep Parhar 0xd88d, 0xdff4,
159483179d39SNavdeep Parhar 0xd88e, 0x6436,
159583179d39SNavdeep Parhar 0xd88f, 0x2ff5,
159683179d39SNavdeep Parhar 0xd890, 0x3005,
159783179d39SNavdeep Parhar 0xd891, 0x8656,
159883179d39SNavdeep Parhar 0xd892, 0xdfba,
159983179d39SNavdeep Parhar 0xd893, 0x56a3,
160083179d39SNavdeep Parhar 0xd894, 0xd05a,
160183179d39SNavdeep Parhar 0xd895, 0x29e2,
160283179d39SNavdeep Parhar 0xd896, 0x3012,
160383179d39SNavdeep Parhar 0xd897, 0x1392,
160483179d39SNavdeep Parhar 0xd898, 0xd05a,
160583179d39SNavdeep Parhar 0xd899, 0x56a3,
160683179d39SNavdeep Parhar 0xd89a, 0xdfba,
160783179d39SNavdeep Parhar 0xd89b, 0x0383,
160883179d39SNavdeep Parhar 0xd89c, 0x6f72,
160983179d39SNavdeep Parhar 0xd89d, 0x1002,
161083179d39SNavdeep Parhar 0xd89e, 0x2a64,
161183179d39SNavdeep Parhar 0xd89f, 0x3014,
161283179d39SNavdeep Parhar 0xd8a0, 0x2005,
161383179d39SNavdeep Parhar 0xd8a1, 0x3d75,
161483179d39SNavdeep Parhar 0xd8a2, 0xc451,
161583179d39SNavdeep Parhar 0xd8a3, 0x29a2,
161683179d39SNavdeep Parhar 0xd8a4, 0x3022,
161783179d39SNavdeep Parhar 0xd8a5, 0x1002,
161883179d39SNavdeep Parhar 0xd8a6, 0x178c,
161983179d39SNavdeep Parhar 0xd8a7, 0x1898,
162083179d39SNavdeep Parhar 0xd8a8, 0x19a4,
162183179d39SNavdeep Parhar 0xd8a9, 0x1ab0,
162283179d39SNavdeep Parhar 0xd8aa, 0x1bbc,
162383179d39SNavdeep Parhar 0xd8ab, 0x1cc8,
162483179d39SNavdeep Parhar 0xd8ac, 0x1dd3,
162583179d39SNavdeep Parhar 0xd8ad, 0x1ede,
162683179d39SNavdeep Parhar 0xd8ae, 0x1fe9,
162783179d39SNavdeep Parhar 0xd8af, 0x20f4,
162883179d39SNavdeep Parhar 0xd8b0, 0x21ff,
162983179d39SNavdeep Parhar 0xd8b1, 0x0000,
163083179d39SNavdeep Parhar 0xd8b2, 0x2741,
163183179d39SNavdeep Parhar 0xd8b3, 0x3021,
163283179d39SNavdeep Parhar 0xd8b4, 0x1001,
163383179d39SNavdeep Parhar 0xd8b5, 0xc620,
163483179d39SNavdeep Parhar 0xd8b6, 0x0000,
163583179d39SNavdeep Parhar 0xd8b7, 0xc621,
163683179d39SNavdeep Parhar 0xd8b8, 0x0000,
163783179d39SNavdeep Parhar 0xd8b9, 0xc622,
163883179d39SNavdeep Parhar 0xd8ba, 0x00e2,
163983179d39SNavdeep Parhar 0xd8bb, 0xc623,
164083179d39SNavdeep Parhar 0xd8bc, 0x007f,
164183179d39SNavdeep Parhar 0xd8bd, 0xc624,
164283179d39SNavdeep Parhar 0xd8be, 0x00ce,
164383179d39SNavdeep Parhar 0xd8bf, 0xc625,
164483179d39SNavdeep Parhar 0xd8c0, 0x0000,
164583179d39SNavdeep Parhar 0xd8c1, 0xc627,
164683179d39SNavdeep Parhar 0xd8c2, 0x0000,
164783179d39SNavdeep Parhar 0xd8c3, 0xc628,
164883179d39SNavdeep Parhar 0xd8c4, 0x0000,
164983179d39SNavdeep Parhar 0xd8c5, 0xc90a,
165083179d39SNavdeep Parhar 0xd8c6, 0x3a7c,
165183179d39SNavdeep Parhar 0xd8c7, 0xc62c,
165283179d39SNavdeep Parhar 0xd8c8, 0x0000,
1653c01f2b83SNavdeep Parhar 0xd8c9, 0x0000,
165483179d39SNavdeep Parhar 0xd8ca, 0x2741,
165583179d39SNavdeep Parhar 0xd8cb, 0x3021,
165683179d39SNavdeep Parhar 0xd8cc, 0x1001,
165783179d39SNavdeep Parhar 0xd8cd, 0xc502,
165883179d39SNavdeep Parhar 0xd8ce, 0x53ac,
165983179d39SNavdeep Parhar 0xd8cf, 0xc503,
166083179d39SNavdeep Parhar 0xd8d0, 0x2cd3,
166183179d39SNavdeep Parhar 0xd8d1, 0xc600,
166283179d39SNavdeep Parhar 0xd8d2, 0x2a6e,
166383179d39SNavdeep Parhar 0xd8d3, 0xc601,
166483179d39SNavdeep Parhar 0xd8d4, 0x2a2c,
166583179d39SNavdeep Parhar 0xd8d5, 0xc605,
166683179d39SNavdeep Parhar 0xd8d6, 0x5557,
166783179d39SNavdeep Parhar 0xd8d7, 0xc60c,
166883179d39SNavdeep Parhar 0xd8d8, 0x5400,
166983179d39SNavdeep Parhar 0xd8d9, 0xc710,
167083179d39SNavdeep Parhar 0xd8da, 0x0700,
167183179d39SNavdeep Parhar 0xd8db, 0xc711,
167283179d39SNavdeep Parhar 0xd8dc, 0x0f06,
167383179d39SNavdeep Parhar 0xd8dd, 0xc718,
167483179d39SNavdeep Parhar 0xd8de, 0x700,
167583179d39SNavdeep Parhar 0xd8df, 0xc719,
167683179d39SNavdeep Parhar 0xd8e0, 0x0f06,
167783179d39SNavdeep Parhar 0xd8e1, 0xc720,
167883179d39SNavdeep Parhar 0xd8e2, 0x4700,
167983179d39SNavdeep Parhar 0xd8e3, 0xc721,
168083179d39SNavdeep Parhar 0xd8e4, 0x0f06,
168183179d39SNavdeep Parhar 0xd8e5, 0xc728,
168283179d39SNavdeep Parhar 0xd8e6, 0x0700,
168383179d39SNavdeep Parhar 0xd8e7, 0xc729,
168483179d39SNavdeep Parhar 0xd8e8, 0x1207,
168583179d39SNavdeep Parhar 0xd8e9, 0xc801,
168683179d39SNavdeep Parhar 0xd8ea, 0x7f50,
168783179d39SNavdeep Parhar 0xd8eb, 0xc802,
168883179d39SNavdeep Parhar 0xd8ec, 0x7760,
168983179d39SNavdeep Parhar 0xd8ed, 0xc803,
169083179d39SNavdeep Parhar 0xd8ee, 0x7fce,
169183179d39SNavdeep Parhar 0xd8ef, 0xc804,
169283179d39SNavdeep Parhar 0xd8f0, 0x520e,
169383179d39SNavdeep Parhar 0xd8f1, 0xc805,
169483179d39SNavdeep Parhar 0xd8f2, 0x5c11,
169583179d39SNavdeep Parhar 0xd8f3, 0xc806,
169683179d39SNavdeep Parhar 0xd8f4, 0x3c51,
169783179d39SNavdeep Parhar 0xd8f5, 0xc807,
169883179d39SNavdeep Parhar 0xd8f6, 0x4061,
169983179d39SNavdeep Parhar 0xd8f7, 0xc808,
170083179d39SNavdeep Parhar 0xd8f8, 0x49c1,
170183179d39SNavdeep Parhar 0xd8f9, 0xc809,
170283179d39SNavdeep Parhar 0xd8fa, 0x3840,
170383179d39SNavdeep Parhar 0xd8fb, 0xc80a,
170483179d39SNavdeep Parhar 0xd8fc, 0x0000,
170583179d39SNavdeep Parhar 0xd8fd, 0xc821,
170683179d39SNavdeep Parhar 0xd8fe, 0x0002,
170783179d39SNavdeep Parhar 0xd8ff, 0xc822,
170883179d39SNavdeep Parhar 0xd900, 0x0046,
170983179d39SNavdeep Parhar 0xd901, 0xc844,
171083179d39SNavdeep Parhar 0xd902, 0x182f,
171183179d39SNavdeep Parhar 0xd903, 0xc849,
171283179d39SNavdeep Parhar 0xd904, 0x0400,
171383179d39SNavdeep Parhar 0xd905, 0xc84a,
171483179d39SNavdeep Parhar 0xd906, 0x0002,
171583179d39SNavdeep Parhar 0xd907, 0xc013,
171683179d39SNavdeep Parhar 0xd908, 0xf341,
171783179d39SNavdeep Parhar 0xd909, 0xc084,
171883179d39SNavdeep Parhar 0xd90a, 0x0030,
171983179d39SNavdeep Parhar 0xd90b, 0xc904,
172083179d39SNavdeep Parhar 0xd90c, 0x1401,
172183179d39SNavdeep Parhar 0xd90d, 0xcb0c,
172283179d39SNavdeep Parhar 0xd90e, 0x0004,
172383179d39SNavdeep Parhar 0xd90f, 0xcb0e,
172483179d39SNavdeep Parhar 0xd910, 0xa00a,
172583179d39SNavdeep Parhar 0xd911, 0xcb0f,
172683179d39SNavdeep Parhar 0xd912, 0xc0c0,
172783179d39SNavdeep Parhar 0xd913, 0xcb10,
172883179d39SNavdeep Parhar 0xd914, 0xc0c0,
172983179d39SNavdeep Parhar 0xd915, 0xcb11,
173083179d39SNavdeep Parhar 0xd916, 0x00a0,
173183179d39SNavdeep Parhar 0xd917, 0xcb12,
173283179d39SNavdeep Parhar 0xd918, 0x0007,
173383179d39SNavdeep Parhar 0xd919, 0xc241,
173483179d39SNavdeep Parhar 0xd91a, 0xa000,
173583179d39SNavdeep Parhar 0xd91b, 0xc243,
173683179d39SNavdeep Parhar 0xd91c, 0x7fe0,
173783179d39SNavdeep Parhar 0xd91d, 0xc604,
173883179d39SNavdeep Parhar 0xd91e, 0x000e,
173983179d39SNavdeep Parhar 0xd91f, 0xc609,
174083179d39SNavdeep Parhar 0xd920, 0x00f5,
174183179d39SNavdeep Parhar 0xd921, 0xc611,
174283179d39SNavdeep Parhar 0xd922, 0x000e,
174383179d39SNavdeep Parhar 0xd923, 0xc660,
174483179d39SNavdeep Parhar 0xd924, 0x9600,
174583179d39SNavdeep Parhar 0xd925, 0xc687,
174683179d39SNavdeep Parhar 0xd926, 0x0004,
174783179d39SNavdeep Parhar 0xd927, 0xc60a,
174883179d39SNavdeep Parhar 0xd928, 0x04f5,
174983179d39SNavdeep Parhar 0xd929, 0x0000,
175083179d39SNavdeep Parhar 0xd92a, 0x2741,
175183179d39SNavdeep Parhar 0xd92b, 0x3021,
175283179d39SNavdeep Parhar 0xd92c, 0x1001,
175383179d39SNavdeep Parhar 0xd92d, 0xc620,
175483179d39SNavdeep Parhar 0xd92e, 0x14e5,
175583179d39SNavdeep Parhar 0xd92f, 0xc621,
175683179d39SNavdeep Parhar 0xd930, 0xc53d,
175783179d39SNavdeep Parhar 0xd931, 0xc622,
175883179d39SNavdeep Parhar 0xd932, 0x3cbe,
175983179d39SNavdeep Parhar 0xd933, 0xc623,
176083179d39SNavdeep Parhar 0xd934, 0x4452,
176183179d39SNavdeep Parhar 0xd935, 0xc624,
176283179d39SNavdeep Parhar 0xd936, 0xc5c5,
176383179d39SNavdeep Parhar 0xd937, 0xc625,
176483179d39SNavdeep Parhar 0xd938, 0xe01e,
176583179d39SNavdeep Parhar 0xd939, 0xc627,
176683179d39SNavdeep Parhar 0xd93a, 0x0000,
176783179d39SNavdeep Parhar 0xd93b, 0xc628,
1768c01f2b83SNavdeep Parhar 0xd93c, 0x0000,
176983179d39SNavdeep Parhar 0xd93d, 0xc62c,
177083179d39SNavdeep Parhar 0xd93e, 0x0000,
177183179d39SNavdeep Parhar 0xd93f, 0xc90a,
177283179d39SNavdeep Parhar 0xd940, 0x3a7c,
177383179d39SNavdeep Parhar 0xd941, 0x0000,
177483179d39SNavdeep Parhar 0xd942, 0x2b84,
177583179d39SNavdeep Parhar 0xd943, 0x3c74,
177683179d39SNavdeep Parhar 0xd944, 0x6435,
177783179d39SNavdeep Parhar 0xd945, 0xdff4,
177883179d39SNavdeep Parhar 0xd946, 0x6435,
177983179d39SNavdeep Parhar 0xd947, 0x2806,
178083179d39SNavdeep Parhar 0xd948, 0x3006,
178183179d39SNavdeep Parhar 0xd949, 0x8565,
178283179d39SNavdeep Parhar 0xd94a, 0x2b24,
178383179d39SNavdeep Parhar 0xd94b, 0x3c24,
178483179d39SNavdeep Parhar 0xd94c, 0x6436,
178583179d39SNavdeep Parhar 0xd94d, 0x1002,
178683179d39SNavdeep Parhar 0xd94e, 0x2b24,
178783179d39SNavdeep Parhar 0xd94f, 0x3c24,
178883179d39SNavdeep Parhar 0xd950, 0x6436,
178983179d39SNavdeep Parhar 0xd951, 0x4045,
179083179d39SNavdeep Parhar 0xd952, 0x8656,
179183179d39SNavdeep Parhar 0xd953, 0x5663,
179283179d39SNavdeep Parhar 0xd954, 0x0302,
179383179d39SNavdeep Parhar 0xd955, 0x401e,
179483179d39SNavdeep Parhar 0xd956, 0x1002,
179583179d39SNavdeep Parhar 0xd957, 0x2807,
179683179d39SNavdeep Parhar 0xd958, 0x31a7,
179783179d39SNavdeep Parhar 0xd959, 0x20c4,
179883179d39SNavdeep Parhar 0xd95a, 0x3c24,
179983179d39SNavdeep Parhar 0xd95b, 0x6724,
180083179d39SNavdeep Parhar 0xd95c, 0x2ff7,
180183179d39SNavdeep Parhar 0xd95d, 0x30f7,
180283179d39SNavdeep Parhar 0xd95e, 0x20c4,
180383179d39SNavdeep Parhar 0xd95f, 0x3c04,
180483179d39SNavdeep Parhar 0xd960, 0x6724,
180583179d39SNavdeep Parhar 0xd961, 0x1002,
180683179d39SNavdeep Parhar 0xd962, 0x2807,
180783179d39SNavdeep Parhar 0xd963, 0x3187,
180883179d39SNavdeep Parhar 0xd964, 0x20c4,
180983179d39SNavdeep Parhar 0xd965, 0x3c24,
181083179d39SNavdeep Parhar 0xd966, 0x6724,
181183179d39SNavdeep Parhar 0xd967, 0x2fe4,
181283179d39SNavdeep Parhar 0xd968, 0x3dc4,
181383179d39SNavdeep Parhar 0xd969, 0x6437,
181483179d39SNavdeep Parhar 0xd96a, 0x20c4,
181583179d39SNavdeep Parhar 0xd96b, 0x3c04,
181683179d39SNavdeep Parhar 0xd96c, 0x6724,
1817c01f2b83SNavdeep Parhar 0xd96d, 0x1002,
181883179d39SNavdeep Parhar 0xd96e, 0x24f4,
181983179d39SNavdeep Parhar 0xd96f, 0x3c64,
182083179d39SNavdeep Parhar 0xd970, 0x6436,
182183179d39SNavdeep Parhar 0xd971, 0xdff4,
182283179d39SNavdeep Parhar 0xd972, 0x6436,
1823c01f2b83SNavdeep Parhar 0xd973, 0x1002,
182483179d39SNavdeep Parhar 0xd974, 0x2006,
182583179d39SNavdeep Parhar 0xd975, 0x3d76,
182683179d39SNavdeep Parhar 0xd976, 0xc161,
182783179d39SNavdeep Parhar 0xd977, 0x6134,
182883179d39SNavdeep Parhar 0xd978, 0x6135,
182983179d39SNavdeep Parhar 0xd979, 0x5443,
183083179d39SNavdeep Parhar 0xd97a, 0x0303,
183183179d39SNavdeep Parhar 0xd97b, 0x6524,
183283179d39SNavdeep Parhar 0xd97c, 0x00fb,
183383179d39SNavdeep Parhar 0xd97d, 0x1002,
183483179d39SNavdeep Parhar 0xd97e, 0x20d4,
183583179d39SNavdeep Parhar 0xd97f, 0x3c24,
183683179d39SNavdeep Parhar 0xd980, 0x2025,
183783179d39SNavdeep Parhar 0xd981, 0x3005,
183883179d39SNavdeep Parhar 0xd982, 0x6524,
183983179d39SNavdeep Parhar 0xd983, 0x1002,
184083179d39SNavdeep Parhar 0xd984, 0xd019,
184183179d39SNavdeep Parhar 0xd985, 0x2104,
184283179d39SNavdeep Parhar 0xd986, 0x3c24,
184383179d39SNavdeep Parhar 0xd987, 0x2105,
184483179d39SNavdeep Parhar 0xd988, 0x3805,
184583179d39SNavdeep Parhar 0xd989, 0x6524,
184683179d39SNavdeep Parhar 0xd98a, 0xdff4,
184783179d39SNavdeep Parhar 0xd98b, 0x4005,
184883179d39SNavdeep Parhar 0xd98c, 0x6524,
184983179d39SNavdeep Parhar 0xd98d, 0x2e8d,
185083179d39SNavdeep Parhar 0xd98e, 0x303d,
185183179d39SNavdeep Parhar 0xd98f, 0x2408,
185283179d39SNavdeep Parhar 0xd990, 0x35d8,
185383179d39SNavdeep Parhar 0xd991, 0x5dd3,
185483179d39SNavdeep Parhar 0xd992, 0x0307,
185583179d39SNavdeep Parhar 0xd993, 0x8887,
185683179d39SNavdeep Parhar 0xd994, 0x63a7,
185783179d39SNavdeep Parhar 0xd995, 0x8887,
185883179d39SNavdeep Parhar 0xd996, 0x63a7,
185983179d39SNavdeep Parhar 0xd997, 0xdffd,
186083179d39SNavdeep Parhar 0xd998, 0x00f9,
186183179d39SNavdeep Parhar 0xd999, 0x1002,
186283179d39SNavdeep Parhar 0xd99a, 0x866a,
186383179d39SNavdeep Parhar 0xd99b, 0x6138,
186483179d39SNavdeep Parhar 0xd99c, 0x5883,
186583179d39SNavdeep Parhar 0xd99d, 0x2aa2,
186683179d39SNavdeep Parhar 0xd99e, 0x3022,
186783179d39SNavdeep Parhar 0xd99f, 0x1302,
186883179d39SNavdeep Parhar 0xd9a0, 0x2ff7,
186983179d39SNavdeep Parhar 0xd9a1, 0x3007,
187083179d39SNavdeep Parhar 0xd9a2, 0x8785,
187183179d39SNavdeep Parhar 0xd9a3, 0xb887,
187283179d39SNavdeep Parhar 0xd9a4, 0x8786,
187383179d39SNavdeep Parhar 0xd9a5, 0xb8c6,
187483179d39SNavdeep Parhar 0xd9a6, 0x5a53,
187583179d39SNavdeep Parhar 0xd9a7, 0x29b2,
187683179d39SNavdeep Parhar 0xd9a8, 0x3022,
187783179d39SNavdeep Parhar 0xd9a9, 0x13c2,
187883179d39SNavdeep Parhar 0xd9aa, 0x2474,
187983179d39SNavdeep Parhar 0xd9ab, 0x3c84,
188083179d39SNavdeep Parhar 0xd9ac, 0x64d7,
188183179d39SNavdeep Parhar 0xd9ad, 0x64d7,
188283179d39SNavdeep Parhar 0xd9ae, 0x2ff5,
188383179d39SNavdeep Parhar 0xd9af, 0x3c05,
188483179d39SNavdeep Parhar 0xd9b0, 0x8757,
188583179d39SNavdeep Parhar 0xd9b1, 0xb886,
188683179d39SNavdeep Parhar 0xd9b2, 0x9767,
188783179d39SNavdeep Parhar 0xd9b3, 0x67c4,
188883179d39SNavdeep Parhar 0xd9b4, 0x6f72,
188983179d39SNavdeep Parhar 0xd9b5, 0x1002,
189083179d39SNavdeep Parhar 0xd9b6, 0x0000,
1891c01f2b83SNavdeep Parhar };
1892c01f2b83SNavdeep Parhar int i, err;
1893c01f2b83SNavdeep Parhar
1894c01f2b83SNavdeep Parhar /* set uC clock and activate it */
1895c01f2b83SNavdeep Parhar err = set_phy_regs(phy, uCclock40MHz);
1896c01f2b83SNavdeep Parhar msleep(500);
1897c01f2b83SNavdeep Parhar if (err)
1898c01f2b83SNavdeep Parhar return err;
1899c01f2b83SNavdeep Parhar err = set_phy_regs(phy, uCclockActivate);
1900c01f2b83SNavdeep Parhar msleep(500);
1901c01f2b83SNavdeep Parhar if (err)
1902c01f2b83SNavdeep Parhar return err;
1903c01f2b83SNavdeep Parhar
1904c01f2b83SNavdeep Parhar for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2)
1905c01f2b83SNavdeep Parhar err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i],
1906c01f2b83SNavdeep Parhar twinax_edc[i + 1]);
1907c01f2b83SNavdeep Parhar /* activate uC */
1908c01f2b83SNavdeep Parhar err = set_phy_regs(phy, uCactivate);
1909c01f2b83SNavdeep Parhar if (!err)
1910c01f2b83SNavdeep Parhar phy->priv = edc_twinax;
1911c01f2b83SNavdeep Parhar return err;
1912c01f2b83SNavdeep Parhar }
1913c01f2b83SNavdeep Parhar
1914c01f2b83SNavdeep Parhar /*
1915c01f2b83SNavdeep Parhar * Return Module Type.
1916c01f2b83SNavdeep Parhar */
ael2020_get_module_type(struct cphy * phy,int delay_ms)1917c01f2b83SNavdeep Parhar static int ael2020_get_module_type(struct cphy *phy, int delay_ms)
1918c01f2b83SNavdeep Parhar {
1919c01f2b83SNavdeep Parhar int v;
1920c01f2b83SNavdeep Parhar unsigned int stat;
1921c01f2b83SNavdeep Parhar
1922c01f2b83SNavdeep Parhar v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2020_GPIO_STAT, &stat);
1923c01f2b83SNavdeep Parhar if (v)
1924c01f2b83SNavdeep Parhar return v;
1925c01f2b83SNavdeep Parhar
1926c01f2b83SNavdeep Parhar if (stat & (0x1 << (AEL2020_GPIO_MODDET*4))) {
1927c01f2b83SNavdeep Parhar /* module absent */
1928c01f2b83SNavdeep Parhar return phy_modtype_none;
1929c01f2b83SNavdeep Parhar }
1930c01f2b83SNavdeep Parhar
1931c01f2b83SNavdeep Parhar return ael2xxx_get_module_type(phy, delay_ms);
1932c01f2b83SNavdeep Parhar }
1933c01f2b83SNavdeep Parhar
1934c01f2b83SNavdeep Parhar /*
1935c01f2b83SNavdeep Parhar * Enable PHY interrupts. We enable "Module Detection" interrupts (on any
1936c01f2b83SNavdeep Parhar * state transition) and then generic Link Alarm Status Interrupt (LASI).
1937c01f2b83SNavdeep Parhar */
ael2020_intr_enable(struct cphy * phy)1938c01f2b83SNavdeep Parhar static int ael2020_intr_enable(struct cphy *phy)
1939c01f2b83SNavdeep Parhar {
1940c01f2b83SNavdeep Parhar struct reg_val regs[] = {
1941c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, AEL2020_GPIO_CFG+AEL2020_GPIO_LSTAT,
1942c01f2b83SNavdeep Parhar 0xffff, 0x4 },
1943c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, AEL2020_GPIO_CTRL,
1944c01f2b83SNavdeep Parhar 0xffff, 0x8 << (AEL2020_GPIO_LSTAT*4) },
1945c01f2b83SNavdeep Parhar
1946c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, AEL2020_GPIO_CTRL,
1947c01f2b83SNavdeep Parhar 0xffff, 0x2 << (AEL2020_GPIO_MODDET*4) },
1948c01f2b83SNavdeep Parhar
1949c01f2b83SNavdeep Parhar /* end */
1950c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1951c01f2b83SNavdeep Parhar };
1952c01f2b83SNavdeep Parhar int err;
1953c01f2b83SNavdeep Parhar
1954c01f2b83SNavdeep Parhar err = set_phy_regs(phy, regs);
1955c01f2b83SNavdeep Parhar if (err)
1956c01f2b83SNavdeep Parhar return err;
1957c01f2b83SNavdeep Parhar
1958c01f2b83SNavdeep Parhar /* enable standard Link Alarm Status Interrupts */
1959c01f2b83SNavdeep Parhar err = t3_phy_lasi_intr_enable(phy);
1960c01f2b83SNavdeep Parhar if (err)
1961c01f2b83SNavdeep Parhar return err;
1962c01f2b83SNavdeep Parhar
1963c01f2b83SNavdeep Parhar return 0;
1964c01f2b83SNavdeep Parhar }
1965c01f2b83SNavdeep Parhar
1966c01f2b83SNavdeep Parhar /*
1967c01f2b83SNavdeep Parhar * Disable PHY interrupts. The mirror of the above ...
1968c01f2b83SNavdeep Parhar */
ael2020_intr_disable(struct cphy * phy)1969c01f2b83SNavdeep Parhar static int ael2020_intr_disable(struct cphy *phy)
1970c01f2b83SNavdeep Parhar {
1971c01f2b83SNavdeep Parhar struct reg_val regs[] = {
1972c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, AEL2020_GPIO_CTRL,
1973c01f2b83SNavdeep Parhar 0xffff, 0xb << (AEL2020_GPIO_LSTAT*4) },
1974c01f2b83SNavdeep Parhar
1975c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, AEL2020_GPIO_CTRL,
1976c01f2b83SNavdeep Parhar 0xffff, 0x1 << (AEL2020_GPIO_MODDET*4) },
1977c01f2b83SNavdeep Parhar
1978c01f2b83SNavdeep Parhar /* end */
1979c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
1980c01f2b83SNavdeep Parhar };
1981c01f2b83SNavdeep Parhar int err;
1982c01f2b83SNavdeep Parhar
1983c01f2b83SNavdeep Parhar err = set_phy_regs(phy, regs);
1984c01f2b83SNavdeep Parhar if (err)
1985c01f2b83SNavdeep Parhar return err;
1986c01f2b83SNavdeep Parhar
1987c01f2b83SNavdeep Parhar /* disable standard Link Alarm Status Interrupts */
1988c01f2b83SNavdeep Parhar return t3_phy_lasi_intr_disable(phy);
1989c01f2b83SNavdeep Parhar }
1990c01f2b83SNavdeep Parhar
1991c01f2b83SNavdeep Parhar /*
1992c01f2b83SNavdeep Parhar * Clear PHY interrupt state.
1993c01f2b83SNavdeep Parhar */
ael2020_intr_clear(struct cphy * phy)1994c01f2b83SNavdeep Parhar static int ael2020_intr_clear(struct cphy *phy)
1995c01f2b83SNavdeep Parhar {
1996c01f2b83SNavdeep Parhar unsigned int stat;
1997c01f2b83SNavdeep Parhar int err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2020_GPIO_INTR, &stat);
1998c01f2b83SNavdeep Parhar return err ? err : t3_phy_lasi_intr_clear(phy);
1999c01f2b83SNavdeep Parhar }
2000c01f2b83SNavdeep Parhar
2001c01f2b83SNavdeep Parhar /*
2002c01f2b83SNavdeep Parhar * Common register settings for the AEL2020 when it comes out of reset.
2003c01f2b83SNavdeep Parhar */
2004c01f2b83SNavdeep Parhar static struct reg_val ael2020_reset_regs[] = {
2005c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x3101 },
2006c01f2b83SNavdeep Parhar
2007c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xcd40, 0xffff, 0x0001 },
2008c01f2b83SNavdeep Parhar
200983179d39SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0x0100 },
201083179d39SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xca22, 0xffff, 0x0100 },
201183179d39SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xca42, 0xffff, 0x0100 },
2012c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xff02, 0xffff, 0x0023 },
2013c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xff03, 0xffff, 0x0000 },
2014c01f2b83SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xff04, 0xffff, 0x0000 },
2015c01f2b83SNavdeep Parhar
201683179d39SNavdeep Parhar { MDIO_DEV_PMA_PMD, 0xc20d, 0xffff, 0x0002 },
2017c01f2b83SNavdeep Parhar /* end */
2018c01f2b83SNavdeep Parhar { 0, 0, 0, 0 }
2019c01f2b83SNavdeep Parhar };
2020c01f2b83SNavdeep Parhar
2021c01f2b83SNavdeep Parhar /*
2022c01f2b83SNavdeep Parhar * Reset the PHY and put it into a canonical operating state.
2023c01f2b83SNavdeep Parhar */
ael2020_reset(struct cphy * phy,int wait)2024c01f2b83SNavdeep Parhar static int ael2020_reset(struct cphy *phy, int wait)
2025c01f2b83SNavdeep Parhar {
2026c01f2b83SNavdeep Parhar int err;
2027c01f2b83SNavdeep Parhar unsigned int lasi_ctrl;
2028c01f2b83SNavdeep Parhar
2029c01f2b83SNavdeep Parhar /* grab current interrupt state */
2030c01f2b83SNavdeep Parhar err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl);
2031c01f2b83SNavdeep Parhar if (err)
2032c01f2b83SNavdeep Parhar return err;
2033c01f2b83SNavdeep Parhar
2034c01f2b83SNavdeep Parhar err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 125);
2035c01f2b83SNavdeep Parhar if (err)
2036c01f2b83SNavdeep Parhar return err;
2037c01f2b83SNavdeep Parhar msleep(100);
2038c01f2b83SNavdeep Parhar
2039c01f2b83SNavdeep Parhar /* basic initialization for all module types */
2040c01f2b83SNavdeep Parhar phy->priv = edc_none;
2041c01f2b83SNavdeep Parhar err = set_phy_regs(phy, ael2020_reset_regs);
2042c01f2b83SNavdeep Parhar if (err)
2043c01f2b83SNavdeep Parhar return err;
204483179d39SNavdeep Parhar msleep(100);
2045c01f2b83SNavdeep Parhar
2046c01f2b83SNavdeep Parhar /* determine module type and perform appropriate initialization */
2047c01f2b83SNavdeep Parhar err = ael2020_get_module_type(phy, 0);
2048c01f2b83SNavdeep Parhar if (err < 0)
2049c01f2b83SNavdeep Parhar return err;
2050c01f2b83SNavdeep Parhar phy->modtype = (u8)err;
20511fa10c92SNavdeep Parhar if (err == phy_modtype_none)
2052c01f2b83SNavdeep Parhar err = 0;
2053c01f2b83SNavdeep Parhar else if (err == phy_modtype_twinax || err == phy_modtype_twinax_long)
2054c01f2b83SNavdeep Parhar err = ael2020_setup_twinax_edc(phy, err);
2055c01f2b83SNavdeep Parhar else
2056c01f2b83SNavdeep Parhar err = ael2020_setup_sr_edc(phy);
2057c01f2b83SNavdeep Parhar if (err)
2058c01f2b83SNavdeep Parhar return err;
2059c01f2b83SNavdeep Parhar
2060c01f2b83SNavdeep Parhar /* reset wipes out interrupts, reenable them if they were on */
2061c01f2b83SNavdeep Parhar if (lasi_ctrl & 1)
2062c01f2b83SNavdeep Parhar err = ael2020_intr_enable(phy);
2063c01f2b83SNavdeep Parhar return err;
2064c01f2b83SNavdeep Parhar }
2065c01f2b83SNavdeep Parhar
2066c01f2b83SNavdeep Parhar /*
2067c01f2b83SNavdeep Parhar * Handle a PHY interrupt.
2068c01f2b83SNavdeep Parhar */
ael2020_intr_handler(struct cphy * phy)2069c01f2b83SNavdeep Parhar static int ael2020_intr_handler(struct cphy *phy)
2070c01f2b83SNavdeep Parhar {
2071c01f2b83SNavdeep Parhar unsigned int stat;
2072c01f2b83SNavdeep Parhar int ret, edc_needed, cause = 0;
2073c01f2b83SNavdeep Parhar
2074c01f2b83SNavdeep Parhar ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2020_GPIO_INTR, &stat);
2075c01f2b83SNavdeep Parhar if (ret)
2076c01f2b83SNavdeep Parhar return ret;
2077c01f2b83SNavdeep Parhar
2078c01f2b83SNavdeep Parhar if (stat & (0x1 << AEL2020_GPIO_MODDET)) {
2079c01f2b83SNavdeep Parhar /* modules have max 300 ms init time after hot plug */
2080c01f2b83SNavdeep Parhar ret = ael2020_get_module_type(phy, 300);
2081c01f2b83SNavdeep Parhar if (ret < 0)
2082c01f2b83SNavdeep Parhar return ret;
2083c01f2b83SNavdeep Parhar
2084c01f2b83SNavdeep Parhar phy->modtype = (u8)ret;
2085c01f2b83SNavdeep Parhar if (ret == phy_modtype_none)
2086c01f2b83SNavdeep Parhar edc_needed = phy->priv; /* on unplug retain EDC */
2087c01f2b83SNavdeep Parhar else if (ret == phy_modtype_twinax ||
2088c01f2b83SNavdeep Parhar ret == phy_modtype_twinax_long)
2089c01f2b83SNavdeep Parhar edc_needed = edc_twinax;
2090c01f2b83SNavdeep Parhar else
2091c01f2b83SNavdeep Parhar edc_needed = edc_sr;
2092c01f2b83SNavdeep Parhar
2093c01f2b83SNavdeep Parhar if (edc_needed != phy->priv) {
2094c01f2b83SNavdeep Parhar ret = ael2020_reset(phy, 0);
2095c01f2b83SNavdeep Parhar return ret ? ret : cphy_cause_module_change;
2096c01f2b83SNavdeep Parhar }
2097c01f2b83SNavdeep Parhar cause = cphy_cause_module_change;
2098c01f2b83SNavdeep Parhar }
2099c01f2b83SNavdeep Parhar
2100c01f2b83SNavdeep Parhar ret = t3_phy_lasi_intr_handler(phy);
2101c01f2b83SNavdeep Parhar if (ret < 0)
2102c01f2b83SNavdeep Parhar return ret;
2103c01f2b83SNavdeep Parhar
2104c01f2b83SNavdeep Parhar ret |= cause;
2105c01f2b83SNavdeep Parhar if (!ret)
2106c01f2b83SNavdeep Parhar ret |= cphy_cause_link_change;
2107c01f2b83SNavdeep Parhar return ret;
2108c01f2b83SNavdeep Parhar }
2109c01f2b83SNavdeep Parhar
2110c01f2b83SNavdeep Parhar static struct cphy_ops ael2020_ops = {
2111c01f2b83SNavdeep Parhar #ifdef C99_NOT_SUPPORTED
2112c01f2b83SNavdeep Parhar ael2020_reset,
2113c01f2b83SNavdeep Parhar ael2020_intr_enable,
2114c01f2b83SNavdeep Parhar ael2020_intr_disable,
2115c01f2b83SNavdeep Parhar ael2020_intr_clear,
2116c01f2b83SNavdeep Parhar ael2020_intr_handler,
2117c01f2b83SNavdeep Parhar NULL,
2118c01f2b83SNavdeep Parhar NULL,
2119c01f2b83SNavdeep Parhar NULL,
2120c01f2b83SNavdeep Parhar NULL,
2121c01f2b83SNavdeep Parhar NULL,
2122c01f2b83SNavdeep Parhar get_link_status_r,
2123c01f2b83SNavdeep Parhar ael1002_power_down,
2124c01f2b83SNavdeep Parhar #else
2125c01f2b83SNavdeep Parhar .reset = ael2020_reset,
2126c01f2b83SNavdeep Parhar .intr_enable = ael2020_intr_enable,
2127c01f2b83SNavdeep Parhar .intr_disable = ael2020_intr_disable,
2128c01f2b83SNavdeep Parhar .intr_clear = ael2020_intr_clear,
2129c01f2b83SNavdeep Parhar .intr_handler = ael2020_intr_handler,
2130c01f2b83SNavdeep Parhar .get_link_status = get_link_status_r,
2131c01f2b83SNavdeep Parhar .power_down = ael1002_power_down,
2132c01f2b83SNavdeep Parhar #endif
2133c01f2b83SNavdeep Parhar };
2134c01f2b83SNavdeep Parhar
t3_ael2020_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)2135c01f2b83SNavdeep Parhar int t3_ael2020_phy_prep(pinfo_t *pinfo, int phy_addr,
2136c01f2b83SNavdeep Parhar const struct mdio_ops *mdio_ops)
2137c01f2b83SNavdeep Parhar {
2138c01f2b83SNavdeep Parhar int err;
2139c01f2b83SNavdeep Parhar struct cphy *phy = &pinfo->phy;
2140c01f2b83SNavdeep Parhar
2141c01f2b83SNavdeep Parhar cphy_init(phy, pinfo->adapter, pinfo, phy_addr, &ael2020_ops, mdio_ops,
2142c01f2b83SNavdeep Parhar SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE |
2143c01f2b83SNavdeep Parhar SUPPORTED_IRQ, "10GBASE-R");
2144c01f2b83SNavdeep Parhar msleep(125);
2145c01f2b83SNavdeep Parhar
2146c01f2b83SNavdeep Parhar err = set_phy_regs(phy, ael2020_reset_regs);
2147c01f2b83SNavdeep Parhar if (err)
2148c01f2b83SNavdeep Parhar return err;
214983179d39SNavdeep Parhar msleep(100);
215083179d39SNavdeep Parhar
2151c01f2b83SNavdeep Parhar err = ael2020_get_module_type(phy, 0);
2152c01f2b83SNavdeep Parhar if (err >= 0)
2153c01f2b83SNavdeep Parhar phy->modtype = err;
2154c01f2b83SNavdeep Parhar
2155c01f2b83SNavdeep Parhar ael_laser_down(phy, 0);
2156c01f2b83SNavdeep Parhar return 0;
2157c01f2b83SNavdeep Parhar }
2158c01f2b83SNavdeep Parhar
2159c01f2b83SNavdeep Parhar /*
21609b4de886SKip Macy * Get link status for a 10GBASE-X device.
21619b4de886SKip Macy */
get_link_status_x(struct cphy * phy,int * link_state,int * speed,int * duplex,int * fc)2162a5eb009bSNavdeep Parhar static int get_link_status_x(struct cphy *phy, int *link_state, int *speed,
21639b4de886SKip Macy int *duplex, int *fc)
21649b4de886SKip Macy {
2165a5eb009bSNavdeep Parhar if (link_state) {
21669b4de886SKip Macy unsigned int stat0, stat1, stat2;
21679b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0);
21689b4de886SKip Macy
21699b4de886SKip Macy if (!err)
21709b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_X, &stat1);
21719b4de886SKip Macy if (!err)
21729b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2);
21739b4de886SKip Macy if (err)
21749b4de886SKip Macy return err;
2175a5eb009bSNavdeep Parhar if ((stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1)
2176a5eb009bSNavdeep Parhar *link_state = PHY_LINK_UP;
2177a5eb009bSNavdeep Parhar else
2178a5eb009bSNavdeep Parhar *link_state = PHY_LINK_DOWN;
21799b4de886SKip Macy }
21809b4de886SKip Macy if (speed)
21819b4de886SKip Macy *speed = SPEED_10000;
21829b4de886SKip Macy if (duplex)
21839b4de886SKip Macy *duplex = DUPLEX_FULL;
21849b4de886SKip Macy return 0;
21859b4de886SKip Macy }
21869b4de886SKip Macy
2187b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED
2188b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = {
2189b6d90eb7SKip Macy ael1006_reset,
21904af83c8cSKip Macy t3_phy_lasi_intr_enable,
21914af83c8cSKip Macy t3_phy_lasi_intr_disable,
21924af83c8cSKip Macy t3_phy_lasi_intr_clear,
21934af83c8cSKip Macy t3_phy_lasi_intr_handler,
2194b6d90eb7SKip Macy NULL,
2195b6d90eb7SKip Macy NULL,
2196b6d90eb7SKip Macy NULL,
2197b6d90eb7SKip Macy NULL,
2198b6d90eb7SKip Macy NULL,
21999b4de886SKip Macy get_link_status_x,
2200c01f2b83SNavdeep Parhar ael1002_power_down,
2201b6d90eb7SKip Macy };
2202b6d90eb7SKip Macy #else
2203b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = {
2204b6d90eb7SKip Macy .reset = ael1006_reset,
22054af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable,
22064af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable,
22074af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear,
22084af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler,
22099b4de886SKip Macy .get_link_status = get_link_status_x,
2210c01f2b83SNavdeep Parhar .power_down = ael1002_power_down,
2211b6d90eb7SKip Macy };
2212b6d90eb7SKip Macy #endif
2213b6d90eb7SKip Macy
t3_qt2045_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)2214c01f2b83SNavdeep Parhar int t3_qt2045_phy_prep(pinfo_t *pinfo, int phy_addr,
2215b6d90eb7SKip Macy const struct mdio_ops *mdio_ops)
2216b6d90eb7SKip Macy {
2217b6d90eb7SKip Macy unsigned int stat;
2218c01f2b83SNavdeep Parhar struct cphy *phy = &pinfo->phy;
2219b6d90eb7SKip Macy
2220c01f2b83SNavdeep Parhar cphy_init(phy, pinfo->adapter, pinfo, phy_addr, &qt2045_ops, mdio_ops,
22218e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
22228e10660fSKip Macy "10GBASE-CX4");
2223b6d90eb7SKip Macy
2224b6d90eb7SKip Macy /*
2225b6d90eb7SKip Macy * Some cards where the PHY is supposed to be at address 0 actually
2226b6d90eb7SKip Macy * have it at 1.
2227b6d90eb7SKip Macy */
2228b6d90eb7SKip Macy if (!phy_addr && !mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, &stat) &&
2229b6d90eb7SKip Macy stat == 0xffff)
2230b6d90eb7SKip Macy phy->addr = 1;
22318e10660fSKip Macy return 0;
2232b6d90eb7SKip Macy }
2233b6d90eb7SKip Macy
xaui_direct_reset(struct cphy * phy,int wait)2234b6d90eb7SKip Macy static int xaui_direct_reset(struct cphy *phy, int wait)
2235b6d90eb7SKip Macy {
2236b6d90eb7SKip Macy return 0;
2237b6d90eb7SKip Macy }
2238b6d90eb7SKip Macy
xaui_direct_get_link_status(struct cphy * phy,int * link_state,int * speed,int * duplex,int * fc)2239a5eb009bSNavdeep Parhar static int xaui_direct_get_link_status(struct cphy *phy, int *link_state,
2240b6d90eb7SKip Macy int *speed, int *duplex, int *fc)
2241b6d90eb7SKip Macy {
2242a5eb009bSNavdeep Parhar if (link_state) {
2243b6d90eb7SKip Macy unsigned int status;
2244c01f2b83SNavdeep Parhar adapter_t *adapter = phy->adapter;
2245b6d90eb7SKip Macy
2246c01f2b83SNavdeep Parhar status = t3_read_reg(adapter,
2247ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT0, phy->addr)) |
2248c01f2b83SNavdeep Parhar t3_read_reg(adapter,
2249ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT1, phy->addr)) |
2250c01f2b83SNavdeep Parhar t3_read_reg(adapter,
2251ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT2, phy->addr)) |
2252c01f2b83SNavdeep Parhar t3_read_reg(adapter,
2253ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT3, phy->addr));
2254a5eb009bSNavdeep Parhar *link_state = status & F_LOWSIG0 ? PHY_LINK_DOWN : PHY_LINK_UP;
2255b6d90eb7SKip Macy }
2256b6d90eb7SKip Macy if (speed)
2257b6d90eb7SKip Macy *speed = SPEED_10000;
2258b6d90eb7SKip Macy if (duplex)
2259b6d90eb7SKip Macy *duplex = DUPLEX_FULL;
2260b6d90eb7SKip Macy return 0;
2261b6d90eb7SKip Macy }
2262b6d90eb7SKip Macy
xaui_direct_power_down(struct cphy * phy,int enable)2263b6d90eb7SKip Macy static int xaui_direct_power_down(struct cphy *phy, int enable)
2264b6d90eb7SKip Macy {
2265b6d90eb7SKip Macy return 0;
2266b6d90eb7SKip Macy }
2267b6d90eb7SKip Macy
2268b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED
2269b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = {
2270b6d90eb7SKip Macy xaui_direct_reset,
2271b6d90eb7SKip Macy ael1002_intr_noop,
2272b6d90eb7SKip Macy ael1002_intr_noop,
2273b6d90eb7SKip Macy ael1002_intr_noop,
2274b6d90eb7SKip Macy ael1002_intr_noop,
2275b6d90eb7SKip Macy NULL,
2276b6d90eb7SKip Macy NULL,
2277b6d90eb7SKip Macy NULL,
2278b6d90eb7SKip Macy NULL,
2279b6d90eb7SKip Macy NULL,
2280b6d90eb7SKip Macy xaui_direct_get_link_status,
2281b6d90eb7SKip Macy xaui_direct_power_down,
2282b6d90eb7SKip Macy };
2283b6d90eb7SKip Macy #else
2284b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = {
2285b6d90eb7SKip Macy .reset = xaui_direct_reset,
2286b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop,
2287b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop,
2288b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop,
2289b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop,
2290b6d90eb7SKip Macy .get_link_status = xaui_direct_get_link_status,
2291b6d90eb7SKip Macy .power_down = xaui_direct_power_down,
2292b6d90eb7SKip Macy };
2293b6d90eb7SKip Macy #endif
2294b6d90eb7SKip Macy
t3_xaui_direct_phy_prep(pinfo_t * pinfo,int phy_addr,const struct mdio_ops * mdio_ops)2295c01f2b83SNavdeep Parhar int t3_xaui_direct_phy_prep(pinfo_t *pinfo, int phy_addr,
2296b6d90eb7SKip Macy const struct mdio_ops *mdio_ops)
2297b6d90eb7SKip Macy {
2298c01f2b83SNavdeep Parhar cphy_init(&pinfo->phy, pinfo->adapter, pinfo, phy_addr, &xaui_direct_ops, mdio_ops,
22998e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
23008e10660fSKip Macy "10GBASE-CX4");
23018e10660fSKip Macy return 0;
2302b6d90eb7SKip Macy }
2303