1b6d90eb7SKip Macy /************************************************************************** 2b6d90eb7SKip Macy 319905d6dSKip Macy Copyright (c) 2007-2008, Chelsio Inc. 4b6d90eb7SKip Macy All rights reserved. 5b6d90eb7SKip Macy 6b6d90eb7SKip Macy Redistribution and use in source and binary forms, with or without 7b6d90eb7SKip Macy modification, are permitted provided that the following conditions are met: 8b6d90eb7SKip Macy 9b6d90eb7SKip Macy 1. Redistributions of source code must retain the above copyright notice, 10b6d90eb7SKip Macy this list of conditions and the following disclaimer. 11b6d90eb7SKip Macy 1210faa568SKip Macy 2. Neither the name of the Chelsio Corporation nor the names of its 13b6d90eb7SKip Macy contributors may be used to endorse or promote products derived from 14b6d90eb7SKip Macy this software without specific prior written permission. 15b6d90eb7SKip Macy 16b6d90eb7SKip Macy THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17b6d90eb7SKip Macy AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18b6d90eb7SKip Macy IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19b6d90eb7SKip Macy ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20b6d90eb7SKip Macy LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21b6d90eb7SKip Macy CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22b6d90eb7SKip Macy SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23b6d90eb7SKip Macy INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24b6d90eb7SKip Macy CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25b6d90eb7SKip Macy ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26b6d90eb7SKip Macy POSSIBILITY OF SUCH DAMAGE. 27b6d90eb7SKip Macy 28b6d90eb7SKip Macy ***************************************************************************/ 29b6d90eb7SKip Macy 30b6d90eb7SKip Macy #include <sys/cdefs.h> 31b6d90eb7SKip Macy __FBSDID("$FreeBSD$"); 32b6d90eb7SKip Macy 3310faa568SKip Macy #include <cxgb_include.h> 34b6d90eb7SKip Macy 358e10660fSKip Macy #undef msleep 368e10660fSKip Macy #define msleep t3_os_sleep 378e10660fSKip Macy 38b6d90eb7SKip Macy enum { 399b4de886SKip Macy PMD_RSD = 10, /* PMA/PMD receive signal detect register */ 409b4de886SKip Macy PCS_STAT1_X = 24, /* 10GBASE-X PCS status 1 register */ 419b4de886SKip Macy PCS_STAT1_R = 32, /* 10GBASE-R PCS status 1 register */ 429b4de886SKip Macy XS_LN_STAT = 24 /* XS lane status register */ 439b4de886SKip Macy }; 449b4de886SKip Macy 459b4de886SKip Macy enum { 46b6d90eb7SKip Macy AEL100X_TX_DISABLE = 9, 47b6d90eb7SKip Macy AEL100X_TX_CONFIG1 = 0xc002, 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, 524af83c8cSKip Macy AEL_OPT_SETTINGS = 0xc017, 539b4de886SKip Macy AEL_I2C_CTRL = 0xc30a, 549b4de886SKip Macy AEL_I2C_DATA = 0xc30b, 559b4de886SKip Macy AEL_I2C_STAT = 0xc30c, 569b4de886SKip Macy AEL2005_GPIO_CTRL = 0xc214, 579b4de886SKip Macy AEL2005_GPIO_STAT = 0xc215, 58b6d90eb7SKip Macy }; 59b6d90eb7SKip Macy 609b4de886SKip Macy enum { edc_none, edc_sr, edc_twinax }; 619b4de886SKip Macy 629b4de886SKip Macy /* PHY module I2C device address */ 639b4de886SKip Macy #define MODULE_DEV_ADDR 0xa0 649b4de886SKip Macy 659b4de886SKip Macy #define AEL2005_MODDET_IRQ 4 669b4de886SKip Macy 674af83c8cSKip Macy struct reg_val { 684af83c8cSKip Macy unsigned short mmd_addr; 694af83c8cSKip Macy unsigned short reg_addr; 704af83c8cSKip Macy unsigned short clear_bits; 714af83c8cSKip Macy unsigned short set_bits; 724af83c8cSKip Macy }; 734af83c8cSKip Macy 74837f41b0SGeorge V. Neville-Neil static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr); 75837f41b0SGeorge V. Neville-Neil 76837f41b0SGeorge V. Neville-Neil static int get_module_type (struct cphy *phy, int hint) 77837f41b0SGeorge V. Neville-Neil { 78837f41b0SGeorge V. Neville-Neil int v; 79837f41b0SGeorge V. Neville-Neil 80837f41b0SGeorge V. Neville-Neil v = hint ? hint : ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0); 81837f41b0SGeorge V. Neville-Neil if (v < 0) 82837f41b0SGeorge V. Neville-Neil return v; 83837f41b0SGeorge V. Neville-Neil 84837f41b0SGeorge V. Neville-Neil if (v == 0x3) { 85837f41b0SGeorge V. Neville-Neil /* SFP: see SFF-8472 for below */ 86837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 3); 87837f41b0SGeorge V. Neville-Neil if (v < 0) 88837f41b0SGeorge V. Neville-Neil return v; 89837f41b0SGeorge V. Neville-Neil 90837f41b0SGeorge V. Neville-Neil if (v == 0x1) 91837f41b0SGeorge V. Neville-Neil return phy_modtype_twinax; 92837f41b0SGeorge V. Neville-Neil if (v == 0x10) 93837f41b0SGeorge V. Neville-Neil return phy_modtype_sr; 94837f41b0SGeorge V. Neville-Neil if (v == 0x20) 95837f41b0SGeorge V. Neville-Neil return phy_modtype_lr; 96837f41b0SGeorge V. Neville-Neil if (v == 0x40) 97837f41b0SGeorge V. Neville-Neil return phy_modtype_lrm; 98837f41b0SGeorge V. Neville-Neil 99837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 6); 100837f41b0SGeorge V. Neville-Neil if (v < 0) 101837f41b0SGeorge V. Neville-Neil return v; 102837f41b0SGeorge V. Neville-Neil if (v != 4) 103837f41b0SGeorge V. Neville-Neil return phy_modtype_unknown; 104837f41b0SGeorge V. Neville-Neil 105837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 10); 106837f41b0SGeorge V. Neville-Neil if (v < 0) 107837f41b0SGeorge V. Neville-Neil return v; 108837f41b0SGeorge V. Neville-Neil 109837f41b0SGeorge V. Neville-Neil if (v & 0x80) { 110837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0x12); 111837f41b0SGeorge V. Neville-Neil if (v < 0) 112837f41b0SGeorge V. Neville-Neil return v; 113837f41b0SGeorge V. Neville-Neil return v > 10 ? phy_modtype_twinax_long : 114837f41b0SGeorge V. Neville-Neil phy_modtype_twinax; 115837f41b0SGeorge V. Neville-Neil } 116837f41b0SGeorge V. Neville-Neil } else if (v == 0x6) { 117837f41b0SGeorge V. Neville-Neil /* XFP: See INF-8077i for details. */ 118837f41b0SGeorge V. Neville-Neil 119837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 127); 120837f41b0SGeorge V. Neville-Neil if (v < 0) 121837f41b0SGeorge V. Neville-Neil return v; 122837f41b0SGeorge V. Neville-Neil 123837f41b0SGeorge V. Neville-Neil if (v != 1) { 124837f41b0SGeorge V. Neville-Neil /* XXX: set page select to table 1 yourself */ 125837f41b0SGeorge V. Neville-Neil return phy_modtype_unknown; 126837f41b0SGeorge V. Neville-Neil } 127837f41b0SGeorge V. Neville-Neil 128837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 131); 129837f41b0SGeorge V. Neville-Neil if (v < 0) 130837f41b0SGeorge V. Neville-Neil return v; 131837f41b0SGeorge V. Neville-Neil if (v == 0x10) 132837f41b0SGeorge V. Neville-Neil return phy_modtype_lrm; 133837f41b0SGeorge V. Neville-Neil if (v == 0x40) 134837f41b0SGeorge V. Neville-Neil return phy_modtype_lr; 135837f41b0SGeorge V. Neville-Neil if (v == 0x80) 136837f41b0SGeorge V. Neville-Neil return phy_modtype_sr; 137837f41b0SGeorge V. Neville-Neil } 138837f41b0SGeorge V. Neville-Neil 139837f41b0SGeorge V. Neville-Neil return phy_modtype_unknown; 140837f41b0SGeorge V. Neville-Neil } 141837f41b0SGeorge V. Neville-Neil 1424af83c8cSKip Macy static int set_phy_regs(struct cphy *phy, const struct reg_val *rv) 1434af83c8cSKip Macy { 1444af83c8cSKip Macy int err; 1454af83c8cSKip Macy 1464af83c8cSKip Macy for (err = 0; rv->mmd_addr && !err; rv++) { 1474af83c8cSKip Macy if (rv->clear_bits == 0xffff) 1484af83c8cSKip Macy err = mdio_write(phy, rv->mmd_addr, rv->reg_addr, 1494af83c8cSKip Macy rv->set_bits); 1504af83c8cSKip Macy else 1514af83c8cSKip Macy err = t3_mdio_change_bits(phy, rv->mmd_addr, 1524af83c8cSKip Macy rv->reg_addr, rv->clear_bits, 1534af83c8cSKip Macy rv->set_bits); 1544af83c8cSKip Macy } 1554af83c8cSKip Macy return err; 1564af83c8cSKip Macy } 1574af83c8cSKip Macy 158b6d90eb7SKip Macy static void ael100x_txon(struct cphy *phy) 159b6d90eb7SKip Macy { 160b6d90eb7SKip Macy int tx_on_gpio = phy->addr == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL; 161b6d90eb7SKip Macy 1628e10660fSKip Macy msleep(100); 163b6d90eb7SKip Macy t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, 0, tx_on_gpio); 1648e10660fSKip Macy msleep(30); 165b6d90eb7SKip Macy } 166b6d90eb7SKip Macy 167b6d90eb7SKip Macy static int ael1002_power_down(struct cphy *phy, int enable) 168b6d90eb7SKip Macy { 169b6d90eb7SKip Macy int err; 170b6d90eb7SKip Macy 171b6d90eb7SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_DISABLE, !!enable); 172b6d90eb7SKip Macy if (!err) 173b6d90eb7SKip Macy err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 174b6d90eb7SKip Macy BMCR_PDOWN, enable ? BMCR_PDOWN : 0); 175b6d90eb7SKip Macy return err; 176b6d90eb7SKip Macy } 177b6d90eb7SKip Macy 178837f41b0SGeorge V. Neville-Neil static int ael1002_get_module_type(struct cphy *phy, int delay_ms) 179837f41b0SGeorge V. Neville-Neil { 180837f41b0SGeorge V. Neville-Neil int v; 181837f41b0SGeorge V. Neville-Neil 182837f41b0SGeorge V. Neville-Neil if (delay_ms) 183837f41b0SGeorge V. Neville-Neil msleep(delay_ms); 184837f41b0SGeorge V. Neville-Neil 185837f41b0SGeorge V. Neville-Neil v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0); 186837f41b0SGeorge V. Neville-Neil 187837f41b0SGeorge V. Neville-Neil return v == -ETIMEDOUT ? phy_modtype_none : get_module_type(phy, v); 188837f41b0SGeorge V. Neville-Neil } 189837f41b0SGeorge V. Neville-Neil 190b6d90eb7SKip Macy static int ael1002_reset(struct cphy *phy, int wait) 191b6d90eb7SKip Macy { 192b6d90eb7SKip Macy int err; 193b6d90eb7SKip Macy 194b6d90eb7SKip Macy if ((err = ael1002_power_down(phy, 0)) || 195b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_CONFIG1, 1)) || 196b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_HI, 0)) || 197b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_LO, 0)) || 198b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_XFI_EQL, 0x18)) || 199b6d90eb7SKip Macy (err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL1002_LB_EN, 200b6d90eb7SKip Macy 0, 1 << 5))) 201b6d90eb7SKip Macy return err; 202837f41b0SGeorge V. Neville-Neil 203837f41b0SGeorge V. Neville-Neil err = ael1002_get_module_type(phy, 300); 204837f41b0SGeorge V. Neville-Neil if (err >= 0) 205837f41b0SGeorge V. Neville-Neil phy->modtype = err; 206837f41b0SGeorge V. Neville-Neil 207b6d90eb7SKip Macy return 0; 208b6d90eb7SKip Macy } 209b6d90eb7SKip Macy 210b6d90eb7SKip Macy static int ael1002_intr_noop(struct cphy *phy) 211b6d90eb7SKip Macy { 212b6d90eb7SKip Macy return 0; 213b6d90eb7SKip Macy } 214b6d90eb7SKip Macy 2159b4de886SKip Macy /* 2169b4de886SKip Macy * Get link status for a 10GBASE-R device. 2179b4de886SKip Macy */ 2189b4de886SKip Macy static int get_link_status_r(struct cphy *phy, int *link_ok, int *speed, 2199b4de886SKip Macy int *duplex, int *fc) 220b6d90eb7SKip Macy { 221b6d90eb7SKip Macy if (link_ok) { 2229b4de886SKip Macy unsigned int stat0, stat1, stat2; 2239b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); 224b6d90eb7SKip Macy 2259b4de886SKip Macy if (!err) 2269b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_R, &stat1); 2279b4de886SKip Macy if (!err) 2289b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); 229b6d90eb7SKip Macy if (err) 230b6d90eb7SKip Macy return err; 2319b4de886SKip Macy *link_ok = (stat0 & stat1 & (stat2 >> 12)) & 1; 232b6d90eb7SKip Macy } 233b6d90eb7SKip Macy if (speed) 234b6d90eb7SKip Macy *speed = SPEED_10000; 235b6d90eb7SKip Macy if (duplex) 236b6d90eb7SKip Macy *duplex = DUPLEX_FULL; 237b6d90eb7SKip Macy return 0; 238b6d90eb7SKip Macy } 239b6d90eb7SKip Macy 240b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 241b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = { 242b6d90eb7SKip Macy ael1002_reset, 243b6d90eb7SKip Macy ael1002_intr_noop, 244b6d90eb7SKip Macy ael1002_intr_noop, 245b6d90eb7SKip Macy ael1002_intr_noop, 246b6d90eb7SKip Macy ael1002_intr_noop, 247b6d90eb7SKip Macy NULL, 248b6d90eb7SKip Macy NULL, 249b6d90eb7SKip Macy NULL, 250b6d90eb7SKip Macy NULL, 251b6d90eb7SKip Macy NULL, 2529b4de886SKip Macy get_link_status_r, 253b6d90eb7SKip Macy ael1002_power_down, 254b6d90eb7SKip Macy }; 255b6d90eb7SKip Macy #else 256b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = { 257b6d90eb7SKip Macy .reset = ael1002_reset, 258b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop, 259b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop, 260b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop, 261b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop, 2629b4de886SKip Macy .get_link_status = get_link_status_r, 263b6d90eb7SKip Macy .power_down = ael1002_power_down, 264b6d90eb7SKip Macy }; 265b6d90eb7SKip Macy #endif 266b6d90eb7SKip Macy 2678e10660fSKip Macy int t3_ael1002_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 268b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 269b6d90eb7SKip Macy { 270837f41b0SGeorge V. Neville-Neil int err; 271837f41b0SGeorge V. Neville-Neil 2728e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &ael1002_ops, mdio_ops, 2738e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE, 27419905d6dSKip Macy "10GBASE-R"); 275b6d90eb7SKip Macy ael100x_txon(phy); 276837f41b0SGeorge V. Neville-Neil 277837f41b0SGeorge V. Neville-Neil err = ael1002_get_module_type(phy, 0); 278837f41b0SGeorge V. Neville-Neil if (err >= 0) 279837f41b0SGeorge V. Neville-Neil phy->modtype = err; 280837f41b0SGeorge V. Neville-Neil 2818e10660fSKip Macy return 0; 282b6d90eb7SKip Macy } 283b6d90eb7SKip Macy 284b6d90eb7SKip Macy static int ael1006_reset(struct cphy *phy, int wait) 285b6d90eb7SKip Macy { 2862a1b9f07SGeorge V. Neville-Neil u32 gpio_out; 2872a1b9f07SGeorge V. Neville-Neil t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); 2882a1b9f07SGeorge V. Neville-Neil /* Hack to reset the phy correctly */ 2892a1b9f07SGeorge V. Neville-Neil /* Read out the current value */ 2902a1b9f07SGeorge V. Neville-Neil gpio_out = t3_read_reg(phy->adapter, A_T3DBG_GPIO_EN); 2912a1b9f07SGeorge V. Neville-Neil /* Reset the phy */ 2922a1b9f07SGeorge V. Neville-Neil gpio_out &= ~F_GPIO6_OUT_VAL; 2932a1b9f07SGeorge V. Neville-Neil t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); 2942a1b9f07SGeorge V. Neville-Neil msleep(125); 2952a1b9f07SGeorge V. Neville-Neil /* Take the phy out of reset */ 2962a1b9f07SGeorge V. Neville-Neil gpio_out |= F_GPIO6_OUT_VAL; 2972a1b9f07SGeorge V. Neville-Neil t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); 2982a1b9f07SGeorge V. Neville-Neil msleep(125); 2992a1b9f07SGeorge V. Neville-Neil t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); 30090362409SGeorge V. Neville-Neil 30190362409SGeorge V. Neville-Neil /* Phy loopback work around for ael1006 */ 30290362409SGeorge V. Neville-Neil /* Soft reset phy by toggling loopback */ 30390362409SGeorge V. Neville-Neil msleep(125); 30490362409SGeorge V. Neville-Neil /* Put phy into local loopback */ 30590362409SGeorge V. Neville-Neil t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 0, 1); 30690362409SGeorge V. Neville-Neil msleep(125); 30790362409SGeorge V. Neville-Neil /* Take phy out of local loopback */ 30890362409SGeorge V. Neville-Neil t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 1, 0); 30990362409SGeorge V. Neville-Neil 3102a1b9f07SGeorge V. Neville-Neil return 0; 311b6d90eb7SKip Macy } 312b6d90eb7SKip Macy 313b6d90eb7SKip Macy static int ael1006_power_down(struct cphy *phy, int enable) 314b6d90eb7SKip Macy { 315b6d90eb7SKip Macy return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 316b6d90eb7SKip Macy BMCR_PDOWN, enable ? BMCR_PDOWN : 0); 317b6d90eb7SKip Macy } 318b6d90eb7SKip Macy 319b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 320b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = { 321b6d90eb7SKip Macy ael1006_reset, 3224af83c8cSKip Macy t3_phy_lasi_intr_enable, 3234af83c8cSKip Macy t3_phy_lasi_intr_disable, 3244af83c8cSKip Macy t3_phy_lasi_intr_clear, 3254af83c8cSKip Macy t3_phy_lasi_intr_handler, 326b6d90eb7SKip Macy NULL, 327b6d90eb7SKip Macy NULL, 328b6d90eb7SKip Macy NULL, 329b6d90eb7SKip Macy NULL, 330b6d90eb7SKip Macy NULL, 3319b4de886SKip Macy get_link_status_r, 332b6d90eb7SKip Macy ael1006_power_down, 333b6d90eb7SKip Macy }; 334b6d90eb7SKip Macy #else 335b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = { 336b6d90eb7SKip Macy .reset = ael1006_reset, 3374af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable, 3384af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable, 3394af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear, 3404af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler, 3419b4de886SKip Macy .get_link_status = get_link_status_r, 342b6d90eb7SKip Macy .power_down = ael1006_power_down, 343b6d90eb7SKip Macy }; 344b6d90eb7SKip Macy #endif 345b6d90eb7SKip Macy 3468e10660fSKip Macy int t3_ael1006_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 347b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 348b6d90eb7SKip Macy { 3498e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &ael1006_ops, mdio_ops, 3508e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE, 3518e10660fSKip Macy "10GBASE-SR"); 352b6d90eb7SKip Macy ael100x_txon(phy); 3538e10660fSKip Macy return 0; 354b6d90eb7SKip Macy } 355b6d90eb7SKip Macy 3564af83c8cSKip Macy static int ael2005_setup_sr_edc(struct cphy *phy) 3574af83c8cSKip Macy { 3589b4de886SKip Macy static struct reg_val regs[] = { 3599b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x181 }, 3609b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc010, 0xffff, 0x448a }, 3619b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5200 }, 3629b4de886SKip Macy { 0, 0, 0, 0 } 3639b4de886SKip Macy }; 3644af83c8cSKip Macy static u16 sr_edc[] = { 3654af83c8cSKip Macy 0xcc00, 0x2ff4, 3664af83c8cSKip Macy 0xcc01, 0x3cd4, 3674af83c8cSKip Macy 0xcc02, 0x2015, 3684af83c8cSKip Macy 0xcc03, 0x3105, 3694af83c8cSKip Macy 0xcc04, 0x6524, 3704af83c8cSKip Macy 0xcc05, 0x27ff, 3714af83c8cSKip Macy 0xcc06, 0x300f, 3724af83c8cSKip Macy 0xcc07, 0x2c8b, 3734af83c8cSKip Macy 0xcc08, 0x300b, 3744af83c8cSKip Macy 0xcc09, 0x4009, 3754af83c8cSKip Macy 0xcc0a, 0x400e, 3764af83c8cSKip Macy 0xcc0b, 0x2f72, 3774af83c8cSKip Macy 0xcc0c, 0x3002, 3784af83c8cSKip Macy 0xcc0d, 0x1002, 3794af83c8cSKip Macy 0xcc0e, 0x2172, 3804af83c8cSKip Macy 0xcc0f, 0x3012, 3814af83c8cSKip Macy 0xcc10, 0x1002, 3824af83c8cSKip Macy 0xcc11, 0x25d2, 3834af83c8cSKip Macy 0xcc12, 0x3012, 3844af83c8cSKip Macy 0xcc13, 0x1002, 3854af83c8cSKip Macy 0xcc14, 0xd01e, 3864af83c8cSKip Macy 0xcc15, 0x27d2, 3874af83c8cSKip Macy 0xcc16, 0x3012, 3884af83c8cSKip Macy 0xcc17, 0x1002, 3894af83c8cSKip Macy 0xcc18, 0x2004, 3904af83c8cSKip Macy 0xcc19, 0x3c84, 3914af83c8cSKip Macy 0xcc1a, 0x6436, 3924af83c8cSKip Macy 0xcc1b, 0x2007, 3934af83c8cSKip Macy 0xcc1c, 0x3f87, 3944af83c8cSKip Macy 0xcc1d, 0x8676, 3954af83c8cSKip Macy 0xcc1e, 0x40b7, 3964af83c8cSKip Macy 0xcc1f, 0xa746, 3974af83c8cSKip Macy 0xcc20, 0x4047, 3984af83c8cSKip Macy 0xcc21, 0x5673, 3994af83c8cSKip Macy 0xcc22, 0x2982, 4004af83c8cSKip Macy 0xcc23, 0x3002, 4014af83c8cSKip Macy 0xcc24, 0x13d2, 4024af83c8cSKip Macy 0xcc25, 0x8bbd, 4034af83c8cSKip Macy 0xcc26, 0x2862, 4044af83c8cSKip Macy 0xcc27, 0x3012, 4054af83c8cSKip Macy 0xcc28, 0x1002, 4064af83c8cSKip Macy 0xcc29, 0x2092, 4074af83c8cSKip Macy 0xcc2a, 0x3012, 4084af83c8cSKip Macy 0xcc2b, 0x1002, 4094af83c8cSKip Macy 0xcc2c, 0x5cc3, 4104af83c8cSKip Macy 0xcc2d, 0x314, 4114af83c8cSKip Macy 0xcc2e, 0x2942, 4124af83c8cSKip Macy 0xcc2f, 0x3002, 4134af83c8cSKip Macy 0xcc30, 0x1002, 4144af83c8cSKip Macy 0xcc31, 0xd019, 4154af83c8cSKip Macy 0xcc32, 0x2032, 4164af83c8cSKip Macy 0xcc33, 0x3012, 4174af83c8cSKip Macy 0xcc34, 0x1002, 4184af83c8cSKip Macy 0xcc35, 0x2a04, 4194af83c8cSKip Macy 0xcc36, 0x3c74, 4204af83c8cSKip Macy 0xcc37, 0x6435, 4214af83c8cSKip Macy 0xcc38, 0x2fa4, 4224af83c8cSKip Macy 0xcc39, 0x3cd4, 4234af83c8cSKip Macy 0xcc3a, 0x6624, 4244af83c8cSKip Macy 0xcc3b, 0x5563, 4254af83c8cSKip Macy 0xcc3c, 0x2d42, 4264af83c8cSKip Macy 0xcc3d, 0x3002, 4274af83c8cSKip Macy 0xcc3e, 0x13d2, 4284af83c8cSKip Macy 0xcc3f, 0x464d, 4294af83c8cSKip Macy 0xcc40, 0x2862, 4304af83c8cSKip Macy 0xcc41, 0x3012, 4314af83c8cSKip Macy 0xcc42, 0x1002, 4324af83c8cSKip Macy 0xcc43, 0x2032, 4334af83c8cSKip Macy 0xcc44, 0x3012, 4344af83c8cSKip Macy 0xcc45, 0x1002, 4354af83c8cSKip Macy 0xcc46, 0x2fb4, 4364af83c8cSKip Macy 0xcc47, 0x3cd4, 4374af83c8cSKip Macy 0xcc48, 0x6624, 4384af83c8cSKip Macy 0xcc49, 0x5563, 4394af83c8cSKip Macy 0xcc4a, 0x2d42, 4404af83c8cSKip Macy 0xcc4b, 0x3002, 4414af83c8cSKip Macy 0xcc4c, 0x13d2, 4424af83c8cSKip Macy 0xcc4d, 0x2ed2, 4434af83c8cSKip Macy 0xcc4e, 0x3002, 4444af83c8cSKip Macy 0xcc4f, 0x1002, 4454af83c8cSKip Macy 0xcc50, 0x2fd2, 4464af83c8cSKip Macy 0xcc51, 0x3002, 4474af83c8cSKip Macy 0xcc52, 0x1002, 4484af83c8cSKip Macy 0xcc53, 0x004, 4494af83c8cSKip Macy 0xcc54, 0x2942, 4504af83c8cSKip Macy 0xcc55, 0x3002, 4514af83c8cSKip Macy 0xcc56, 0x1002, 4524af83c8cSKip Macy 0xcc57, 0x2092, 4534af83c8cSKip Macy 0xcc58, 0x3012, 4544af83c8cSKip Macy 0xcc59, 0x1002, 4554af83c8cSKip Macy 0xcc5a, 0x5cc3, 4564af83c8cSKip Macy 0xcc5b, 0x317, 4574af83c8cSKip Macy 0xcc5c, 0x2f72, 4584af83c8cSKip Macy 0xcc5d, 0x3002, 4594af83c8cSKip Macy 0xcc5e, 0x1002, 4604af83c8cSKip Macy 0xcc5f, 0x2942, 4614af83c8cSKip Macy 0xcc60, 0x3002, 4624af83c8cSKip Macy 0xcc61, 0x1002, 4634af83c8cSKip Macy 0xcc62, 0x22cd, 4644af83c8cSKip Macy 0xcc63, 0x301d, 4654af83c8cSKip Macy 0xcc64, 0x2862, 4664af83c8cSKip Macy 0xcc65, 0x3012, 4674af83c8cSKip Macy 0xcc66, 0x1002, 4684af83c8cSKip Macy 0xcc67, 0x2ed2, 4694af83c8cSKip Macy 0xcc68, 0x3002, 4704af83c8cSKip Macy 0xcc69, 0x1002, 4714af83c8cSKip Macy 0xcc6a, 0x2d72, 4724af83c8cSKip Macy 0xcc6b, 0x3002, 4734af83c8cSKip Macy 0xcc6c, 0x1002, 4744af83c8cSKip Macy 0xcc6d, 0x628f, 4754af83c8cSKip Macy 0xcc6e, 0x2112, 4764af83c8cSKip Macy 0xcc6f, 0x3012, 4774af83c8cSKip Macy 0xcc70, 0x1002, 4784af83c8cSKip Macy 0xcc71, 0x5aa3, 4794af83c8cSKip Macy 0xcc72, 0x2dc2, 4804af83c8cSKip Macy 0xcc73, 0x3002, 4814af83c8cSKip Macy 0xcc74, 0x1312, 4824af83c8cSKip Macy 0xcc75, 0x6f72, 4834af83c8cSKip Macy 0xcc76, 0x1002, 4844af83c8cSKip Macy 0xcc77, 0x2807, 4854af83c8cSKip Macy 0xcc78, 0x31a7, 4864af83c8cSKip Macy 0xcc79, 0x20c4, 4874af83c8cSKip Macy 0xcc7a, 0x3c24, 4884af83c8cSKip Macy 0xcc7b, 0x6724, 4894af83c8cSKip Macy 0xcc7c, 0x1002, 4904af83c8cSKip Macy 0xcc7d, 0x2807, 4914af83c8cSKip Macy 0xcc7e, 0x3187, 4924af83c8cSKip Macy 0xcc7f, 0x20c4, 4934af83c8cSKip Macy 0xcc80, 0x3c24, 4944af83c8cSKip Macy 0xcc81, 0x6724, 4954af83c8cSKip Macy 0xcc82, 0x1002, 4964af83c8cSKip Macy 0xcc83, 0x2514, 4974af83c8cSKip Macy 0xcc84, 0x3c64, 4984af83c8cSKip Macy 0xcc85, 0x6436, 4994af83c8cSKip Macy 0xcc86, 0xdff4, 5004af83c8cSKip Macy 0xcc87, 0x6436, 5014af83c8cSKip Macy 0xcc88, 0x1002, 5024af83c8cSKip Macy 0xcc89, 0x40a4, 5034af83c8cSKip Macy 0xcc8a, 0x643c, 5044af83c8cSKip Macy 0xcc8b, 0x4016, 5054af83c8cSKip Macy 0xcc8c, 0x8c6c, 5064af83c8cSKip Macy 0xcc8d, 0x2b24, 5074af83c8cSKip Macy 0xcc8e, 0x3c24, 5084af83c8cSKip Macy 0xcc8f, 0x6435, 5094af83c8cSKip Macy 0xcc90, 0x1002, 5104af83c8cSKip Macy 0xcc91, 0x2b24, 5114af83c8cSKip Macy 0xcc92, 0x3c24, 5124af83c8cSKip Macy 0xcc93, 0x643a, 5134af83c8cSKip Macy 0xcc94, 0x4025, 5144af83c8cSKip Macy 0xcc95, 0x8a5a, 5154af83c8cSKip Macy 0xcc96, 0x1002, 5164af83c8cSKip Macy 0xcc97, 0x2731, 5174af83c8cSKip Macy 0xcc98, 0x3011, 5184af83c8cSKip Macy 0xcc99, 0x1001, 5194af83c8cSKip Macy 0xcc9a, 0xc7a0, 5204af83c8cSKip Macy 0xcc9b, 0x100, 5214af83c8cSKip Macy 0xcc9c, 0xc502, 5224af83c8cSKip Macy 0xcc9d, 0x53ac, 5234af83c8cSKip Macy 0xcc9e, 0xc503, 5244af83c8cSKip Macy 0xcc9f, 0xd5d5, 5254af83c8cSKip Macy 0xcca0, 0xc600, 5264af83c8cSKip Macy 0xcca1, 0x2a6d, 5274af83c8cSKip Macy 0xcca2, 0xc601, 5284af83c8cSKip Macy 0xcca3, 0x2a4c, 5294af83c8cSKip Macy 0xcca4, 0xc602, 5304af83c8cSKip Macy 0xcca5, 0x111, 5314af83c8cSKip Macy 0xcca6, 0xc60c, 5324af83c8cSKip Macy 0xcca7, 0x5900, 5334af83c8cSKip Macy 0xcca8, 0xc710, 5344af83c8cSKip Macy 0xcca9, 0x700, 5354af83c8cSKip Macy 0xccaa, 0xc718, 5364af83c8cSKip Macy 0xccab, 0x700, 5374af83c8cSKip Macy 0xccac, 0xc720, 5384af83c8cSKip Macy 0xccad, 0x4700, 5394af83c8cSKip Macy 0xccae, 0xc801, 5404af83c8cSKip Macy 0xccaf, 0x7f50, 5414af83c8cSKip Macy 0xccb0, 0xc802, 5424af83c8cSKip Macy 0xccb1, 0x7760, 5434af83c8cSKip Macy 0xccb2, 0xc803, 5444af83c8cSKip Macy 0xccb3, 0x7fce, 5454af83c8cSKip Macy 0xccb4, 0xc804, 5464af83c8cSKip Macy 0xccb5, 0x5700, 5474af83c8cSKip Macy 0xccb6, 0xc805, 5484af83c8cSKip Macy 0xccb7, 0x5f11, 5494af83c8cSKip Macy 0xccb8, 0xc806, 5504af83c8cSKip Macy 0xccb9, 0x4751, 5514af83c8cSKip Macy 0xccba, 0xc807, 5524af83c8cSKip Macy 0xccbb, 0x57e1, 5534af83c8cSKip Macy 0xccbc, 0xc808, 5544af83c8cSKip Macy 0xccbd, 0x2700, 5554af83c8cSKip Macy 0xccbe, 0xc809, 5564af83c8cSKip Macy 0xccbf, 0x000, 5574af83c8cSKip Macy 0xccc0, 0xc821, 5584af83c8cSKip Macy 0xccc1, 0x002, 5594af83c8cSKip Macy 0xccc2, 0xc822, 5604af83c8cSKip Macy 0xccc3, 0x014, 5614af83c8cSKip Macy 0xccc4, 0xc832, 5624af83c8cSKip Macy 0xccc5, 0x1186, 5634af83c8cSKip Macy 0xccc6, 0xc847, 5644af83c8cSKip Macy 0xccc7, 0x1e02, 5654af83c8cSKip Macy 0xccc8, 0xc013, 5664af83c8cSKip Macy 0xccc9, 0xf341, 5674af83c8cSKip Macy 0xccca, 0xc01a, 5684af83c8cSKip Macy 0xcccb, 0x446, 5694af83c8cSKip Macy 0xcccc, 0xc024, 5704af83c8cSKip Macy 0xcccd, 0x1000, 5714af83c8cSKip Macy 0xccce, 0xc025, 5724af83c8cSKip Macy 0xcccf, 0xa00, 5734af83c8cSKip Macy 0xccd0, 0xc026, 5744af83c8cSKip Macy 0xccd1, 0xc0c, 5754af83c8cSKip Macy 0xccd2, 0xc027, 5764af83c8cSKip Macy 0xccd3, 0xc0c, 5774af83c8cSKip Macy 0xccd4, 0xc029, 5784af83c8cSKip Macy 0xccd5, 0x0a0, 5794af83c8cSKip Macy 0xccd6, 0xc030, 5804af83c8cSKip Macy 0xccd7, 0xa00, 5814af83c8cSKip Macy 0xccd8, 0xc03c, 5824af83c8cSKip Macy 0xccd9, 0x01c, 5834af83c8cSKip Macy 0xccda, 0xc005, 5844af83c8cSKip Macy 0xccdb, 0x7a06, 5854af83c8cSKip Macy 0xccdc, 0x000, 5864af83c8cSKip Macy 0xccdd, 0x2731, 5874af83c8cSKip Macy 0xccde, 0x3011, 5884af83c8cSKip Macy 0xccdf, 0x1001, 5894af83c8cSKip Macy 0xcce0, 0xc620, 5904af83c8cSKip Macy 0xcce1, 0x000, 5914af83c8cSKip Macy 0xcce2, 0xc621, 5924af83c8cSKip Macy 0xcce3, 0x03f, 5934af83c8cSKip Macy 0xcce4, 0xc622, 5944af83c8cSKip Macy 0xcce5, 0x000, 5954af83c8cSKip Macy 0xcce6, 0xc623, 5964af83c8cSKip Macy 0xcce7, 0x000, 5974af83c8cSKip Macy 0xcce8, 0xc624, 5984af83c8cSKip Macy 0xcce9, 0x000, 5994af83c8cSKip Macy 0xccea, 0xc625, 6004af83c8cSKip Macy 0xcceb, 0x000, 6014af83c8cSKip Macy 0xccec, 0xc627, 6024af83c8cSKip Macy 0xcced, 0x000, 6034af83c8cSKip Macy 0xccee, 0xc628, 6044af83c8cSKip Macy 0xccef, 0x000, 6054af83c8cSKip Macy 0xccf0, 0xc62c, 6064af83c8cSKip Macy 0xccf1, 0x000, 6074af83c8cSKip Macy 0xccf2, 0x000, 6084af83c8cSKip Macy 0xccf3, 0x2806, 6094af83c8cSKip Macy 0xccf4, 0x3cb6, 6104af83c8cSKip Macy 0xccf5, 0xc161, 6114af83c8cSKip Macy 0xccf6, 0x6134, 6124af83c8cSKip Macy 0xccf7, 0x6135, 6134af83c8cSKip Macy 0xccf8, 0x5443, 6144af83c8cSKip Macy 0xccf9, 0x303, 6154af83c8cSKip Macy 0xccfa, 0x6524, 6164af83c8cSKip Macy 0xccfb, 0x00b, 6174af83c8cSKip Macy 0xccfc, 0x1002, 6184af83c8cSKip Macy 0xccfd, 0x2104, 6194af83c8cSKip Macy 0xccfe, 0x3c24, 6204af83c8cSKip Macy 0xccff, 0x2105, 6214af83c8cSKip Macy 0xcd00, 0x3805, 6224af83c8cSKip Macy 0xcd01, 0x6524, 6234af83c8cSKip Macy 0xcd02, 0xdff4, 6244af83c8cSKip Macy 0xcd03, 0x4005, 6254af83c8cSKip Macy 0xcd04, 0x6524, 6264af83c8cSKip Macy 0xcd05, 0x1002, 6274af83c8cSKip Macy 0xcd06, 0x5dd3, 6284af83c8cSKip Macy 0xcd07, 0x306, 6294af83c8cSKip Macy 0xcd08, 0x2ff7, 6304af83c8cSKip Macy 0xcd09, 0x38f7, 6314af83c8cSKip Macy 0xcd0a, 0x60b7, 6324af83c8cSKip Macy 0xcd0b, 0xdffd, 6334af83c8cSKip Macy 0xcd0c, 0x00a, 6344af83c8cSKip Macy 0xcd0d, 0x1002, 6354af83c8cSKip Macy 0xcd0e, 0 6364af83c8cSKip Macy }; 6374af83c8cSKip Macy int i, err; 6384af83c8cSKip Macy 6399b4de886SKip Macy err = set_phy_regs(phy, regs); 6409b4de886SKip Macy if (err) 6419b4de886SKip Macy return err; 6429b4de886SKip Macy 6439b4de886SKip Macy msleep(50); 6449b4de886SKip Macy 6459b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2) 6464af83c8cSKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, sr_edc[i], 6474af83c8cSKip Macy sr_edc[i + 1]); 6489b4de886SKip Macy if (!err) 6499b4de886SKip Macy phy->priv = edc_sr; 6504af83c8cSKip Macy return err; 6514af83c8cSKip Macy } 6524af83c8cSKip Macy 6539b4de886SKip Macy static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype) 6549b4de886SKip Macy { 6559b4de886SKip Macy static struct reg_val regs[] = { 6569b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5a00 }, 6579b4de886SKip Macy { 0, 0, 0, 0 } 6589b4de886SKip Macy }; 6599b4de886SKip Macy static struct reg_val preemphasis[] = { 6609b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc014, 0xffff, 0xfe16 }, 6619b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc015, 0xffff, 0xa000 }, 6629b4de886SKip Macy { 0, 0, 0, 0 } 6639b4de886SKip Macy }; 6649b4de886SKip Macy static u16 twinax_edc[] = { 6659b4de886SKip Macy 0xcc00, 0x4009, 6669b4de886SKip Macy 0xcc01, 0x27ff, 6679b4de886SKip Macy 0xcc02, 0x300f, 6689b4de886SKip Macy 0xcc03, 0x40aa, 6699b4de886SKip Macy 0xcc04, 0x401c, 6709b4de886SKip Macy 0xcc05, 0x401e, 6719b4de886SKip Macy 0xcc06, 0x2ff4, 6729b4de886SKip Macy 0xcc07, 0x3cd4, 6739b4de886SKip Macy 0xcc08, 0x2035, 6749b4de886SKip Macy 0xcc09, 0x3145, 6759b4de886SKip Macy 0xcc0a, 0x6524, 6769b4de886SKip Macy 0xcc0b, 0x26a2, 6779b4de886SKip Macy 0xcc0c, 0x3012, 6789b4de886SKip Macy 0xcc0d, 0x1002, 6799b4de886SKip Macy 0xcc0e, 0x29c2, 6809b4de886SKip Macy 0xcc0f, 0x3002, 6819b4de886SKip Macy 0xcc10, 0x1002, 6829b4de886SKip Macy 0xcc11, 0x2072, 6839b4de886SKip Macy 0xcc12, 0x3012, 6849b4de886SKip Macy 0xcc13, 0x1002, 6859b4de886SKip Macy 0xcc14, 0x22cd, 6869b4de886SKip Macy 0xcc15, 0x301d, 6879b4de886SKip Macy 0xcc16, 0x2e52, 6889b4de886SKip Macy 0xcc17, 0x3012, 6899b4de886SKip Macy 0xcc18, 0x1002, 6909b4de886SKip Macy 0xcc19, 0x28e2, 6919b4de886SKip Macy 0xcc1a, 0x3002, 6929b4de886SKip Macy 0xcc1b, 0x1002, 6939b4de886SKip Macy 0xcc1c, 0x628f, 6949b4de886SKip Macy 0xcc1d, 0x2ac2, 6959b4de886SKip Macy 0xcc1e, 0x3012, 6969b4de886SKip Macy 0xcc1f, 0x1002, 6979b4de886SKip Macy 0xcc20, 0x5553, 6989b4de886SKip Macy 0xcc21, 0x2ae2, 6999b4de886SKip Macy 0xcc22, 0x3002, 7009b4de886SKip Macy 0xcc23, 0x1302, 7019b4de886SKip Macy 0xcc24, 0x401e, 7029b4de886SKip Macy 0xcc25, 0x2be2, 7039b4de886SKip Macy 0xcc26, 0x3012, 7049b4de886SKip Macy 0xcc27, 0x1002, 7059b4de886SKip Macy 0xcc28, 0x2da2, 7069b4de886SKip Macy 0xcc29, 0x3012, 7079b4de886SKip Macy 0xcc2a, 0x1002, 7089b4de886SKip Macy 0xcc2b, 0x2ba2, 7099b4de886SKip Macy 0xcc2c, 0x3002, 7109b4de886SKip Macy 0xcc2d, 0x1002, 7119b4de886SKip Macy 0xcc2e, 0x5ee3, 7129b4de886SKip Macy 0xcc2f, 0x305, 7139b4de886SKip Macy 0xcc30, 0x400e, 7149b4de886SKip Macy 0xcc31, 0x2bc2, 7159b4de886SKip Macy 0xcc32, 0x3002, 7169b4de886SKip Macy 0xcc33, 0x1002, 7179b4de886SKip Macy 0xcc34, 0x2b82, 7189b4de886SKip Macy 0xcc35, 0x3012, 7199b4de886SKip Macy 0xcc36, 0x1002, 7209b4de886SKip Macy 0xcc37, 0x5663, 7219b4de886SKip Macy 0xcc38, 0x302, 7229b4de886SKip Macy 0xcc39, 0x401e, 7239b4de886SKip Macy 0xcc3a, 0x6f72, 7249b4de886SKip Macy 0xcc3b, 0x1002, 7259b4de886SKip Macy 0xcc3c, 0x628f, 7269b4de886SKip Macy 0xcc3d, 0x2be2, 7279b4de886SKip Macy 0xcc3e, 0x3012, 7289b4de886SKip Macy 0xcc3f, 0x1002, 7299b4de886SKip Macy 0xcc40, 0x22cd, 7309b4de886SKip Macy 0xcc41, 0x301d, 7319b4de886SKip Macy 0xcc42, 0x2e52, 7329b4de886SKip Macy 0xcc43, 0x3012, 7339b4de886SKip Macy 0xcc44, 0x1002, 7349b4de886SKip Macy 0xcc45, 0x2522, 7359b4de886SKip Macy 0xcc46, 0x3012, 7369b4de886SKip Macy 0xcc47, 0x1002, 7379b4de886SKip Macy 0xcc48, 0x2da2, 7389b4de886SKip Macy 0xcc49, 0x3012, 7399b4de886SKip Macy 0xcc4a, 0x1002, 7409b4de886SKip Macy 0xcc4b, 0x2ca2, 7419b4de886SKip Macy 0xcc4c, 0x3012, 7429b4de886SKip Macy 0xcc4d, 0x1002, 7439b4de886SKip Macy 0xcc4e, 0x2fa4, 7449b4de886SKip Macy 0xcc4f, 0x3cd4, 7459b4de886SKip Macy 0xcc50, 0x6624, 7469b4de886SKip Macy 0xcc51, 0x410b, 7479b4de886SKip Macy 0xcc52, 0x56b3, 7489b4de886SKip Macy 0xcc53, 0x3c4, 7499b4de886SKip Macy 0xcc54, 0x2fb2, 7509b4de886SKip Macy 0xcc55, 0x3002, 7519b4de886SKip Macy 0xcc56, 0x1002, 7529b4de886SKip Macy 0xcc57, 0x220b, 7539b4de886SKip Macy 0xcc58, 0x303b, 7549b4de886SKip Macy 0xcc59, 0x56b3, 7559b4de886SKip Macy 0xcc5a, 0x3c3, 7569b4de886SKip Macy 0xcc5b, 0x866b, 7579b4de886SKip Macy 0xcc5c, 0x400c, 7589b4de886SKip Macy 0xcc5d, 0x23a2, 7599b4de886SKip Macy 0xcc5e, 0x3012, 7609b4de886SKip Macy 0xcc5f, 0x1002, 7619b4de886SKip Macy 0xcc60, 0x2da2, 7629b4de886SKip Macy 0xcc61, 0x3012, 7639b4de886SKip Macy 0xcc62, 0x1002, 7649b4de886SKip Macy 0xcc63, 0x2ca2, 7659b4de886SKip Macy 0xcc64, 0x3012, 7669b4de886SKip Macy 0xcc65, 0x1002, 7679b4de886SKip Macy 0xcc66, 0x2fb4, 7689b4de886SKip Macy 0xcc67, 0x3cd4, 7699b4de886SKip Macy 0xcc68, 0x6624, 7709b4de886SKip Macy 0xcc69, 0x56b3, 7719b4de886SKip Macy 0xcc6a, 0x3c3, 7729b4de886SKip Macy 0xcc6b, 0x866b, 7739b4de886SKip Macy 0xcc6c, 0x401c, 7749b4de886SKip Macy 0xcc6d, 0x2205, 7759b4de886SKip Macy 0xcc6e, 0x3035, 7769b4de886SKip Macy 0xcc6f, 0x5b53, 7779b4de886SKip Macy 0xcc70, 0x2c52, 7789b4de886SKip Macy 0xcc71, 0x3002, 7799b4de886SKip Macy 0xcc72, 0x13c2, 7809b4de886SKip Macy 0xcc73, 0x5cc3, 7819b4de886SKip Macy 0xcc74, 0x317, 7829b4de886SKip Macy 0xcc75, 0x2522, 7839b4de886SKip Macy 0xcc76, 0x3012, 7849b4de886SKip Macy 0xcc77, 0x1002, 7859b4de886SKip Macy 0xcc78, 0x2da2, 7869b4de886SKip Macy 0xcc79, 0x3012, 7879b4de886SKip Macy 0xcc7a, 0x1002, 7889b4de886SKip Macy 0xcc7b, 0x2b82, 7899b4de886SKip Macy 0xcc7c, 0x3012, 7909b4de886SKip Macy 0xcc7d, 0x1002, 7919b4de886SKip Macy 0xcc7e, 0x5663, 7929b4de886SKip Macy 0xcc7f, 0x303, 7939b4de886SKip Macy 0xcc80, 0x401e, 7949b4de886SKip Macy 0xcc81, 0x004, 7959b4de886SKip Macy 0xcc82, 0x2c42, 7969b4de886SKip Macy 0xcc83, 0x3012, 7979b4de886SKip Macy 0xcc84, 0x1002, 7989b4de886SKip Macy 0xcc85, 0x6f72, 7999b4de886SKip Macy 0xcc86, 0x1002, 8009b4de886SKip Macy 0xcc87, 0x628f, 8019b4de886SKip Macy 0xcc88, 0x2304, 8029b4de886SKip Macy 0xcc89, 0x3c84, 8039b4de886SKip Macy 0xcc8a, 0x6436, 8049b4de886SKip Macy 0xcc8b, 0xdff4, 8059b4de886SKip Macy 0xcc8c, 0x6436, 8069b4de886SKip Macy 0xcc8d, 0x2ff5, 8079b4de886SKip Macy 0xcc8e, 0x3005, 8089b4de886SKip Macy 0xcc8f, 0x8656, 8099b4de886SKip Macy 0xcc90, 0xdfba, 8109b4de886SKip Macy 0xcc91, 0x56a3, 8119b4de886SKip Macy 0xcc92, 0xd05a, 8129b4de886SKip Macy 0xcc93, 0x21c2, 8139b4de886SKip Macy 0xcc94, 0x3012, 8149b4de886SKip Macy 0xcc95, 0x1392, 8159b4de886SKip Macy 0xcc96, 0xd05a, 8169b4de886SKip Macy 0xcc97, 0x56a3, 8179b4de886SKip Macy 0xcc98, 0xdfba, 8189b4de886SKip Macy 0xcc99, 0x383, 8199b4de886SKip Macy 0xcc9a, 0x6f72, 8209b4de886SKip Macy 0xcc9b, 0x1002, 8219b4de886SKip Macy 0xcc9c, 0x28c5, 8229b4de886SKip Macy 0xcc9d, 0x3005, 8239b4de886SKip Macy 0xcc9e, 0x4178, 8249b4de886SKip Macy 0xcc9f, 0x5653, 8259b4de886SKip Macy 0xcca0, 0x384, 8269b4de886SKip Macy 0xcca1, 0x22b2, 8279b4de886SKip Macy 0xcca2, 0x3012, 8289b4de886SKip Macy 0xcca3, 0x1002, 8299b4de886SKip Macy 0xcca4, 0x2be5, 8309b4de886SKip Macy 0xcca5, 0x3005, 8319b4de886SKip Macy 0xcca6, 0x41e8, 8329b4de886SKip Macy 0xcca7, 0x5653, 8339b4de886SKip Macy 0xcca8, 0x382, 8349b4de886SKip Macy 0xcca9, 0x002, 8359b4de886SKip Macy 0xccaa, 0x4258, 8369b4de886SKip Macy 0xccab, 0x2474, 8379b4de886SKip Macy 0xccac, 0x3c84, 8389b4de886SKip Macy 0xccad, 0x6437, 8399b4de886SKip Macy 0xccae, 0xdff4, 8409b4de886SKip Macy 0xccaf, 0x6437, 8419b4de886SKip Macy 0xccb0, 0x2ff5, 8429b4de886SKip Macy 0xccb1, 0x3c05, 8439b4de886SKip Macy 0xccb2, 0x8757, 8449b4de886SKip Macy 0xccb3, 0xb888, 8459b4de886SKip Macy 0xccb4, 0x9787, 8469b4de886SKip Macy 0xccb5, 0xdff4, 8479b4de886SKip Macy 0xccb6, 0x6724, 8489b4de886SKip Macy 0xccb7, 0x866a, 8499b4de886SKip Macy 0xccb8, 0x6f72, 8509b4de886SKip Macy 0xccb9, 0x1002, 8519b4de886SKip Macy 0xccba, 0x2d01, 8529b4de886SKip Macy 0xccbb, 0x3011, 8539b4de886SKip Macy 0xccbc, 0x1001, 8549b4de886SKip Macy 0xccbd, 0xc620, 8559b4de886SKip Macy 0xccbe, 0x14e5, 8569b4de886SKip Macy 0xccbf, 0xc621, 8579b4de886SKip Macy 0xccc0, 0xc53d, 8589b4de886SKip Macy 0xccc1, 0xc622, 8599b4de886SKip Macy 0xccc2, 0x3cbe, 8609b4de886SKip Macy 0xccc3, 0xc623, 8619b4de886SKip Macy 0xccc4, 0x4452, 8629b4de886SKip Macy 0xccc5, 0xc624, 8639b4de886SKip Macy 0xccc6, 0xc5c5, 8649b4de886SKip Macy 0xccc7, 0xc625, 8659b4de886SKip Macy 0xccc8, 0xe01e, 8669b4de886SKip Macy 0xccc9, 0xc627, 8679b4de886SKip Macy 0xccca, 0x000, 8689b4de886SKip Macy 0xcccb, 0xc628, 8699b4de886SKip Macy 0xcccc, 0x000, 8709b4de886SKip Macy 0xcccd, 0xc62b, 8719b4de886SKip Macy 0xccce, 0x000, 8729b4de886SKip Macy 0xcccf, 0xc62c, 8739b4de886SKip Macy 0xccd0, 0x000, 8749b4de886SKip Macy 0xccd1, 0x000, 8759b4de886SKip Macy 0xccd2, 0x2d01, 8769b4de886SKip Macy 0xccd3, 0x3011, 8779b4de886SKip Macy 0xccd4, 0x1001, 8789b4de886SKip Macy 0xccd5, 0xc620, 8799b4de886SKip Macy 0xccd6, 0x000, 8809b4de886SKip Macy 0xccd7, 0xc621, 8819b4de886SKip Macy 0xccd8, 0x000, 8829b4de886SKip Macy 0xccd9, 0xc622, 8839b4de886SKip Macy 0xccda, 0x0ce, 8849b4de886SKip Macy 0xccdb, 0xc623, 8859b4de886SKip Macy 0xccdc, 0x07f, 8869b4de886SKip Macy 0xccdd, 0xc624, 8879b4de886SKip Macy 0xccde, 0x032, 8889b4de886SKip Macy 0xccdf, 0xc625, 8899b4de886SKip Macy 0xcce0, 0x000, 8909b4de886SKip Macy 0xcce1, 0xc627, 8919b4de886SKip Macy 0xcce2, 0x000, 8929b4de886SKip Macy 0xcce3, 0xc628, 8939b4de886SKip Macy 0xcce4, 0x000, 8949b4de886SKip Macy 0xcce5, 0xc62b, 8959b4de886SKip Macy 0xcce6, 0x000, 8969b4de886SKip Macy 0xcce7, 0xc62c, 8979b4de886SKip Macy 0xcce8, 0x000, 8989b4de886SKip Macy 0xcce9, 0x000, 8999b4de886SKip Macy 0xccea, 0x2d01, 9009b4de886SKip Macy 0xcceb, 0x3011, 9019b4de886SKip Macy 0xccec, 0x1001, 9029b4de886SKip Macy 0xcced, 0xc502, 9039b4de886SKip Macy 0xccee, 0x609f, 9049b4de886SKip Macy 0xccef, 0xc600, 9059b4de886SKip Macy 0xccf0, 0x2a6e, 9069b4de886SKip Macy 0xccf1, 0xc601, 9079b4de886SKip Macy 0xccf2, 0x2a2c, 9089b4de886SKip Macy 0xccf3, 0xc60c, 9099b4de886SKip Macy 0xccf4, 0x5400, 9109b4de886SKip Macy 0xccf5, 0xc710, 9119b4de886SKip Macy 0xccf6, 0x700, 9129b4de886SKip Macy 0xccf7, 0xc718, 9139b4de886SKip Macy 0xccf8, 0x700, 9149b4de886SKip Macy 0xccf9, 0xc720, 9159b4de886SKip Macy 0xccfa, 0x4700, 9169b4de886SKip Macy 0xccfb, 0xc728, 9179b4de886SKip Macy 0xccfc, 0x700, 9189b4de886SKip Macy 0xccfd, 0xc729, 9199b4de886SKip Macy 0xccfe, 0x1207, 9209b4de886SKip Macy 0xccff, 0xc801, 9219b4de886SKip Macy 0xcd00, 0x7f50, 9229b4de886SKip Macy 0xcd01, 0xc802, 9239b4de886SKip Macy 0xcd02, 0x7760, 9249b4de886SKip Macy 0xcd03, 0xc803, 9259b4de886SKip Macy 0xcd04, 0x7fce, 9269b4de886SKip Macy 0xcd05, 0xc804, 9279b4de886SKip Macy 0xcd06, 0x520e, 9289b4de886SKip Macy 0xcd07, 0xc805, 9299b4de886SKip Macy 0xcd08, 0x5c11, 9309b4de886SKip Macy 0xcd09, 0xc806, 9319b4de886SKip Macy 0xcd0a, 0x3c51, 9329b4de886SKip Macy 0xcd0b, 0xc807, 9339b4de886SKip Macy 0xcd0c, 0x4061, 9349b4de886SKip Macy 0xcd0d, 0xc808, 9359b4de886SKip Macy 0xcd0e, 0x49c1, 9369b4de886SKip Macy 0xcd0f, 0xc809, 9379b4de886SKip Macy 0xcd10, 0x3840, 9389b4de886SKip Macy 0xcd11, 0xc80a, 9399b4de886SKip Macy 0xcd12, 0x000, 9409b4de886SKip Macy 0xcd13, 0xc821, 9419b4de886SKip Macy 0xcd14, 0x002, 9429b4de886SKip Macy 0xcd15, 0xc822, 9439b4de886SKip Macy 0xcd16, 0x046, 9449b4de886SKip Macy 0xcd17, 0xc844, 9459b4de886SKip Macy 0xcd18, 0x182f, 9469b4de886SKip Macy 0xcd19, 0xc013, 9479b4de886SKip Macy 0xcd1a, 0xf341, 9489b4de886SKip Macy 0xcd1b, 0xc01a, 9499b4de886SKip Macy 0xcd1c, 0x446, 9509b4de886SKip Macy 0xcd1d, 0xc024, 9519b4de886SKip Macy 0xcd1e, 0x1000, 9529b4de886SKip Macy 0xcd1f, 0xc025, 9539b4de886SKip Macy 0xcd20, 0xa00, 9549b4de886SKip Macy 0xcd21, 0xc026, 9559b4de886SKip Macy 0xcd22, 0xc0c, 9569b4de886SKip Macy 0xcd23, 0xc027, 9579b4de886SKip Macy 0xcd24, 0xc0c, 9589b4de886SKip Macy 0xcd25, 0xc029, 9599b4de886SKip Macy 0xcd26, 0x0a0, 9609b4de886SKip Macy 0xcd27, 0xc030, 9619b4de886SKip Macy 0xcd28, 0xa00, 9629b4de886SKip Macy 0xcd29, 0xc03c, 9639b4de886SKip Macy 0xcd2a, 0x01c, 9649b4de886SKip Macy 0xcd2b, 0x000, 9659b4de886SKip Macy 0xcd2c, 0x2b84, 9669b4de886SKip Macy 0xcd2d, 0x3c74, 9679b4de886SKip Macy 0xcd2e, 0x6435, 9689b4de886SKip Macy 0xcd2f, 0xdff4, 9699b4de886SKip Macy 0xcd30, 0x6435, 9709b4de886SKip Macy 0xcd31, 0x2806, 9719b4de886SKip Macy 0xcd32, 0x3006, 9729b4de886SKip Macy 0xcd33, 0x8565, 9739b4de886SKip Macy 0xcd34, 0x2b24, 9749b4de886SKip Macy 0xcd35, 0x3c24, 9759b4de886SKip Macy 0xcd36, 0x6436, 9769b4de886SKip Macy 0xcd37, 0x1002, 9779b4de886SKip Macy 0xcd38, 0x2b24, 9789b4de886SKip Macy 0xcd39, 0x3c24, 9799b4de886SKip Macy 0xcd3a, 0x6436, 9809b4de886SKip Macy 0xcd3b, 0x4045, 9819b4de886SKip Macy 0xcd3c, 0x8656, 9829b4de886SKip Macy 0xcd3d, 0x1002, 9839b4de886SKip Macy 0xcd3e, 0x2807, 9849b4de886SKip Macy 0xcd3f, 0x31a7, 9859b4de886SKip Macy 0xcd40, 0x20c4, 9869b4de886SKip Macy 0xcd41, 0x3c24, 9879b4de886SKip Macy 0xcd42, 0x6724, 9889b4de886SKip Macy 0xcd43, 0x1002, 9899b4de886SKip Macy 0xcd44, 0x2807, 9909b4de886SKip Macy 0xcd45, 0x3187, 9919b4de886SKip Macy 0xcd46, 0x20c4, 9929b4de886SKip Macy 0xcd47, 0x3c24, 9939b4de886SKip Macy 0xcd48, 0x6724, 9949b4de886SKip Macy 0xcd49, 0x1002, 9959b4de886SKip Macy 0xcd4a, 0x2514, 9969b4de886SKip Macy 0xcd4b, 0x3c64, 9979b4de886SKip Macy 0xcd4c, 0x6436, 9989b4de886SKip Macy 0xcd4d, 0xdff4, 9999b4de886SKip Macy 0xcd4e, 0x6436, 10009b4de886SKip Macy 0xcd4f, 0x1002, 10019b4de886SKip Macy 0xcd50, 0x2806, 10029b4de886SKip Macy 0xcd51, 0x3cb6, 10039b4de886SKip Macy 0xcd52, 0xc161, 10049b4de886SKip Macy 0xcd53, 0x6134, 10059b4de886SKip Macy 0xcd54, 0x6135, 10069b4de886SKip Macy 0xcd55, 0x5443, 10079b4de886SKip Macy 0xcd56, 0x303, 10089b4de886SKip Macy 0xcd57, 0x6524, 10099b4de886SKip Macy 0xcd58, 0x00b, 10109b4de886SKip Macy 0xcd59, 0x1002, 10119b4de886SKip Macy 0xcd5a, 0xd019, 10129b4de886SKip Macy 0xcd5b, 0x2104, 10139b4de886SKip Macy 0xcd5c, 0x3c24, 10149b4de886SKip Macy 0xcd5d, 0x2105, 10159b4de886SKip Macy 0xcd5e, 0x3805, 10169b4de886SKip Macy 0xcd5f, 0x6524, 10179b4de886SKip Macy 0xcd60, 0xdff4, 10189b4de886SKip Macy 0xcd61, 0x4005, 10199b4de886SKip Macy 0xcd62, 0x6524, 10209b4de886SKip Macy 0xcd63, 0x2e8d, 10219b4de886SKip Macy 0xcd64, 0x303d, 10229b4de886SKip Macy 0xcd65, 0x5dd3, 10239b4de886SKip Macy 0xcd66, 0x306, 10249b4de886SKip Macy 0xcd67, 0x2ff7, 10259b4de886SKip Macy 0xcd68, 0x38f7, 10269b4de886SKip Macy 0xcd69, 0x60b7, 10279b4de886SKip Macy 0xcd6a, 0xdffd, 10289b4de886SKip Macy 0xcd6b, 0x00a, 10299b4de886SKip Macy 0xcd6c, 0x1002, 10309b4de886SKip Macy 0xcd6d, 0 10319b4de886SKip Macy }; 10329b4de886SKip Macy int i, err; 10339b4de886SKip Macy 10349b4de886SKip Macy err = set_phy_regs(phy, regs); 10359b4de886SKip Macy if (!err && modtype == phy_modtype_twinax_long) 10369b4de886SKip Macy err = set_phy_regs(phy, preemphasis); 10379b4de886SKip Macy if (err) 10389b4de886SKip Macy return err; 10399b4de886SKip Macy 10409b4de886SKip Macy msleep(50); 10419b4de886SKip Macy 10429b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2) 10439b4de886SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i], 10449b4de886SKip Macy twinax_edc[i + 1]); 10459b4de886SKip Macy if (!err) 10469b4de886SKip Macy phy->priv = edc_twinax; 10479b4de886SKip Macy return err; 10489b4de886SKip Macy } 10499b4de886SKip Macy 10509b4de886SKip Macy static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr) 10519b4de886SKip Macy { 10529b4de886SKip Macy int i, err; 10539b4de886SKip Macy unsigned int stat, data; 10549b4de886SKip Macy 10559b4de886SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, 10569b4de886SKip Macy (dev_addr << 8) | (1 << 8) | word_addr); 10579b4de886SKip Macy if (err) 10589b4de886SKip Macy return err; 10599b4de886SKip Macy 10609b4de886SKip Macy for (i = 0; i < 5; i++) { 10619b4de886SKip Macy msleep(1); 10629b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); 10639b4de886SKip Macy if (err) 10649b4de886SKip Macy return err; 10659b4de886SKip Macy if ((stat & 3) == 1) { 10669b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, 10679b4de886SKip Macy &data); 10689b4de886SKip Macy if (err) 10699b4de886SKip Macy return err; 10709b4de886SKip Macy return data >> 8; 10719b4de886SKip Macy } 10729b4de886SKip Macy } 10739b4de886SKip Macy CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n", 10749b4de886SKip Macy phy->addr, word_addr); 10759b4de886SKip Macy return -ETIMEDOUT; 10769b4de886SKip Macy } 10779b4de886SKip Macy 1078837f41b0SGeorge V. Neville-Neil static int ael2005_get_module_type(struct cphy *phy, int delay_ms) 10799b4de886SKip Macy { 10809b4de886SKip Macy int v; 10819b4de886SKip Macy unsigned int stat; 10829b4de886SKip Macy 10839b4de886SKip Macy v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat); 10849b4de886SKip Macy if (v) 10859b4de886SKip Macy return v; 10869b4de886SKip Macy 10879b4de886SKip Macy if (stat & (1 << 8)) /* module absent */ 10889b4de886SKip Macy return phy_modtype_none; 10899b4de886SKip Macy 10909b4de886SKip Macy if (delay_ms) 10919b4de886SKip Macy msleep(delay_ms); 10929b4de886SKip Macy 1093837f41b0SGeorge V. Neville-Neil return get_module_type(phy, 0); 10949b4de886SKip Macy 10959b4de886SKip Macy } 10969b4de886SKip Macy 10979b4de886SKip Macy static int ael2005_intr_enable(struct cphy *phy) 10989b4de886SKip Macy { 10999b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200); 11009b4de886SKip Macy return err ? err : t3_phy_lasi_intr_enable(phy); 11019b4de886SKip Macy } 11029b4de886SKip Macy 11039b4de886SKip Macy static int ael2005_intr_disable(struct cphy *phy) 11049b4de886SKip Macy { 11059b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x100); 11069b4de886SKip Macy return err ? err : t3_phy_lasi_intr_disable(phy); 11079b4de886SKip Macy } 11089b4de886SKip Macy 11099b4de886SKip Macy static int ael2005_intr_clear(struct cphy *phy) 11109b4de886SKip Macy { 11119b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0xd00); 11129b4de886SKip Macy return err ? err : t3_phy_lasi_intr_clear(phy); 11139b4de886SKip Macy } 11149b4de886SKip Macy 11154af83c8cSKip Macy static int ael2005_reset(struct cphy *phy, int wait) 11164af83c8cSKip Macy { 11174af83c8cSKip Macy static struct reg_val regs0[] = { 11184af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc001, 0, 1 << 5 }, 11194af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc017, 0, 1 << 5 }, 11204af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc013, 0xffff, 0xf341 }, 11214af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, 11224af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8100 }, 11234af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, 11244af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0 }, 11254af83c8cSKip Macy { 0, 0, 0, 0 } 11264af83c8cSKip Macy }; 11274af83c8cSKip Macy static struct reg_val regs1[] = { 11284af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca00, 0xffff, 0x0080 }, 11294af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0 }, 11304af83c8cSKip Macy { 0, 0, 0, 0 } 11314af83c8cSKip Macy }; 11324af83c8cSKip Macy 11339b4de886SKip Macy int err, lasi_ctrl; 11349b4de886SKip Macy 11359b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl); 11369b4de886SKip Macy if (err) 11379b4de886SKip Macy return err; 11384af83c8cSKip Macy 11394af83c8cSKip Macy err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 0); 11404af83c8cSKip Macy if (err) 11414af83c8cSKip Macy return err; 11424af83c8cSKip Macy 11434af83c8cSKip Macy msleep(125); 11449b4de886SKip Macy phy->priv = edc_none; 11454af83c8cSKip Macy err = set_phy_regs(phy, regs0); 11464af83c8cSKip Macy if (err) 11474af83c8cSKip Macy return err; 11484af83c8cSKip Macy 11494af83c8cSKip Macy msleep(50); 11504af83c8cSKip Macy 1151837f41b0SGeorge V. Neville-Neil err = ael2005_get_module_type(phy, 0); 11529b4de886SKip Macy if (err < 0) 11539b4de886SKip Macy return err; 11549b4de886SKip Macy phy->modtype = (u8)err; 11559b4de886SKip Macy 11569b4de886SKip Macy if (err == phy_modtype_twinax || err == phy_modtype_twinax_long) 11579b4de886SKip Macy err = ael2005_setup_twinax_edc(phy, err); 11589b4de886SKip Macy else 11594af83c8cSKip Macy err = ael2005_setup_sr_edc(phy); 11604af83c8cSKip Macy if (err) 11614af83c8cSKip Macy return err; 11624af83c8cSKip Macy 11639b4de886SKip Macy err = set_phy_regs(phy, regs1); 11649b4de886SKip Macy if (err) 11659b4de886SKip Macy return err; 11669b4de886SKip Macy 11679b4de886SKip Macy /* reset wipes out interrupts, reenable them if they were on */ 11689b4de886SKip Macy if (lasi_ctrl & 1) 11699b4de886SKip Macy err = ael2005_intr_enable(phy); 11709b4de886SKip Macy return err; 11719b4de886SKip Macy } 11729b4de886SKip Macy 11739b4de886SKip Macy static int ael2005_intr_handler(struct cphy *phy) 11749b4de886SKip Macy { 11759b4de886SKip Macy unsigned int stat; 11769b4de886SKip Macy int ret, edc_needed, cause = 0; 11779b4de886SKip Macy 11789b4de886SKip Macy ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_STAT, &stat); 11799b4de886SKip Macy if (ret) 11809b4de886SKip Macy return ret; 11819b4de886SKip Macy 11829b4de886SKip Macy if (stat & AEL2005_MODDET_IRQ) { 11839b4de886SKip Macy ret = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 11849b4de886SKip Macy 0xd00); 11859b4de886SKip Macy if (ret) 11869b4de886SKip Macy return ret; 11879b4de886SKip Macy 11889b4de886SKip Macy /* modules have max 300 ms init time after hot plug */ 1189837f41b0SGeorge V. Neville-Neil ret = ael2005_get_module_type(phy, 300); 11909b4de886SKip Macy if (ret < 0) 11919b4de886SKip Macy return ret; 11929b4de886SKip Macy 11939b4de886SKip Macy phy->modtype = (u8)ret; 11949b4de886SKip Macy if (ret == phy_modtype_none) 11959b4de886SKip Macy edc_needed = phy->priv; /* on unplug retain EDC */ 11969b4de886SKip Macy else if (ret == phy_modtype_twinax || 11979b4de886SKip Macy ret == phy_modtype_twinax_long) 11989b4de886SKip Macy edc_needed = edc_twinax; 11999b4de886SKip Macy else 12009b4de886SKip Macy edc_needed = edc_sr; 12019b4de886SKip Macy 12029b4de886SKip Macy if (edc_needed != phy->priv) { 12039b4de886SKip Macy ret = ael2005_reset(phy, 0); 12049b4de886SKip Macy return ret ? ret : cphy_cause_module_change; 12059b4de886SKip Macy } 12069b4de886SKip Macy cause = cphy_cause_module_change; 12079b4de886SKip Macy } 12089b4de886SKip Macy 12099b4de886SKip Macy ret = t3_phy_lasi_intr_handler(phy); 12109b4de886SKip Macy return ret < 0 ? ret : ret + cause; 12114af83c8cSKip Macy } 12124af83c8cSKip Macy 12134af83c8cSKip Macy #ifdef C99_NOT_SUPPORTED 12144af83c8cSKip Macy static struct cphy_ops ael2005_ops = { 12154af83c8cSKip Macy ael2005_reset, 12169b4de886SKip Macy ael2005_intr_enable, 12179b4de886SKip Macy ael2005_intr_disable, 12189b4de886SKip Macy ael2005_intr_clear, 12199b4de886SKip Macy ael2005_intr_handler, 12204af83c8cSKip Macy NULL, 12214af83c8cSKip Macy NULL, 12224af83c8cSKip Macy NULL, 12234af83c8cSKip Macy NULL, 12244af83c8cSKip Macy NULL, 12259b4de886SKip Macy get_link_status_r, 12264af83c8cSKip Macy ael1002_power_down, 12274af83c8cSKip Macy }; 12284af83c8cSKip Macy #else 12294af83c8cSKip Macy static struct cphy_ops ael2005_ops = { 12304af83c8cSKip Macy .reset = ael2005_reset, 12319b4de886SKip Macy .intr_enable = ael2005_intr_enable, 12329b4de886SKip Macy .intr_disable = ael2005_intr_disable, 12339b4de886SKip Macy .intr_clear = ael2005_intr_clear, 12349b4de886SKip Macy .intr_handler = ael2005_intr_handler, 12359b4de886SKip Macy .get_link_status = get_link_status_r, 12364af83c8cSKip Macy .power_down = ael1002_power_down, 12374af83c8cSKip Macy }; 12384af83c8cSKip Macy #endif 12394af83c8cSKip Macy 12404af83c8cSKip Macy int t3_ael2005_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 12414af83c8cSKip Macy const struct mdio_ops *mdio_ops) 12424af83c8cSKip Macy { 1243837f41b0SGeorge V. Neville-Neil int err; 12444af83c8cSKip Macy cphy_init(phy, adapter, phy_addr, &ael2005_ops, mdio_ops, 12459b4de886SKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE | 12469b4de886SKip Macy SUPPORTED_IRQ, "10GBASE-R"); 12474af83c8cSKip Macy msleep(125); 1248837f41b0SGeorge V. Neville-Neil 1249837f41b0SGeorge V. Neville-Neil err = ael2005_get_module_type(phy, 0); 1250837f41b0SGeorge V. Neville-Neil if (err >= 0) 1251837f41b0SGeorge V. Neville-Neil phy->modtype = err; 1252837f41b0SGeorge V. Neville-Neil 12534af83c8cSKip Macy return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL_OPT_SETTINGS, 0, 12544af83c8cSKip Macy 1 << 5); 12554af83c8cSKip Macy } 12564af83c8cSKip Macy 12579b4de886SKip Macy /* 12589b4de886SKip Macy * Get link status for a 10GBASE-X device. 12599b4de886SKip Macy */ 12609b4de886SKip Macy static int get_link_status_x(struct cphy *phy, int *link_ok, int *speed, 12619b4de886SKip Macy int *duplex, int *fc) 12629b4de886SKip Macy { 12639b4de886SKip Macy if (link_ok) { 12649b4de886SKip Macy unsigned int stat0, stat1, stat2; 12659b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); 12669b4de886SKip Macy 12679b4de886SKip Macy if (!err) 12689b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_X, &stat1); 12699b4de886SKip Macy if (!err) 12709b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); 12719b4de886SKip Macy if (err) 12729b4de886SKip Macy return err; 12739b4de886SKip Macy *link_ok = (stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1; 12749b4de886SKip Macy } 12759b4de886SKip Macy if (speed) 12769b4de886SKip Macy *speed = SPEED_10000; 12779b4de886SKip Macy if (duplex) 12789b4de886SKip Macy *duplex = DUPLEX_FULL; 12799b4de886SKip Macy return 0; 12809b4de886SKip Macy } 12819b4de886SKip Macy 1282b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 1283b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = { 1284b6d90eb7SKip Macy ael1006_reset, 12854af83c8cSKip Macy t3_phy_lasi_intr_enable, 12864af83c8cSKip Macy t3_phy_lasi_intr_disable, 12874af83c8cSKip Macy t3_phy_lasi_intr_clear, 12884af83c8cSKip Macy t3_phy_lasi_intr_handler, 1289b6d90eb7SKip Macy NULL, 1290b6d90eb7SKip Macy NULL, 1291b6d90eb7SKip Macy NULL, 1292b6d90eb7SKip Macy NULL, 1293b6d90eb7SKip Macy NULL, 12949b4de886SKip Macy get_link_status_x, 1295b6d90eb7SKip Macy ael1006_power_down, 1296b6d90eb7SKip Macy }; 1297b6d90eb7SKip Macy #else 1298b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = { 1299b6d90eb7SKip Macy .reset = ael1006_reset, 13004af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable, 13014af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable, 13024af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear, 13034af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler, 13049b4de886SKip Macy .get_link_status = get_link_status_x, 1305b6d90eb7SKip Macy .power_down = ael1006_power_down, 1306b6d90eb7SKip Macy }; 1307b6d90eb7SKip Macy #endif 1308b6d90eb7SKip Macy 13098e10660fSKip Macy int t3_qt2045_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 1310b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 1311b6d90eb7SKip Macy { 1312b6d90eb7SKip Macy unsigned int stat; 1313b6d90eb7SKip Macy 13148e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &qt2045_ops, mdio_ops, 13158e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 13168e10660fSKip Macy "10GBASE-CX4"); 1317b6d90eb7SKip Macy 1318b6d90eb7SKip Macy /* 1319b6d90eb7SKip Macy * Some cards where the PHY is supposed to be at address 0 actually 1320b6d90eb7SKip Macy * have it at 1. 1321b6d90eb7SKip Macy */ 1322b6d90eb7SKip Macy if (!phy_addr && !mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, &stat) && 1323b6d90eb7SKip Macy stat == 0xffff) 1324b6d90eb7SKip Macy phy->addr = 1; 13258e10660fSKip Macy return 0; 1326b6d90eb7SKip Macy } 1327b6d90eb7SKip Macy 1328b6d90eb7SKip Macy static int xaui_direct_reset(struct cphy *phy, int wait) 1329b6d90eb7SKip Macy { 1330b6d90eb7SKip Macy return 0; 1331b6d90eb7SKip Macy } 1332b6d90eb7SKip Macy 1333b6d90eb7SKip Macy static int xaui_direct_get_link_status(struct cphy *phy, int *link_ok, 1334b6d90eb7SKip Macy int *speed, int *duplex, int *fc) 1335b6d90eb7SKip Macy { 1336b6d90eb7SKip Macy if (link_ok) { 1337b6d90eb7SKip Macy unsigned int status; 1338b6d90eb7SKip Macy 1339b6d90eb7SKip Macy status = t3_read_reg(phy->adapter, 1340ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT0, phy->addr)) | 1341ef72318fSKip Macy t3_read_reg(phy->adapter, 1342ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT1, phy->addr)) | 1343ef72318fSKip Macy t3_read_reg(phy->adapter, 1344ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT2, phy->addr)) | 1345ef72318fSKip Macy t3_read_reg(phy->adapter, 1346ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT3, phy->addr)); 1347b6d90eb7SKip Macy *link_ok = !(status & F_LOWSIG0); 1348b6d90eb7SKip Macy } 1349b6d90eb7SKip Macy if (speed) 1350b6d90eb7SKip Macy *speed = SPEED_10000; 1351b6d90eb7SKip Macy if (duplex) 1352b6d90eb7SKip Macy *duplex = DUPLEX_FULL; 1353b6d90eb7SKip Macy return 0; 1354b6d90eb7SKip Macy } 1355b6d90eb7SKip Macy 1356b6d90eb7SKip Macy static int xaui_direct_power_down(struct cphy *phy, int enable) 1357b6d90eb7SKip Macy { 1358b6d90eb7SKip Macy return 0; 1359b6d90eb7SKip Macy } 1360b6d90eb7SKip Macy 1361b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 1362b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = { 1363b6d90eb7SKip Macy xaui_direct_reset, 1364b6d90eb7SKip Macy ael1002_intr_noop, 1365b6d90eb7SKip Macy ael1002_intr_noop, 1366b6d90eb7SKip Macy ael1002_intr_noop, 1367b6d90eb7SKip Macy ael1002_intr_noop, 1368b6d90eb7SKip Macy NULL, 1369b6d90eb7SKip Macy NULL, 1370b6d90eb7SKip Macy NULL, 1371b6d90eb7SKip Macy NULL, 1372b6d90eb7SKip Macy NULL, 1373b6d90eb7SKip Macy xaui_direct_get_link_status, 1374b6d90eb7SKip Macy xaui_direct_power_down, 1375b6d90eb7SKip Macy }; 1376b6d90eb7SKip Macy #else 1377b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = { 1378b6d90eb7SKip Macy .reset = xaui_direct_reset, 1379b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop, 1380b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop, 1381b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop, 1382b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop, 1383b6d90eb7SKip Macy .get_link_status = xaui_direct_get_link_status, 1384b6d90eb7SKip Macy .power_down = xaui_direct_power_down, 1385b6d90eb7SKip Macy }; 1386b6d90eb7SKip Macy #endif 1387b6d90eb7SKip Macy 13888e10660fSKip Macy int t3_xaui_direct_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 1389b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 1390b6d90eb7SKip Macy { 13918e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops, 13928e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 13938e10660fSKip Macy "10GBASE-CX4"); 13948e10660fSKip Macy return 0; 1395b6d90eb7SKip Macy } 1396