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 744af83c8cSKip Macy static int set_phy_regs(struct cphy *phy, const struct reg_val *rv) 754af83c8cSKip Macy { 764af83c8cSKip Macy int err; 774af83c8cSKip Macy 784af83c8cSKip Macy for (err = 0; rv->mmd_addr && !err; rv++) { 794af83c8cSKip Macy if (rv->clear_bits == 0xffff) 804af83c8cSKip Macy err = mdio_write(phy, rv->mmd_addr, rv->reg_addr, 814af83c8cSKip Macy rv->set_bits); 824af83c8cSKip Macy else 834af83c8cSKip Macy err = t3_mdio_change_bits(phy, rv->mmd_addr, 844af83c8cSKip Macy rv->reg_addr, rv->clear_bits, 854af83c8cSKip Macy rv->set_bits); 864af83c8cSKip Macy } 874af83c8cSKip Macy return err; 884af83c8cSKip Macy } 894af83c8cSKip Macy 90b6d90eb7SKip Macy static void ael100x_txon(struct cphy *phy) 91b6d90eb7SKip Macy { 92b6d90eb7SKip Macy int tx_on_gpio = phy->addr == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL; 93b6d90eb7SKip Macy 948e10660fSKip Macy msleep(100); 95b6d90eb7SKip Macy t3_set_reg_field(phy->adapter, A_T3DBG_GPIO_EN, 0, tx_on_gpio); 968e10660fSKip Macy msleep(30); 97b6d90eb7SKip Macy } 98b6d90eb7SKip Macy 99b6d90eb7SKip Macy static int ael1002_power_down(struct cphy *phy, int enable) 100b6d90eb7SKip Macy { 101b6d90eb7SKip Macy int err; 102b6d90eb7SKip Macy 103b6d90eb7SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_DISABLE, !!enable); 104b6d90eb7SKip Macy if (!err) 105b6d90eb7SKip Macy err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 106b6d90eb7SKip Macy BMCR_PDOWN, enable ? BMCR_PDOWN : 0); 107b6d90eb7SKip Macy return err; 108b6d90eb7SKip Macy } 109b6d90eb7SKip Macy 110b6d90eb7SKip Macy static int ael1002_reset(struct cphy *phy, int wait) 111b6d90eb7SKip Macy { 112b6d90eb7SKip Macy int err; 113b6d90eb7SKip Macy 114b6d90eb7SKip Macy if ((err = ael1002_power_down(phy, 0)) || 115b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL100X_TX_CONFIG1, 1)) || 116b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_HI, 0)) || 117b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_PWR_DOWN_LO, 0)) || 118b6d90eb7SKip Macy (err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL1002_XFI_EQL, 0x18)) || 119b6d90eb7SKip Macy (err = t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL1002_LB_EN, 120b6d90eb7SKip Macy 0, 1 << 5))) 121b6d90eb7SKip Macy return err; 122b6d90eb7SKip Macy return 0; 123b6d90eb7SKip Macy } 124b6d90eb7SKip Macy 125b6d90eb7SKip Macy static int ael1002_intr_noop(struct cphy *phy) 126b6d90eb7SKip Macy { 127b6d90eb7SKip Macy return 0; 128b6d90eb7SKip Macy } 129b6d90eb7SKip Macy 1309b4de886SKip Macy /* 1319b4de886SKip Macy * Get link status for a 10GBASE-R device. 1329b4de886SKip Macy */ 1339b4de886SKip Macy static int get_link_status_r(struct cphy *phy, int *link_ok, int *speed, 1349b4de886SKip Macy int *duplex, int *fc) 135b6d90eb7SKip Macy { 136b6d90eb7SKip Macy if (link_ok) { 1379b4de886SKip Macy unsigned int stat0, stat1, stat2; 1389b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); 139b6d90eb7SKip Macy 1409b4de886SKip Macy if (!err) 1419b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_R, &stat1); 1429b4de886SKip Macy if (!err) 1439b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); 144b6d90eb7SKip Macy if (err) 145b6d90eb7SKip Macy return err; 1469b4de886SKip Macy *link_ok = (stat0 & stat1 & (stat2 >> 12)) & 1; 147b6d90eb7SKip Macy } 148b6d90eb7SKip Macy if (speed) 149b6d90eb7SKip Macy *speed = SPEED_10000; 150b6d90eb7SKip Macy if (duplex) 151b6d90eb7SKip Macy *duplex = DUPLEX_FULL; 152b6d90eb7SKip Macy return 0; 153b6d90eb7SKip Macy } 154b6d90eb7SKip Macy 155b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 156b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = { 157b6d90eb7SKip Macy ael1002_reset, 158b6d90eb7SKip Macy ael1002_intr_noop, 159b6d90eb7SKip Macy ael1002_intr_noop, 160b6d90eb7SKip Macy ael1002_intr_noop, 161b6d90eb7SKip Macy ael1002_intr_noop, 162b6d90eb7SKip Macy NULL, 163b6d90eb7SKip Macy NULL, 164b6d90eb7SKip Macy NULL, 165b6d90eb7SKip Macy NULL, 166b6d90eb7SKip Macy NULL, 1679b4de886SKip Macy get_link_status_r, 168b6d90eb7SKip Macy ael1002_power_down, 169b6d90eb7SKip Macy }; 170b6d90eb7SKip Macy #else 171b6d90eb7SKip Macy static struct cphy_ops ael1002_ops = { 172b6d90eb7SKip Macy .reset = ael1002_reset, 173b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop, 174b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop, 175b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop, 176b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop, 1779b4de886SKip Macy .get_link_status = get_link_status_r, 178b6d90eb7SKip Macy .power_down = ael1002_power_down, 179b6d90eb7SKip Macy }; 180b6d90eb7SKip Macy #endif 181b6d90eb7SKip Macy 1828e10660fSKip Macy int t3_ael1002_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 183b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 184b6d90eb7SKip Macy { 1858e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &ael1002_ops, mdio_ops, 1868e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE, 18719905d6dSKip Macy "10GBASE-R"); 188b6d90eb7SKip Macy ael100x_txon(phy); 1898e10660fSKip Macy return 0; 190b6d90eb7SKip Macy } 191b6d90eb7SKip Macy 192b6d90eb7SKip Macy static int ael1006_reset(struct cphy *phy, int wait) 193b6d90eb7SKip Macy { 1942a1b9f07SGeorge V. Neville-Neil u32 gpio_out; 1952a1b9f07SGeorge V. Neville-Neil t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); 1962a1b9f07SGeorge V. Neville-Neil /* Hack to reset the phy correctly */ 1972a1b9f07SGeorge V. Neville-Neil /* Read out the current value */ 1982a1b9f07SGeorge V. Neville-Neil gpio_out = t3_read_reg(phy->adapter, A_T3DBG_GPIO_EN); 1992a1b9f07SGeorge V. Neville-Neil /* Reset the phy */ 2002a1b9f07SGeorge V. Neville-Neil gpio_out &= ~F_GPIO6_OUT_VAL; 2012a1b9f07SGeorge V. Neville-Neil t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); 2022a1b9f07SGeorge V. Neville-Neil msleep(125); 2032a1b9f07SGeorge V. Neville-Neil /* Take the phy out of reset */ 2042a1b9f07SGeorge V. Neville-Neil gpio_out |= F_GPIO6_OUT_VAL; 2052a1b9f07SGeorge V. Neville-Neil t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); 2062a1b9f07SGeorge V. Neville-Neil msleep(125); 2072a1b9f07SGeorge V. Neville-Neil t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); 2082a1b9f07SGeorge V. Neville-Neil return 0; 209b6d90eb7SKip Macy } 210b6d90eb7SKip Macy 211b6d90eb7SKip Macy static int ael1006_power_down(struct cphy *phy, int enable) 212b6d90eb7SKip Macy { 213b6d90eb7SKip Macy return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 214b6d90eb7SKip Macy BMCR_PDOWN, enable ? BMCR_PDOWN : 0); 215b6d90eb7SKip Macy } 216b6d90eb7SKip Macy 217b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 218b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = { 219b6d90eb7SKip Macy ael1006_reset, 2204af83c8cSKip Macy t3_phy_lasi_intr_enable, 2214af83c8cSKip Macy t3_phy_lasi_intr_disable, 2224af83c8cSKip Macy t3_phy_lasi_intr_clear, 2234af83c8cSKip Macy t3_phy_lasi_intr_handler, 224b6d90eb7SKip Macy NULL, 225b6d90eb7SKip Macy NULL, 226b6d90eb7SKip Macy NULL, 227b6d90eb7SKip Macy NULL, 228b6d90eb7SKip Macy NULL, 2299b4de886SKip Macy get_link_status_r, 230b6d90eb7SKip Macy ael1006_power_down, 231b6d90eb7SKip Macy }; 232b6d90eb7SKip Macy #else 233b6d90eb7SKip Macy static struct cphy_ops ael1006_ops = { 234b6d90eb7SKip Macy .reset = ael1006_reset, 2354af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable, 2364af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable, 2374af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear, 2384af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler, 2399b4de886SKip Macy .get_link_status = get_link_status_r, 240b6d90eb7SKip Macy .power_down = ael1006_power_down, 241b6d90eb7SKip Macy }; 242b6d90eb7SKip Macy #endif 243b6d90eb7SKip Macy 2448e10660fSKip Macy int t3_ael1006_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 245b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 246b6d90eb7SKip Macy { 2478e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &ael1006_ops, mdio_ops, 2488e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE, 2498e10660fSKip Macy "10GBASE-SR"); 250b6d90eb7SKip Macy ael100x_txon(phy); 2518e10660fSKip Macy return 0; 252b6d90eb7SKip Macy } 253b6d90eb7SKip Macy 2544af83c8cSKip Macy static int ael2005_setup_sr_edc(struct cphy *phy) 2554af83c8cSKip Macy { 2569b4de886SKip Macy static struct reg_val regs[] = { 2579b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x181 }, 2589b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc010, 0xffff, 0x448a }, 2599b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5200 }, 2609b4de886SKip Macy { 0, 0, 0, 0 } 2619b4de886SKip Macy }; 2624af83c8cSKip Macy static u16 sr_edc[] = { 2634af83c8cSKip Macy 0xcc00, 0x2ff4, 2644af83c8cSKip Macy 0xcc01, 0x3cd4, 2654af83c8cSKip Macy 0xcc02, 0x2015, 2664af83c8cSKip Macy 0xcc03, 0x3105, 2674af83c8cSKip Macy 0xcc04, 0x6524, 2684af83c8cSKip Macy 0xcc05, 0x27ff, 2694af83c8cSKip Macy 0xcc06, 0x300f, 2704af83c8cSKip Macy 0xcc07, 0x2c8b, 2714af83c8cSKip Macy 0xcc08, 0x300b, 2724af83c8cSKip Macy 0xcc09, 0x4009, 2734af83c8cSKip Macy 0xcc0a, 0x400e, 2744af83c8cSKip Macy 0xcc0b, 0x2f72, 2754af83c8cSKip Macy 0xcc0c, 0x3002, 2764af83c8cSKip Macy 0xcc0d, 0x1002, 2774af83c8cSKip Macy 0xcc0e, 0x2172, 2784af83c8cSKip Macy 0xcc0f, 0x3012, 2794af83c8cSKip Macy 0xcc10, 0x1002, 2804af83c8cSKip Macy 0xcc11, 0x25d2, 2814af83c8cSKip Macy 0xcc12, 0x3012, 2824af83c8cSKip Macy 0xcc13, 0x1002, 2834af83c8cSKip Macy 0xcc14, 0xd01e, 2844af83c8cSKip Macy 0xcc15, 0x27d2, 2854af83c8cSKip Macy 0xcc16, 0x3012, 2864af83c8cSKip Macy 0xcc17, 0x1002, 2874af83c8cSKip Macy 0xcc18, 0x2004, 2884af83c8cSKip Macy 0xcc19, 0x3c84, 2894af83c8cSKip Macy 0xcc1a, 0x6436, 2904af83c8cSKip Macy 0xcc1b, 0x2007, 2914af83c8cSKip Macy 0xcc1c, 0x3f87, 2924af83c8cSKip Macy 0xcc1d, 0x8676, 2934af83c8cSKip Macy 0xcc1e, 0x40b7, 2944af83c8cSKip Macy 0xcc1f, 0xa746, 2954af83c8cSKip Macy 0xcc20, 0x4047, 2964af83c8cSKip Macy 0xcc21, 0x5673, 2974af83c8cSKip Macy 0xcc22, 0x2982, 2984af83c8cSKip Macy 0xcc23, 0x3002, 2994af83c8cSKip Macy 0xcc24, 0x13d2, 3004af83c8cSKip Macy 0xcc25, 0x8bbd, 3014af83c8cSKip Macy 0xcc26, 0x2862, 3024af83c8cSKip Macy 0xcc27, 0x3012, 3034af83c8cSKip Macy 0xcc28, 0x1002, 3044af83c8cSKip Macy 0xcc29, 0x2092, 3054af83c8cSKip Macy 0xcc2a, 0x3012, 3064af83c8cSKip Macy 0xcc2b, 0x1002, 3074af83c8cSKip Macy 0xcc2c, 0x5cc3, 3084af83c8cSKip Macy 0xcc2d, 0x314, 3094af83c8cSKip Macy 0xcc2e, 0x2942, 3104af83c8cSKip Macy 0xcc2f, 0x3002, 3114af83c8cSKip Macy 0xcc30, 0x1002, 3124af83c8cSKip Macy 0xcc31, 0xd019, 3134af83c8cSKip Macy 0xcc32, 0x2032, 3144af83c8cSKip Macy 0xcc33, 0x3012, 3154af83c8cSKip Macy 0xcc34, 0x1002, 3164af83c8cSKip Macy 0xcc35, 0x2a04, 3174af83c8cSKip Macy 0xcc36, 0x3c74, 3184af83c8cSKip Macy 0xcc37, 0x6435, 3194af83c8cSKip Macy 0xcc38, 0x2fa4, 3204af83c8cSKip Macy 0xcc39, 0x3cd4, 3214af83c8cSKip Macy 0xcc3a, 0x6624, 3224af83c8cSKip Macy 0xcc3b, 0x5563, 3234af83c8cSKip Macy 0xcc3c, 0x2d42, 3244af83c8cSKip Macy 0xcc3d, 0x3002, 3254af83c8cSKip Macy 0xcc3e, 0x13d2, 3264af83c8cSKip Macy 0xcc3f, 0x464d, 3274af83c8cSKip Macy 0xcc40, 0x2862, 3284af83c8cSKip Macy 0xcc41, 0x3012, 3294af83c8cSKip Macy 0xcc42, 0x1002, 3304af83c8cSKip Macy 0xcc43, 0x2032, 3314af83c8cSKip Macy 0xcc44, 0x3012, 3324af83c8cSKip Macy 0xcc45, 0x1002, 3334af83c8cSKip Macy 0xcc46, 0x2fb4, 3344af83c8cSKip Macy 0xcc47, 0x3cd4, 3354af83c8cSKip Macy 0xcc48, 0x6624, 3364af83c8cSKip Macy 0xcc49, 0x5563, 3374af83c8cSKip Macy 0xcc4a, 0x2d42, 3384af83c8cSKip Macy 0xcc4b, 0x3002, 3394af83c8cSKip Macy 0xcc4c, 0x13d2, 3404af83c8cSKip Macy 0xcc4d, 0x2ed2, 3414af83c8cSKip Macy 0xcc4e, 0x3002, 3424af83c8cSKip Macy 0xcc4f, 0x1002, 3434af83c8cSKip Macy 0xcc50, 0x2fd2, 3444af83c8cSKip Macy 0xcc51, 0x3002, 3454af83c8cSKip Macy 0xcc52, 0x1002, 3464af83c8cSKip Macy 0xcc53, 0x004, 3474af83c8cSKip Macy 0xcc54, 0x2942, 3484af83c8cSKip Macy 0xcc55, 0x3002, 3494af83c8cSKip Macy 0xcc56, 0x1002, 3504af83c8cSKip Macy 0xcc57, 0x2092, 3514af83c8cSKip Macy 0xcc58, 0x3012, 3524af83c8cSKip Macy 0xcc59, 0x1002, 3534af83c8cSKip Macy 0xcc5a, 0x5cc3, 3544af83c8cSKip Macy 0xcc5b, 0x317, 3554af83c8cSKip Macy 0xcc5c, 0x2f72, 3564af83c8cSKip Macy 0xcc5d, 0x3002, 3574af83c8cSKip Macy 0xcc5e, 0x1002, 3584af83c8cSKip Macy 0xcc5f, 0x2942, 3594af83c8cSKip Macy 0xcc60, 0x3002, 3604af83c8cSKip Macy 0xcc61, 0x1002, 3614af83c8cSKip Macy 0xcc62, 0x22cd, 3624af83c8cSKip Macy 0xcc63, 0x301d, 3634af83c8cSKip Macy 0xcc64, 0x2862, 3644af83c8cSKip Macy 0xcc65, 0x3012, 3654af83c8cSKip Macy 0xcc66, 0x1002, 3664af83c8cSKip Macy 0xcc67, 0x2ed2, 3674af83c8cSKip Macy 0xcc68, 0x3002, 3684af83c8cSKip Macy 0xcc69, 0x1002, 3694af83c8cSKip Macy 0xcc6a, 0x2d72, 3704af83c8cSKip Macy 0xcc6b, 0x3002, 3714af83c8cSKip Macy 0xcc6c, 0x1002, 3724af83c8cSKip Macy 0xcc6d, 0x628f, 3734af83c8cSKip Macy 0xcc6e, 0x2112, 3744af83c8cSKip Macy 0xcc6f, 0x3012, 3754af83c8cSKip Macy 0xcc70, 0x1002, 3764af83c8cSKip Macy 0xcc71, 0x5aa3, 3774af83c8cSKip Macy 0xcc72, 0x2dc2, 3784af83c8cSKip Macy 0xcc73, 0x3002, 3794af83c8cSKip Macy 0xcc74, 0x1312, 3804af83c8cSKip Macy 0xcc75, 0x6f72, 3814af83c8cSKip Macy 0xcc76, 0x1002, 3824af83c8cSKip Macy 0xcc77, 0x2807, 3834af83c8cSKip Macy 0xcc78, 0x31a7, 3844af83c8cSKip Macy 0xcc79, 0x20c4, 3854af83c8cSKip Macy 0xcc7a, 0x3c24, 3864af83c8cSKip Macy 0xcc7b, 0x6724, 3874af83c8cSKip Macy 0xcc7c, 0x1002, 3884af83c8cSKip Macy 0xcc7d, 0x2807, 3894af83c8cSKip Macy 0xcc7e, 0x3187, 3904af83c8cSKip Macy 0xcc7f, 0x20c4, 3914af83c8cSKip Macy 0xcc80, 0x3c24, 3924af83c8cSKip Macy 0xcc81, 0x6724, 3934af83c8cSKip Macy 0xcc82, 0x1002, 3944af83c8cSKip Macy 0xcc83, 0x2514, 3954af83c8cSKip Macy 0xcc84, 0x3c64, 3964af83c8cSKip Macy 0xcc85, 0x6436, 3974af83c8cSKip Macy 0xcc86, 0xdff4, 3984af83c8cSKip Macy 0xcc87, 0x6436, 3994af83c8cSKip Macy 0xcc88, 0x1002, 4004af83c8cSKip Macy 0xcc89, 0x40a4, 4014af83c8cSKip Macy 0xcc8a, 0x643c, 4024af83c8cSKip Macy 0xcc8b, 0x4016, 4034af83c8cSKip Macy 0xcc8c, 0x8c6c, 4044af83c8cSKip Macy 0xcc8d, 0x2b24, 4054af83c8cSKip Macy 0xcc8e, 0x3c24, 4064af83c8cSKip Macy 0xcc8f, 0x6435, 4074af83c8cSKip Macy 0xcc90, 0x1002, 4084af83c8cSKip Macy 0xcc91, 0x2b24, 4094af83c8cSKip Macy 0xcc92, 0x3c24, 4104af83c8cSKip Macy 0xcc93, 0x643a, 4114af83c8cSKip Macy 0xcc94, 0x4025, 4124af83c8cSKip Macy 0xcc95, 0x8a5a, 4134af83c8cSKip Macy 0xcc96, 0x1002, 4144af83c8cSKip Macy 0xcc97, 0x2731, 4154af83c8cSKip Macy 0xcc98, 0x3011, 4164af83c8cSKip Macy 0xcc99, 0x1001, 4174af83c8cSKip Macy 0xcc9a, 0xc7a0, 4184af83c8cSKip Macy 0xcc9b, 0x100, 4194af83c8cSKip Macy 0xcc9c, 0xc502, 4204af83c8cSKip Macy 0xcc9d, 0x53ac, 4214af83c8cSKip Macy 0xcc9e, 0xc503, 4224af83c8cSKip Macy 0xcc9f, 0xd5d5, 4234af83c8cSKip Macy 0xcca0, 0xc600, 4244af83c8cSKip Macy 0xcca1, 0x2a6d, 4254af83c8cSKip Macy 0xcca2, 0xc601, 4264af83c8cSKip Macy 0xcca3, 0x2a4c, 4274af83c8cSKip Macy 0xcca4, 0xc602, 4284af83c8cSKip Macy 0xcca5, 0x111, 4294af83c8cSKip Macy 0xcca6, 0xc60c, 4304af83c8cSKip Macy 0xcca7, 0x5900, 4314af83c8cSKip Macy 0xcca8, 0xc710, 4324af83c8cSKip Macy 0xcca9, 0x700, 4334af83c8cSKip Macy 0xccaa, 0xc718, 4344af83c8cSKip Macy 0xccab, 0x700, 4354af83c8cSKip Macy 0xccac, 0xc720, 4364af83c8cSKip Macy 0xccad, 0x4700, 4374af83c8cSKip Macy 0xccae, 0xc801, 4384af83c8cSKip Macy 0xccaf, 0x7f50, 4394af83c8cSKip Macy 0xccb0, 0xc802, 4404af83c8cSKip Macy 0xccb1, 0x7760, 4414af83c8cSKip Macy 0xccb2, 0xc803, 4424af83c8cSKip Macy 0xccb3, 0x7fce, 4434af83c8cSKip Macy 0xccb4, 0xc804, 4444af83c8cSKip Macy 0xccb5, 0x5700, 4454af83c8cSKip Macy 0xccb6, 0xc805, 4464af83c8cSKip Macy 0xccb7, 0x5f11, 4474af83c8cSKip Macy 0xccb8, 0xc806, 4484af83c8cSKip Macy 0xccb9, 0x4751, 4494af83c8cSKip Macy 0xccba, 0xc807, 4504af83c8cSKip Macy 0xccbb, 0x57e1, 4514af83c8cSKip Macy 0xccbc, 0xc808, 4524af83c8cSKip Macy 0xccbd, 0x2700, 4534af83c8cSKip Macy 0xccbe, 0xc809, 4544af83c8cSKip Macy 0xccbf, 0x000, 4554af83c8cSKip Macy 0xccc0, 0xc821, 4564af83c8cSKip Macy 0xccc1, 0x002, 4574af83c8cSKip Macy 0xccc2, 0xc822, 4584af83c8cSKip Macy 0xccc3, 0x014, 4594af83c8cSKip Macy 0xccc4, 0xc832, 4604af83c8cSKip Macy 0xccc5, 0x1186, 4614af83c8cSKip Macy 0xccc6, 0xc847, 4624af83c8cSKip Macy 0xccc7, 0x1e02, 4634af83c8cSKip Macy 0xccc8, 0xc013, 4644af83c8cSKip Macy 0xccc9, 0xf341, 4654af83c8cSKip Macy 0xccca, 0xc01a, 4664af83c8cSKip Macy 0xcccb, 0x446, 4674af83c8cSKip Macy 0xcccc, 0xc024, 4684af83c8cSKip Macy 0xcccd, 0x1000, 4694af83c8cSKip Macy 0xccce, 0xc025, 4704af83c8cSKip Macy 0xcccf, 0xa00, 4714af83c8cSKip Macy 0xccd0, 0xc026, 4724af83c8cSKip Macy 0xccd1, 0xc0c, 4734af83c8cSKip Macy 0xccd2, 0xc027, 4744af83c8cSKip Macy 0xccd3, 0xc0c, 4754af83c8cSKip Macy 0xccd4, 0xc029, 4764af83c8cSKip Macy 0xccd5, 0x0a0, 4774af83c8cSKip Macy 0xccd6, 0xc030, 4784af83c8cSKip Macy 0xccd7, 0xa00, 4794af83c8cSKip Macy 0xccd8, 0xc03c, 4804af83c8cSKip Macy 0xccd9, 0x01c, 4814af83c8cSKip Macy 0xccda, 0xc005, 4824af83c8cSKip Macy 0xccdb, 0x7a06, 4834af83c8cSKip Macy 0xccdc, 0x000, 4844af83c8cSKip Macy 0xccdd, 0x2731, 4854af83c8cSKip Macy 0xccde, 0x3011, 4864af83c8cSKip Macy 0xccdf, 0x1001, 4874af83c8cSKip Macy 0xcce0, 0xc620, 4884af83c8cSKip Macy 0xcce1, 0x000, 4894af83c8cSKip Macy 0xcce2, 0xc621, 4904af83c8cSKip Macy 0xcce3, 0x03f, 4914af83c8cSKip Macy 0xcce4, 0xc622, 4924af83c8cSKip Macy 0xcce5, 0x000, 4934af83c8cSKip Macy 0xcce6, 0xc623, 4944af83c8cSKip Macy 0xcce7, 0x000, 4954af83c8cSKip Macy 0xcce8, 0xc624, 4964af83c8cSKip Macy 0xcce9, 0x000, 4974af83c8cSKip Macy 0xccea, 0xc625, 4984af83c8cSKip Macy 0xcceb, 0x000, 4994af83c8cSKip Macy 0xccec, 0xc627, 5004af83c8cSKip Macy 0xcced, 0x000, 5014af83c8cSKip Macy 0xccee, 0xc628, 5024af83c8cSKip Macy 0xccef, 0x000, 5034af83c8cSKip Macy 0xccf0, 0xc62c, 5044af83c8cSKip Macy 0xccf1, 0x000, 5054af83c8cSKip Macy 0xccf2, 0x000, 5064af83c8cSKip Macy 0xccf3, 0x2806, 5074af83c8cSKip Macy 0xccf4, 0x3cb6, 5084af83c8cSKip Macy 0xccf5, 0xc161, 5094af83c8cSKip Macy 0xccf6, 0x6134, 5104af83c8cSKip Macy 0xccf7, 0x6135, 5114af83c8cSKip Macy 0xccf8, 0x5443, 5124af83c8cSKip Macy 0xccf9, 0x303, 5134af83c8cSKip Macy 0xccfa, 0x6524, 5144af83c8cSKip Macy 0xccfb, 0x00b, 5154af83c8cSKip Macy 0xccfc, 0x1002, 5164af83c8cSKip Macy 0xccfd, 0x2104, 5174af83c8cSKip Macy 0xccfe, 0x3c24, 5184af83c8cSKip Macy 0xccff, 0x2105, 5194af83c8cSKip Macy 0xcd00, 0x3805, 5204af83c8cSKip Macy 0xcd01, 0x6524, 5214af83c8cSKip Macy 0xcd02, 0xdff4, 5224af83c8cSKip Macy 0xcd03, 0x4005, 5234af83c8cSKip Macy 0xcd04, 0x6524, 5244af83c8cSKip Macy 0xcd05, 0x1002, 5254af83c8cSKip Macy 0xcd06, 0x5dd3, 5264af83c8cSKip Macy 0xcd07, 0x306, 5274af83c8cSKip Macy 0xcd08, 0x2ff7, 5284af83c8cSKip Macy 0xcd09, 0x38f7, 5294af83c8cSKip Macy 0xcd0a, 0x60b7, 5304af83c8cSKip Macy 0xcd0b, 0xdffd, 5314af83c8cSKip Macy 0xcd0c, 0x00a, 5324af83c8cSKip Macy 0xcd0d, 0x1002, 5334af83c8cSKip Macy 0xcd0e, 0 5344af83c8cSKip Macy }; 5354af83c8cSKip Macy int i, err; 5364af83c8cSKip Macy 5379b4de886SKip Macy err = set_phy_regs(phy, regs); 5389b4de886SKip Macy if (err) 5399b4de886SKip Macy return err; 5409b4de886SKip Macy 5419b4de886SKip Macy msleep(50); 5429b4de886SKip Macy 5439b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2) 5444af83c8cSKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, sr_edc[i], 5454af83c8cSKip Macy sr_edc[i + 1]); 5469b4de886SKip Macy if (!err) 5479b4de886SKip Macy phy->priv = edc_sr; 5484af83c8cSKip Macy return err; 5494af83c8cSKip Macy } 5504af83c8cSKip Macy 5519b4de886SKip Macy static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype) 5529b4de886SKip Macy { 5539b4de886SKip Macy static struct reg_val regs[] = { 5549b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5a00 }, 5559b4de886SKip Macy { 0, 0, 0, 0 } 5569b4de886SKip Macy }; 5579b4de886SKip Macy static struct reg_val preemphasis[] = { 5589b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc014, 0xffff, 0xfe16 }, 5599b4de886SKip Macy { MDIO_DEV_PMA_PMD, 0xc015, 0xffff, 0xa000 }, 5609b4de886SKip Macy { 0, 0, 0, 0 } 5619b4de886SKip Macy }; 5629b4de886SKip Macy static u16 twinax_edc[] = { 5639b4de886SKip Macy 0xcc00, 0x4009, 5649b4de886SKip Macy 0xcc01, 0x27ff, 5659b4de886SKip Macy 0xcc02, 0x300f, 5669b4de886SKip Macy 0xcc03, 0x40aa, 5679b4de886SKip Macy 0xcc04, 0x401c, 5689b4de886SKip Macy 0xcc05, 0x401e, 5699b4de886SKip Macy 0xcc06, 0x2ff4, 5709b4de886SKip Macy 0xcc07, 0x3cd4, 5719b4de886SKip Macy 0xcc08, 0x2035, 5729b4de886SKip Macy 0xcc09, 0x3145, 5739b4de886SKip Macy 0xcc0a, 0x6524, 5749b4de886SKip Macy 0xcc0b, 0x26a2, 5759b4de886SKip Macy 0xcc0c, 0x3012, 5769b4de886SKip Macy 0xcc0d, 0x1002, 5779b4de886SKip Macy 0xcc0e, 0x29c2, 5789b4de886SKip Macy 0xcc0f, 0x3002, 5799b4de886SKip Macy 0xcc10, 0x1002, 5809b4de886SKip Macy 0xcc11, 0x2072, 5819b4de886SKip Macy 0xcc12, 0x3012, 5829b4de886SKip Macy 0xcc13, 0x1002, 5839b4de886SKip Macy 0xcc14, 0x22cd, 5849b4de886SKip Macy 0xcc15, 0x301d, 5859b4de886SKip Macy 0xcc16, 0x2e52, 5869b4de886SKip Macy 0xcc17, 0x3012, 5879b4de886SKip Macy 0xcc18, 0x1002, 5889b4de886SKip Macy 0xcc19, 0x28e2, 5899b4de886SKip Macy 0xcc1a, 0x3002, 5909b4de886SKip Macy 0xcc1b, 0x1002, 5919b4de886SKip Macy 0xcc1c, 0x628f, 5929b4de886SKip Macy 0xcc1d, 0x2ac2, 5939b4de886SKip Macy 0xcc1e, 0x3012, 5949b4de886SKip Macy 0xcc1f, 0x1002, 5959b4de886SKip Macy 0xcc20, 0x5553, 5969b4de886SKip Macy 0xcc21, 0x2ae2, 5979b4de886SKip Macy 0xcc22, 0x3002, 5989b4de886SKip Macy 0xcc23, 0x1302, 5999b4de886SKip Macy 0xcc24, 0x401e, 6009b4de886SKip Macy 0xcc25, 0x2be2, 6019b4de886SKip Macy 0xcc26, 0x3012, 6029b4de886SKip Macy 0xcc27, 0x1002, 6039b4de886SKip Macy 0xcc28, 0x2da2, 6049b4de886SKip Macy 0xcc29, 0x3012, 6059b4de886SKip Macy 0xcc2a, 0x1002, 6069b4de886SKip Macy 0xcc2b, 0x2ba2, 6079b4de886SKip Macy 0xcc2c, 0x3002, 6089b4de886SKip Macy 0xcc2d, 0x1002, 6099b4de886SKip Macy 0xcc2e, 0x5ee3, 6109b4de886SKip Macy 0xcc2f, 0x305, 6119b4de886SKip Macy 0xcc30, 0x400e, 6129b4de886SKip Macy 0xcc31, 0x2bc2, 6139b4de886SKip Macy 0xcc32, 0x3002, 6149b4de886SKip Macy 0xcc33, 0x1002, 6159b4de886SKip Macy 0xcc34, 0x2b82, 6169b4de886SKip Macy 0xcc35, 0x3012, 6179b4de886SKip Macy 0xcc36, 0x1002, 6189b4de886SKip Macy 0xcc37, 0x5663, 6199b4de886SKip Macy 0xcc38, 0x302, 6209b4de886SKip Macy 0xcc39, 0x401e, 6219b4de886SKip Macy 0xcc3a, 0x6f72, 6229b4de886SKip Macy 0xcc3b, 0x1002, 6239b4de886SKip Macy 0xcc3c, 0x628f, 6249b4de886SKip Macy 0xcc3d, 0x2be2, 6259b4de886SKip Macy 0xcc3e, 0x3012, 6269b4de886SKip Macy 0xcc3f, 0x1002, 6279b4de886SKip Macy 0xcc40, 0x22cd, 6289b4de886SKip Macy 0xcc41, 0x301d, 6299b4de886SKip Macy 0xcc42, 0x2e52, 6309b4de886SKip Macy 0xcc43, 0x3012, 6319b4de886SKip Macy 0xcc44, 0x1002, 6329b4de886SKip Macy 0xcc45, 0x2522, 6339b4de886SKip Macy 0xcc46, 0x3012, 6349b4de886SKip Macy 0xcc47, 0x1002, 6359b4de886SKip Macy 0xcc48, 0x2da2, 6369b4de886SKip Macy 0xcc49, 0x3012, 6379b4de886SKip Macy 0xcc4a, 0x1002, 6389b4de886SKip Macy 0xcc4b, 0x2ca2, 6399b4de886SKip Macy 0xcc4c, 0x3012, 6409b4de886SKip Macy 0xcc4d, 0x1002, 6419b4de886SKip Macy 0xcc4e, 0x2fa4, 6429b4de886SKip Macy 0xcc4f, 0x3cd4, 6439b4de886SKip Macy 0xcc50, 0x6624, 6449b4de886SKip Macy 0xcc51, 0x410b, 6459b4de886SKip Macy 0xcc52, 0x56b3, 6469b4de886SKip Macy 0xcc53, 0x3c4, 6479b4de886SKip Macy 0xcc54, 0x2fb2, 6489b4de886SKip Macy 0xcc55, 0x3002, 6499b4de886SKip Macy 0xcc56, 0x1002, 6509b4de886SKip Macy 0xcc57, 0x220b, 6519b4de886SKip Macy 0xcc58, 0x303b, 6529b4de886SKip Macy 0xcc59, 0x56b3, 6539b4de886SKip Macy 0xcc5a, 0x3c3, 6549b4de886SKip Macy 0xcc5b, 0x866b, 6559b4de886SKip Macy 0xcc5c, 0x400c, 6569b4de886SKip Macy 0xcc5d, 0x23a2, 6579b4de886SKip Macy 0xcc5e, 0x3012, 6589b4de886SKip Macy 0xcc5f, 0x1002, 6599b4de886SKip Macy 0xcc60, 0x2da2, 6609b4de886SKip Macy 0xcc61, 0x3012, 6619b4de886SKip Macy 0xcc62, 0x1002, 6629b4de886SKip Macy 0xcc63, 0x2ca2, 6639b4de886SKip Macy 0xcc64, 0x3012, 6649b4de886SKip Macy 0xcc65, 0x1002, 6659b4de886SKip Macy 0xcc66, 0x2fb4, 6669b4de886SKip Macy 0xcc67, 0x3cd4, 6679b4de886SKip Macy 0xcc68, 0x6624, 6689b4de886SKip Macy 0xcc69, 0x56b3, 6699b4de886SKip Macy 0xcc6a, 0x3c3, 6709b4de886SKip Macy 0xcc6b, 0x866b, 6719b4de886SKip Macy 0xcc6c, 0x401c, 6729b4de886SKip Macy 0xcc6d, 0x2205, 6739b4de886SKip Macy 0xcc6e, 0x3035, 6749b4de886SKip Macy 0xcc6f, 0x5b53, 6759b4de886SKip Macy 0xcc70, 0x2c52, 6769b4de886SKip Macy 0xcc71, 0x3002, 6779b4de886SKip Macy 0xcc72, 0x13c2, 6789b4de886SKip Macy 0xcc73, 0x5cc3, 6799b4de886SKip Macy 0xcc74, 0x317, 6809b4de886SKip Macy 0xcc75, 0x2522, 6819b4de886SKip Macy 0xcc76, 0x3012, 6829b4de886SKip Macy 0xcc77, 0x1002, 6839b4de886SKip Macy 0xcc78, 0x2da2, 6849b4de886SKip Macy 0xcc79, 0x3012, 6859b4de886SKip Macy 0xcc7a, 0x1002, 6869b4de886SKip Macy 0xcc7b, 0x2b82, 6879b4de886SKip Macy 0xcc7c, 0x3012, 6889b4de886SKip Macy 0xcc7d, 0x1002, 6899b4de886SKip Macy 0xcc7e, 0x5663, 6909b4de886SKip Macy 0xcc7f, 0x303, 6919b4de886SKip Macy 0xcc80, 0x401e, 6929b4de886SKip Macy 0xcc81, 0x004, 6939b4de886SKip Macy 0xcc82, 0x2c42, 6949b4de886SKip Macy 0xcc83, 0x3012, 6959b4de886SKip Macy 0xcc84, 0x1002, 6969b4de886SKip Macy 0xcc85, 0x6f72, 6979b4de886SKip Macy 0xcc86, 0x1002, 6989b4de886SKip Macy 0xcc87, 0x628f, 6999b4de886SKip Macy 0xcc88, 0x2304, 7009b4de886SKip Macy 0xcc89, 0x3c84, 7019b4de886SKip Macy 0xcc8a, 0x6436, 7029b4de886SKip Macy 0xcc8b, 0xdff4, 7039b4de886SKip Macy 0xcc8c, 0x6436, 7049b4de886SKip Macy 0xcc8d, 0x2ff5, 7059b4de886SKip Macy 0xcc8e, 0x3005, 7069b4de886SKip Macy 0xcc8f, 0x8656, 7079b4de886SKip Macy 0xcc90, 0xdfba, 7089b4de886SKip Macy 0xcc91, 0x56a3, 7099b4de886SKip Macy 0xcc92, 0xd05a, 7109b4de886SKip Macy 0xcc93, 0x21c2, 7119b4de886SKip Macy 0xcc94, 0x3012, 7129b4de886SKip Macy 0xcc95, 0x1392, 7139b4de886SKip Macy 0xcc96, 0xd05a, 7149b4de886SKip Macy 0xcc97, 0x56a3, 7159b4de886SKip Macy 0xcc98, 0xdfba, 7169b4de886SKip Macy 0xcc99, 0x383, 7179b4de886SKip Macy 0xcc9a, 0x6f72, 7189b4de886SKip Macy 0xcc9b, 0x1002, 7199b4de886SKip Macy 0xcc9c, 0x28c5, 7209b4de886SKip Macy 0xcc9d, 0x3005, 7219b4de886SKip Macy 0xcc9e, 0x4178, 7229b4de886SKip Macy 0xcc9f, 0x5653, 7239b4de886SKip Macy 0xcca0, 0x384, 7249b4de886SKip Macy 0xcca1, 0x22b2, 7259b4de886SKip Macy 0xcca2, 0x3012, 7269b4de886SKip Macy 0xcca3, 0x1002, 7279b4de886SKip Macy 0xcca4, 0x2be5, 7289b4de886SKip Macy 0xcca5, 0x3005, 7299b4de886SKip Macy 0xcca6, 0x41e8, 7309b4de886SKip Macy 0xcca7, 0x5653, 7319b4de886SKip Macy 0xcca8, 0x382, 7329b4de886SKip Macy 0xcca9, 0x002, 7339b4de886SKip Macy 0xccaa, 0x4258, 7349b4de886SKip Macy 0xccab, 0x2474, 7359b4de886SKip Macy 0xccac, 0x3c84, 7369b4de886SKip Macy 0xccad, 0x6437, 7379b4de886SKip Macy 0xccae, 0xdff4, 7389b4de886SKip Macy 0xccaf, 0x6437, 7399b4de886SKip Macy 0xccb0, 0x2ff5, 7409b4de886SKip Macy 0xccb1, 0x3c05, 7419b4de886SKip Macy 0xccb2, 0x8757, 7429b4de886SKip Macy 0xccb3, 0xb888, 7439b4de886SKip Macy 0xccb4, 0x9787, 7449b4de886SKip Macy 0xccb5, 0xdff4, 7459b4de886SKip Macy 0xccb6, 0x6724, 7469b4de886SKip Macy 0xccb7, 0x866a, 7479b4de886SKip Macy 0xccb8, 0x6f72, 7489b4de886SKip Macy 0xccb9, 0x1002, 7499b4de886SKip Macy 0xccba, 0x2d01, 7509b4de886SKip Macy 0xccbb, 0x3011, 7519b4de886SKip Macy 0xccbc, 0x1001, 7529b4de886SKip Macy 0xccbd, 0xc620, 7539b4de886SKip Macy 0xccbe, 0x14e5, 7549b4de886SKip Macy 0xccbf, 0xc621, 7559b4de886SKip Macy 0xccc0, 0xc53d, 7569b4de886SKip Macy 0xccc1, 0xc622, 7579b4de886SKip Macy 0xccc2, 0x3cbe, 7589b4de886SKip Macy 0xccc3, 0xc623, 7599b4de886SKip Macy 0xccc4, 0x4452, 7609b4de886SKip Macy 0xccc5, 0xc624, 7619b4de886SKip Macy 0xccc6, 0xc5c5, 7629b4de886SKip Macy 0xccc7, 0xc625, 7639b4de886SKip Macy 0xccc8, 0xe01e, 7649b4de886SKip Macy 0xccc9, 0xc627, 7659b4de886SKip Macy 0xccca, 0x000, 7669b4de886SKip Macy 0xcccb, 0xc628, 7679b4de886SKip Macy 0xcccc, 0x000, 7689b4de886SKip Macy 0xcccd, 0xc62b, 7699b4de886SKip Macy 0xccce, 0x000, 7709b4de886SKip Macy 0xcccf, 0xc62c, 7719b4de886SKip Macy 0xccd0, 0x000, 7729b4de886SKip Macy 0xccd1, 0x000, 7739b4de886SKip Macy 0xccd2, 0x2d01, 7749b4de886SKip Macy 0xccd3, 0x3011, 7759b4de886SKip Macy 0xccd4, 0x1001, 7769b4de886SKip Macy 0xccd5, 0xc620, 7779b4de886SKip Macy 0xccd6, 0x000, 7789b4de886SKip Macy 0xccd7, 0xc621, 7799b4de886SKip Macy 0xccd8, 0x000, 7809b4de886SKip Macy 0xccd9, 0xc622, 7819b4de886SKip Macy 0xccda, 0x0ce, 7829b4de886SKip Macy 0xccdb, 0xc623, 7839b4de886SKip Macy 0xccdc, 0x07f, 7849b4de886SKip Macy 0xccdd, 0xc624, 7859b4de886SKip Macy 0xccde, 0x032, 7869b4de886SKip Macy 0xccdf, 0xc625, 7879b4de886SKip Macy 0xcce0, 0x000, 7889b4de886SKip Macy 0xcce1, 0xc627, 7899b4de886SKip Macy 0xcce2, 0x000, 7909b4de886SKip Macy 0xcce3, 0xc628, 7919b4de886SKip Macy 0xcce4, 0x000, 7929b4de886SKip Macy 0xcce5, 0xc62b, 7939b4de886SKip Macy 0xcce6, 0x000, 7949b4de886SKip Macy 0xcce7, 0xc62c, 7959b4de886SKip Macy 0xcce8, 0x000, 7969b4de886SKip Macy 0xcce9, 0x000, 7979b4de886SKip Macy 0xccea, 0x2d01, 7989b4de886SKip Macy 0xcceb, 0x3011, 7999b4de886SKip Macy 0xccec, 0x1001, 8009b4de886SKip Macy 0xcced, 0xc502, 8019b4de886SKip Macy 0xccee, 0x609f, 8029b4de886SKip Macy 0xccef, 0xc600, 8039b4de886SKip Macy 0xccf0, 0x2a6e, 8049b4de886SKip Macy 0xccf1, 0xc601, 8059b4de886SKip Macy 0xccf2, 0x2a2c, 8069b4de886SKip Macy 0xccf3, 0xc60c, 8079b4de886SKip Macy 0xccf4, 0x5400, 8089b4de886SKip Macy 0xccf5, 0xc710, 8099b4de886SKip Macy 0xccf6, 0x700, 8109b4de886SKip Macy 0xccf7, 0xc718, 8119b4de886SKip Macy 0xccf8, 0x700, 8129b4de886SKip Macy 0xccf9, 0xc720, 8139b4de886SKip Macy 0xccfa, 0x4700, 8149b4de886SKip Macy 0xccfb, 0xc728, 8159b4de886SKip Macy 0xccfc, 0x700, 8169b4de886SKip Macy 0xccfd, 0xc729, 8179b4de886SKip Macy 0xccfe, 0x1207, 8189b4de886SKip Macy 0xccff, 0xc801, 8199b4de886SKip Macy 0xcd00, 0x7f50, 8209b4de886SKip Macy 0xcd01, 0xc802, 8219b4de886SKip Macy 0xcd02, 0x7760, 8229b4de886SKip Macy 0xcd03, 0xc803, 8239b4de886SKip Macy 0xcd04, 0x7fce, 8249b4de886SKip Macy 0xcd05, 0xc804, 8259b4de886SKip Macy 0xcd06, 0x520e, 8269b4de886SKip Macy 0xcd07, 0xc805, 8279b4de886SKip Macy 0xcd08, 0x5c11, 8289b4de886SKip Macy 0xcd09, 0xc806, 8299b4de886SKip Macy 0xcd0a, 0x3c51, 8309b4de886SKip Macy 0xcd0b, 0xc807, 8319b4de886SKip Macy 0xcd0c, 0x4061, 8329b4de886SKip Macy 0xcd0d, 0xc808, 8339b4de886SKip Macy 0xcd0e, 0x49c1, 8349b4de886SKip Macy 0xcd0f, 0xc809, 8359b4de886SKip Macy 0xcd10, 0x3840, 8369b4de886SKip Macy 0xcd11, 0xc80a, 8379b4de886SKip Macy 0xcd12, 0x000, 8389b4de886SKip Macy 0xcd13, 0xc821, 8399b4de886SKip Macy 0xcd14, 0x002, 8409b4de886SKip Macy 0xcd15, 0xc822, 8419b4de886SKip Macy 0xcd16, 0x046, 8429b4de886SKip Macy 0xcd17, 0xc844, 8439b4de886SKip Macy 0xcd18, 0x182f, 8449b4de886SKip Macy 0xcd19, 0xc013, 8459b4de886SKip Macy 0xcd1a, 0xf341, 8469b4de886SKip Macy 0xcd1b, 0xc01a, 8479b4de886SKip Macy 0xcd1c, 0x446, 8489b4de886SKip Macy 0xcd1d, 0xc024, 8499b4de886SKip Macy 0xcd1e, 0x1000, 8509b4de886SKip Macy 0xcd1f, 0xc025, 8519b4de886SKip Macy 0xcd20, 0xa00, 8529b4de886SKip Macy 0xcd21, 0xc026, 8539b4de886SKip Macy 0xcd22, 0xc0c, 8549b4de886SKip Macy 0xcd23, 0xc027, 8559b4de886SKip Macy 0xcd24, 0xc0c, 8569b4de886SKip Macy 0xcd25, 0xc029, 8579b4de886SKip Macy 0xcd26, 0x0a0, 8589b4de886SKip Macy 0xcd27, 0xc030, 8599b4de886SKip Macy 0xcd28, 0xa00, 8609b4de886SKip Macy 0xcd29, 0xc03c, 8619b4de886SKip Macy 0xcd2a, 0x01c, 8629b4de886SKip Macy 0xcd2b, 0x000, 8639b4de886SKip Macy 0xcd2c, 0x2b84, 8649b4de886SKip Macy 0xcd2d, 0x3c74, 8659b4de886SKip Macy 0xcd2e, 0x6435, 8669b4de886SKip Macy 0xcd2f, 0xdff4, 8679b4de886SKip Macy 0xcd30, 0x6435, 8689b4de886SKip Macy 0xcd31, 0x2806, 8699b4de886SKip Macy 0xcd32, 0x3006, 8709b4de886SKip Macy 0xcd33, 0x8565, 8719b4de886SKip Macy 0xcd34, 0x2b24, 8729b4de886SKip Macy 0xcd35, 0x3c24, 8739b4de886SKip Macy 0xcd36, 0x6436, 8749b4de886SKip Macy 0xcd37, 0x1002, 8759b4de886SKip Macy 0xcd38, 0x2b24, 8769b4de886SKip Macy 0xcd39, 0x3c24, 8779b4de886SKip Macy 0xcd3a, 0x6436, 8789b4de886SKip Macy 0xcd3b, 0x4045, 8799b4de886SKip Macy 0xcd3c, 0x8656, 8809b4de886SKip Macy 0xcd3d, 0x1002, 8819b4de886SKip Macy 0xcd3e, 0x2807, 8829b4de886SKip Macy 0xcd3f, 0x31a7, 8839b4de886SKip Macy 0xcd40, 0x20c4, 8849b4de886SKip Macy 0xcd41, 0x3c24, 8859b4de886SKip Macy 0xcd42, 0x6724, 8869b4de886SKip Macy 0xcd43, 0x1002, 8879b4de886SKip Macy 0xcd44, 0x2807, 8889b4de886SKip Macy 0xcd45, 0x3187, 8899b4de886SKip Macy 0xcd46, 0x20c4, 8909b4de886SKip Macy 0xcd47, 0x3c24, 8919b4de886SKip Macy 0xcd48, 0x6724, 8929b4de886SKip Macy 0xcd49, 0x1002, 8939b4de886SKip Macy 0xcd4a, 0x2514, 8949b4de886SKip Macy 0xcd4b, 0x3c64, 8959b4de886SKip Macy 0xcd4c, 0x6436, 8969b4de886SKip Macy 0xcd4d, 0xdff4, 8979b4de886SKip Macy 0xcd4e, 0x6436, 8989b4de886SKip Macy 0xcd4f, 0x1002, 8999b4de886SKip Macy 0xcd50, 0x2806, 9009b4de886SKip Macy 0xcd51, 0x3cb6, 9019b4de886SKip Macy 0xcd52, 0xc161, 9029b4de886SKip Macy 0xcd53, 0x6134, 9039b4de886SKip Macy 0xcd54, 0x6135, 9049b4de886SKip Macy 0xcd55, 0x5443, 9059b4de886SKip Macy 0xcd56, 0x303, 9069b4de886SKip Macy 0xcd57, 0x6524, 9079b4de886SKip Macy 0xcd58, 0x00b, 9089b4de886SKip Macy 0xcd59, 0x1002, 9099b4de886SKip Macy 0xcd5a, 0xd019, 9109b4de886SKip Macy 0xcd5b, 0x2104, 9119b4de886SKip Macy 0xcd5c, 0x3c24, 9129b4de886SKip Macy 0xcd5d, 0x2105, 9139b4de886SKip Macy 0xcd5e, 0x3805, 9149b4de886SKip Macy 0xcd5f, 0x6524, 9159b4de886SKip Macy 0xcd60, 0xdff4, 9169b4de886SKip Macy 0xcd61, 0x4005, 9179b4de886SKip Macy 0xcd62, 0x6524, 9189b4de886SKip Macy 0xcd63, 0x2e8d, 9199b4de886SKip Macy 0xcd64, 0x303d, 9209b4de886SKip Macy 0xcd65, 0x5dd3, 9219b4de886SKip Macy 0xcd66, 0x306, 9229b4de886SKip Macy 0xcd67, 0x2ff7, 9239b4de886SKip Macy 0xcd68, 0x38f7, 9249b4de886SKip Macy 0xcd69, 0x60b7, 9259b4de886SKip Macy 0xcd6a, 0xdffd, 9269b4de886SKip Macy 0xcd6b, 0x00a, 9279b4de886SKip Macy 0xcd6c, 0x1002, 9289b4de886SKip Macy 0xcd6d, 0 9299b4de886SKip Macy }; 9309b4de886SKip Macy int i, err; 9319b4de886SKip Macy 9329b4de886SKip Macy err = set_phy_regs(phy, regs); 9339b4de886SKip Macy if (!err && modtype == phy_modtype_twinax_long) 9349b4de886SKip Macy err = set_phy_regs(phy, preemphasis); 9359b4de886SKip Macy if (err) 9369b4de886SKip Macy return err; 9379b4de886SKip Macy 9389b4de886SKip Macy msleep(50); 9399b4de886SKip Macy 9409b4de886SKip Macy for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2) 9419b4de886SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i], 9429b4de886SKip Macy twinax_edc[i + 1]); 9439b4de886SKip Macy if (!err) 9449b4de886SKip Macy phy->priv = edc_twinax; 9459b4de886SKip Macy return err; 9469b4de886SKip Macy } 9479b4de886SKip Macy 9489b4de886SKip Macy static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr) 9499b4de886SKip Macy { 9509b4de886SKip Macy int i, err; 9519b4de886SKip Macy unsigned int stat, data; 9529b4de886SKip Macy 9539b4de886SKip Macy err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, 9549b4de886SKip Macy (dev_addr << 8) | (1 << 8) | word_addr); 9559b4de886SKip Macy if (err) 9569b4de886SKip Macy return err; 9579b4de886SKip Macy 9589b4de886SKip Macy for (i = 0; i < 5; i++) { 9599b4de886SKip Macy msleep(1); 9609b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); 9619b4de886SKip Macy if (err) 9629b4de886SKip Macy return err; 9639b4de886SKip Macy if ((stat & 3) == 1) { 9649b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, 9659b4de886SKip Macy &data); 9669b4de886SKip Macy if (err) 9679b4de886SKip Macy return err; 9689b4de886SKip Macy return data >> 8; 9699b4de886SKip Macy } 9709b4de886SKip Macy } 9719b4de886SKip Macy CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n", 9729b4de886SKip Macy phy->addr, word_addr); 9739b4de886SKip Macy return -ETIMEDOUT; 9749b4de886SKip Macy } 9759b4de886SKip Macy 9769b4de886SKip Macy static int get_module_type(struct cphy *phy, int delay_ms) 9779b4de886SKip Macy { 9789b4de886SKip Macy int v; 9799b4de886SKip Macy unsigned int stat; 9809b4de886SKip Macy 9819b4de886SKip Macy v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat); 9829b4de886SKip Macy if (v) 9839b4de886SKip Macy return v; 9849b4de886SKip Macy 9859b4de886SKip Macy if (stat & (1 << 8)) /* module absent */ 9869b4de886SKip Macy return phy_modtype_none; 9879b4de886SKip Macy 9889b4de886SKip Macy if (delay_ms) 9899b4de886SKip Macy msleep(delay_ms); 9909b4de886SKip Macy 9919b4de886SKip Macy /* see SFF-8472 for below */ 9929b4de886SKip Macy v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 3); 9939b4de886SKip Macy if (v < 0) 9949b4de886SKip Macy return v; 9959b4de886SKip Macy 9969b4de886SKip Macy if (v == 0x10) 9979b4de886SKip Macy return phy_modtype_sr; 9989b4de886SKip Macy if (v == 0x20) 9999b4de886SKip Macy return phy_modtype_lr; 10009b4de886SKip Macy if (v == 0x40) 10019b4de886SKip Macy return phy_modtype_lrm; 10029b4de886SKip Macy 10039b4de886SKip Macy v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 6); 10049b4de886SKip Macy if (v < 0) 10059b4de886SKip Macy return v; 10069b4de886SKip Macy if (v != 4) 10079b4de886SKip Macy goto unknown; 10089b4de886SKip Macy 10099b4de886SKip Macy v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 10); 10109b4de886SKip Macy if (v < 0) 10119b4de886SKip Macy return v; 10129b4de886SKip Macy 10139b4de886SKip Macy if (v & 0x80) { 10149b4de886SKip Macy v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0x12); 10159b4de886SKip Macy if (v < 0) 10169b4de886SKip Macy return v; 10179b4de886SKip Macy return v > 10 ? phy_modtype_twinax_long : phy_modtype_twinax; 10189b4de886SKip Macy } 10199b4de886SKip Macy unknown: 10209b4de886SKip Macy return phy_modtype_unknown; 10219b4de886SKip Macy } 10229b4de886SKip Macy 10239b4de886SKip Macy static int ael2005_intr_enable(struct cphy *phy) 10249b4de886SKip Macy { 10259b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200); 10269b4de886SKip Macy return err ? err : t3_phy_lasi_intr_enable(phy); 10279b4de886SKip Macy } 10289b4de886SKip Macy 10299b4de886SKip Macy static int ael2005_intr_disable(struct cphy *phy) 10309b4de886SKip Macy { 10319b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x100); 10329b4de886SKip Macy return err ? err : t3_phy_lasi_intr_disable(phy); 10339b4de886SKip Macy } 10349b4de886SKip Macy 10359b4de886SKip Macy static int ael2005_intr_clear(struct cphy *phy) 10369b4de886SKip Macy { 10379b4de886SKip Macy int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0xd00); 10389b4de886SKip Macy return err ? err : t3_phy_lasi_intr_clear(phy); 10399b4de886SKip Macy } 10409b4de886SKip Macy 10414af83c8cSKip Macy static int ael2005_reset(struct cphy *phy, int wait) 10424af83c8cSKip Macy { 10434af83c8cSKip Macy static struct reg_val regs0[] = { 10444af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc001, 0, 1 << 5 }, 10454af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc017, 0, 1 << 5 }, 10464af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc013, 0xffff, 0xf341 }, 10474af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, 10484af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8100 }, 10494af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, 10504af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0 }, 10514af83c8cSKip Macy { 0, 0, 0, 0 } 10524af83c8cSKip Macy }; 10534af83c8cSKip Macy static struct reg_val regs1[] = { 10544af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca00, 0xffff, 0x0080 }, 10554af83c8cSKip Macy { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0 }, 10564af83c8cSKip Macy { 0, 0, 0, 0 } 10574af83c8cSKip Macy }; 10584af83c8cSKip Macy 10599b4de886SKip Macy int err, lasi_ctrl; 10609b4de886SKip Macy 10619b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl); 10629b4de886SKip Macy if (err) 10639b4de886SKip Macy return err; 10644af83c8cSKip Macy 10654af83c8cSKip Macy err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 0); 10664af83c8cSKip Macy if (err) 10674af83c8cSKip Macy return err; 10684af83c8cSKip Macy 10694af83c8cSKip Macy msleep(125); 10709b4de886SKip Macy phy->priv = edc_none; 10714af83c8cSKip Macy err = set_phy_regs(phy, regs0); 10724af83c8cSKip Macy if (err) 10734af83c8cSKip Macy return err; 10744af83c8cSKip Macy 10754af83c8cSKip Macy msleep(50); 10764af83c8cSKip Macy 10779b4de886SKip Macy err = get_module_type(phy, 0); 10789b4de886SKip Macy if (err < 0) 10799b4de886SKip Macy return err; 10809b4de886SKip Macy phy->modtype = (u8)err; 10819b4de886SKip Macy 10829b4de886SKip Macy if (err == phy_modtype_twinax || err == phy_modtype_twinax_long) 10839b4de886SKip Macy err = ael2005_setup_twinax_edc(phy, err); 10849b4de886SKip Macy else 10854af83c8cSKip Macy err = ael2005_setup_sr_edc(phy); 10864af83c8cSKip Macy if (err) 10874af83c8cSKip Macy return err; 10884af83c8cSKip Macy 10899b4de886SKip Macy err = set_phy_regs(phy, regs1); 10909b4de886SKip Macy if (err) 10919b4de886SKip Macy return err; 10929b4de886SKip Macy 10939b4de886SKip Macy /* reset wipes out interrupts, reenable them if they were on */ 10949b4de886SKip Macy if (lasi_ctrl & 1) 10959b4de886SKip Macy err = ael2005_intr_enable(phy); 10969b4de886SKip Macy return err; 10979b4de886SKip Macy } 10989b4de886SKip Macy 10999b4de886SKip Macy static int ael2005_intr_handler(struct cphy *phy) 11009b4de886SKip Macy { 11019b4de886SKip Macy unsigned int stat; 11029b4de886SKip Macy int ret, edc_needed, cause = 0; 11039b4de886SKip Macy 11049b4de886SKip Macy ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_STAT, &stat); 11059b4de886SKip Macy if (ret) 11069b4de886SKip Macy return ret; 11079b4de886SKip Macy 11089b4de886SKip Macy if (stat & AEL2005_MODDET_IRQ) { 11099b4de886SKip Macy ret = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 11109b4de886SKip Macy 0xd00); 11119b4de886SKip Macy if (ret) 11129b4de886SKip Macy return ret; 11139b4de886SKip Macy 11149b4de886SKip Macy /* modules have max 300 ms init time after hot plug */ 11159b4de886SKip Macy ret = get_module_type(phy, 300); 11169b4de886SKip Macy if (ret < 0) 11179b4de886SKip Macy return ret; 11189b4de886SKip Macy 11199b4de886SKip Macy phy->modtype = (u8)ret; 11209b4de886SKip Macy if (ret == phy_modtype_none) 11219b4de886SKip Macy edc_needed = phy->priv; /* on unplug retain EDC */ 11229b4de886SKip Macy else if (ret == phy_modtype_twinax || 11239b4de886SKip Macy ret == phy_modtype_twinax_long) 11249b4de886SKip Macy edc_needed = edc_twinax; 11259b4de886SKip Macy else 11269b4de886SKip Macy edc_needed = edc_sr; 11279b4de886SKip Macy 11289b4de886SKip Macy if (edc_needed != phy->priv) { 11299b4de886SKip Macy ret = ael2005_reset(phy, 0); 11309b4de886SKip Macy return ret ? ret : cphy_cause_module_change; 11319b4de886SKip Macy } 11329b4de886SKip Macy cause = cphy_cause_module_change; 11339b4de886SKip Macy } 11349b4de886SKip Macy 11359b4de886SKip Macy ret = t3_phy_lasi_intr_handler(phy); 11369b4de886SKip Macy return ret < 0 ? ret : ret + cause; 11374af83c8cSKip Macy } 11384af83c8cSKip Macy 11394af83c8cSKip Macy #ifdef C99_NOT_SUPPORTED 11404af83c8cSKip Macy static struct cphy_ops ael2005_ops = { 11414af83c8cSKip Macy ael2005_reset, 11429b4de886SKip Macy ael2005_intr_enable, 11439b4de886SKip Macy ael2005_intr_disable, 11449b4de886SKip Macy ael2005_intr_clear, 11459b4de886SKip Macy ael2005_intr_handler, 11464af83c8cSKip Macy NULL, 11474af83c8cSKip Macy NULL, 11484af83c8cSKip Macy NULL, 11494af83c8cSKip Macy NULL, 11504af83c8cSKip Macy NULL, 11519b4de886SKip Macy get_link_status_r, 11524af83c8cSKip Macy ael1002_power_down, 11534af83c8cSKip Macy }; 11544af83c8cSKip Macy #else 11554af83c8cSKip Macy static struct cphy_ops ael2005_ops = { 11564af83c8cSKip Macy .reset = ael2005_reset, 11579b4de886SKip Macy .intr_enable = ael2005_intr_enable, 11589b4de886SKip Macy .intr_disable = ael2005_intr_disable, 11599b4de886SKip Macy .intr_clear = ael2005_intr_clear, 11609b4de886SKip Macy .intr_handler = ael2005_intr_handler, 11619b4de886SKip Macy .get_link_status = get_link_status_r, 11624af83c8cSKip Macy .power_down = ael1002_power_down, 11634af83c8cSKip Macy }; 11644af83c8cSKip Macy #endif 11654af83c8cSKip Macy 11664af83c8cSKip Macy int t3_ael2005_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 11674af83c8cSKip Macy const struct mdio_ops *mdio_ops) 11684af83c8cSKip Macy { 11694af83c8cSKip Macy cphy_init(phy, adapter, phy_addr, &ael2005_ops, mdio_ops, 11709b4de886SKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE | 11719b4de886SKip Macy SUPPORTED_IRQ, "10GBASE-R"); 11724af83c8cSKip Macy msleep(125); 11734af83c8cSKip Macy return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL_OPT_SETTINGS, 0, 11744af83c8cSKip Macy 1 << 5); 11754af83c8cSKip Macy } 11764af83c8cSKip Macy 11779b4de886SKip Macy /* 11789b4de886SKip Macy * Get link status for a 10GBASE-X device. 11799b4de886SKip Macy */ 11809b4de886SKip Macy static int get_link_status_x(struct cphy *phy, int *link_ok, int *speed, 11819b4de886SKip Macy int *duplex, int *fc) 11829b4de886SKip Macy { 11839b4de886SKip Macy if (link_ok) { 11849b4de886SKip Macy unsigned int stat0, stat1, stat2; 11859b4de886SKip Macy int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); 11869b4de886SKip Macy 11879b4de886SKip Macy if (!err) 11889b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_X, &stat1); 11899b4de886SKip Macy if (!err) 11909b4de886SKip Macy err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); 11919b4de886SKip Macy if (err) 11929b4de886SKip Macy return err; 11939b4de886SKip Macy *link_ok = (stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1; 11949b4de886SKip Macy } 11959b4de886SKip Macy if (speed) 11969b4de886SKip Macy *speed = SPEED_10000; 11979b4de886SKip Macy if (duplex) 11989b4de886SKip Macy *duplex = DUPLEX_FULL; 11999b4de886SKip Macy return 0; 12009b4de886SKip Macy } 12019b4de886SKip Macy 1202b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 1203b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = { 1204b6d90eb7SKip Macy ael1006_reset, 12054af83c8cSKip Macy t3_phy_lasi_intr_enable, 12064af83c8cSKip Macy t3_phy_lasi_intr_disable, 12074af83c8cSKip Macy t3_phy_lasi_intr_clear, 12084af83c8cSKip Macy t3_phy_lasi_intr_handler, 1209b6d90eb7SKip Macy NULL, 1210b6d90eb7SKip Macy NULL, 1211b6d90eb7SKip Macy NULL, 1212b6d90eb7SKip Macy NULL, 1213b6d90eb7SKip Macy NULL, 12149b4de886SKip Macy get_link_status_x, 1215b6d90eb7SKip Macy ael1006_power_down, 1216b6d90eb7SKip Macy }; 1217b6d90eb7SKip Macy #else 1218b6d90eb7SKip Macy static struct cphy_ops qt2045_ops = { 1219b6d90eb7SKip Macy .reset = ael1006_reset, 12204af83c8cSKip Macy .intr_enable = t3_phy_lasi_intr_enable, 12214af83c8cSKip Macy .intr_disable = t3_phy_lasi_intr_disable, 12224af83c8cSKip Macy .intr_clear = t3_phy_lasi_intr_clear, 12234af83c8cSKip Macy .intr_handler = t3_phy_lasi_intr_handler, 12249b4de886SKip Macy .get_link_status = get_link_status_x, 1225b6d90eb7SKip Macy .power_down = ael1006_power_down, 1226b6d90eb7SKip Macy }; 1227b6d90eb7SKip Macy #endif 1228b6d90eb7SKip Macy 12298e10660fSKip Macy int t3_qt2045_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 1230b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 1231b6d90eb7SKip Macy { 1232b6d90eb7SKip Macy unsigned int stat; 1233b6d90eb7SKip Macy 12348e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &qt2045_ops, mdio_ops, 12358e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 12368e10660fSKip Macy "10GBASE-CX4"); 1237b6d90eb7SKip Macy 1238b6d90eb7SKip Macy /* 1239b6d90eb7SKip Macy * Some cards where the PHY is supposed to be at address 0 actually 1240b6d90eb7SKip Macy * have it at 1. 1241b6d90eb7SKip Macy */ 1242b6d90eb7SKip Macy if (!phy_addr && !mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, &stat) && 1243b6d90eb7SKip Macy stat == 0xffff) 1244b6d90eb7SKip Macy phy->addr = 1; 12458e10660fSKip Macy return 0; 1246b6d90eb7SKip Macy } 1247b6d90eb7SKip Macy 1248b6d90eb7SKip Macy static int xaui_direct_reset(struct cphy *phy, int wait) 1249b6d90eb7SKip Macy { 1250b6d90eb7SKip Macy return 0; 1251b6d90eb7SKip Macy } 1252b6d90eb7SKip Macy 1253b6d90eb7SKip Macy static int xaui_direct_get_link_status(struct cphy *phy, int *link_ok, 1254b6d90eb7SKip Macy int *speed, int *duplex, int *fc) 1255b6d90eb7SKip Macy { 1256b6d90eb7SKip Macy if (link_ok) { 1257b6d90eb7SKip Macy unsigned int status; 1258b6d90eb7SKip Macy 1259b6d90eb7SKip Macy status = t3_read_reg(phy->adapter, 1260ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT0, phy->addr)) | 1261ef72318fSKip Macy t3_read_reg(phy->adapter, 1262ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT1, phy->addr)) | 1263ef72318fSKip Macy t3_read_reg(phy->adapter, 1264ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT2, phy->addr)) | 1265ef72318fSKip Macy t3_read_reg(phy->adapter, 1266ef72318fSKip Macy XGM_REG(A_XGM_SERDES_STAT3, phy->addr)); 1267b6d90eb7SKip Macy *link_ok = !(status & F_LOWSIG0); 1268b6d90eb7SKip Macy } 1269b6d90eb7SKip Macy if (speed) 1270b6d90eb7SKip Macy *speed = SPEED_10000; 1271b6d90eb7SKip Macy if (duplex) 1272b6d90eb7SKip Macy *duplex = DUPLEX_FULL; 1273b6d90eb7SKip Macy return 0; 1274b6d90eb7SKip Macy } 1275b6d90eb7SKip Macy 1276b6d90eb7SKip Macy static int xaui_direct_power_down(struct cphy *phy, int enable) 1277b6d90eb7SKip Macy { 1278b6d90eb7SKip Macy return 0; 1279b6d90eb7SKip Macy } 1280b6d90eb7SKip Macy 1281b6d90eb7SKip Macy #ifdef C99_NOT_SUPPORTED 1282b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = { 1283b6d90eb7SKip Macy xaui_direct_reset, 1284b6d90eb7SKip Macy ael1002_intr_noop, 1285b6d90eb7SKip Macy ael1002_intr_noop, 1286b6d90eb7SKip Macy ael1002_intr_noop, 1287b6d90eb7SKip Macy ael1002_intr_noop, 1288b6d90eb7SKip Macy NULL, 1289b6d90eb7SKip Macy NULL, 1290b6d90eb7SKip Macy NULL, 1291b6d90eb7SKip Macy NULL, 1292b6d90eb7SKip Macy NULL, 1293b6d90eb7SKip Macy xaui_direct_get_link_status, 1294b6d90eb7SKip Macy xaui_direct_power_down, 1295b6d90eb7SKip Macy }; 1296b6d90eb7SKip Macy #else 1297b6d90eb7SKip Macy static struct cphy_ops xaui_direct_ops = { 1298b6d90eb7SKip Macy .reset = xaui_direct_reset, 1299b6d90eb7SKip Macy .intr_enable = ael1002_intr_noop, 1300b6d90eb7SKip Macy .intr_disable = ael1002_intr_noop, 1301b6d90eb7SKip Macy .intr_clear = ael1002_intr_noop, 1302b6d90eb7SKip Macy .intr_handler = ael1002_intr_noop, 1303b6d90eb7SKip Macy .get_link_status = xaui_direct_get_link_status, 1304b6d90eb7SKip Macy .power_down = xaui_direct_power_down, 1305b6d90eb7SKip Macy }; 1306b6d90eb7SKip Macy #endif 1307b6d90eb7SKip Macy 13088e10660fSKip Macy int t3_xaui_direct_phy_prep(struct cphy *phy, adapter_t *adapter, int phy_addr, 1309b6d90eb7SKip Macy const struct mdio_ops *mdio_ops) 1310b6d90eb7SKip Macy { 13118e10660fSKip Macy cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops, 13128e10660fSKip Macy SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 13138e10660fSKip Macy "10GBASE-CX4"); 13148e10660fSKip Macy return 0; 1315b6d90eb7SKip Macy } 1316