From patchwork Fri Nov 23 09:36:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Onnasch, Alexander (EXT)" X-Patchwork-Id: 1002221 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=landisgyr.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=landisgyr.com header.i=@landisgyr.com header.b="l2Ya1AyW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431WQt62F3z9sCV for ; Fri, 23 Nov 2018 20:36:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409121AbeKWUTq (ORCPT ); Fri, 23 Nov 2018 15:19:46 -0500 Received: from mail-eopbgr130127.outbound.protection.outlook.com ([40.107.13.127]:33815 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387987AbeKWUTq (ORCPT ); Fri, 23 Nov 2018 15:19:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landisgyr.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5YM/MY8UKFllEOEmubel7q2TjxUWWKONwySE1py5xaE=; b=l2Ya1AyWh5cmGwTgvKN0+Is7jvBNAbFg+YR3HgJIRNwl1MCiq0r5iwnG6PVVbe46yni7kLzShR8B1XftURMTrZ/tbQuGuRL/9423hBah4RbYaSajxAah7saK38vnOQMA0xz/oGK7PafrOaPWeVSaeMmD68AklKA3e4xZA+jjJ/M= Received: from AM6PR01MB4262.eurprd01.prod.exchangelabs.com (20.176.242.28) by AM6PR01MB5042.eurprd01.prod.exchangelabs.com (20.177.188.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.28; Fri, 23 Nov 2018 09:36:11 +0000 Received: from AM6PR01MB4262.eurprd01.prod.exchangelabs.com ([fe80::d547:38d1:d542:d499]) by AM6PR01MB4262.eurprd01.prod.exchangelabs.com ([fe80::d547:38d1:d542:d499%4]) with mapi id 15.20.1361.018; Fri, 23 Nov 2018 09:36:11 +0000 From: "Onnasch, Alexander (EXT)" CC: "Onnasch, Alexander (EXT)" , Andrew Lunn , Florian Fainelli , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH v2 net] phy: Micrel KSZ8061: link failure after cable connect Thread-Topic: [PATCH v2 net] phy: Micrel KSZ8061: link failure after cable connect Thread-Index: AQHUgw/47vC48FtyF0moC2bokhV8ng== Date: Fri, 23 Nov 2018 09:36:11 +0000 Message-ID: <1542965762-26822-1-git-send-email-alexander.onnasch@landisgyr.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR07CA0269.eurprd07.prod.outlook.com (2603:10a6:803:b4::36) To AM6PR01MB4262.eurprd01.prod.exchangelabs.com (2603:10a6:20b:20::28) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [80.239.165.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR01MB5042; 6:ZjmYOg5pgOhcnBkXKF1ftVKGbykFhzUJVlnWkNq/aWSDnJ6K5hXRWKa8l5XeR9bkpmlVCvaNwIUatWTJYxL25VsEFNW8RfMTfa3jMHuZXZZXlUlB94CmEKqDf2pLOxiNof6zbS6YutzsrnEWaU1WwJ91UrhQwwDKm7JOfgQHdnIEHBDp2se91Y+2maXeaT3Sj7uIHxYnNeYMHcIiAnXj2NiC7V/9UtghzgmQU+UoQ8F3enxR0y3vm15ut+rOtvp0OqpZGLW7gI8/O/Jg92LT/UQ8knFAvP20MQvkoHI/7SiaujfHdgqLf0djECoXiCE3d+cA9lYJwKOOUhbxgqxulS8tTMNWGaVwosW2Hdixz0gKEL82GkX83qhdsIB5PU5iCu7t3n4+fA3a81ER5T7hekBIkqbDbAl2bv80eJ5Ow0hq0X2a8z2M7dbF3UyhcwHKpFSW407T7e6uLXIG//6SRw==; 5:VAzUUiNek7UyEaQh47DgDCyxWM0sgB8DtWvSy/t95c4hZSU3tZ6/Cnx7DUAKEImaZbiIeDuZ1u5l0Nc9ypRibbkWlC8eTWqFQUrUfYwfXM9wc4i7cQZVVzPqMU4tsJhlGFCI5H7eVSId4f3JXmOjPCC87vLoH+OB7Sic8aCIQMM=; 7:kEEm3L49ze+C89Hy5cgLeiKReOpAlInEFn+I7+iOivZgpyN672Ctv/wUmPIkFj42dRYr+1A6Eg8wdTaGhFlybW12kMpTShr5eB4VzbSf/gYebpAECSjGzSgfW9m5+cj1nJwPFVEz5oVgVptBwRgR/w== x-ms-office365-filtering-correlation-id: ff122224-ce7d-4f3a-00b1-08d651271a69 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR01MB5042; x-ms-traffictypediagnostic: AM6PR01MB5042: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Onnasch@landisgyr.com; x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:AM6PR01MB5042; BCL:0; PCL:0; RULEID:; SRVR:AM6PR01MB5042; x-forefront-prvs: 086597191B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(346002)(136003)(376002)(396003)(366004)(199004)(189003)(59246006)(5660300001)(106356001)(305945005)(6116002)(7736002)(105586002)(3846002)(54906003)(36756003)(72206003)(478600001)(316002)(25786009)(8676002)(2900100001)(66066001)(8936002)(14454004)(81156014)(81166006)(86362001)(97736004)(53936002)(1671002)(71200400001)(71190400001)(52116002)(6436002)(256004)(14444005)(109986005)(39060400002)(26005)(186003)(4326008)(68736007)(6506007)(102836004)(6512007)(386003)(476003)(2616005)(486006)(99286004)(2906002)(6486002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM6PR01MB5042; H:AM6PR01MB4262.eurprd01.prod.exchangelabs.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: landisgyr.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: pt0AT2zWNihVdnmpkRFxt6dFMD/E2IimUpd6fngmRPzdcZ0MAtZ3926UTLJGtX6LJj/YTEHOYnNo8Ac3D0CW/L83mwzxfEMZHHSX2iQzimMTam/Hh5h980cyiJIMwmq31wXZoOS/zgr5mQVZLqaIep5XrsnuoUd96v7XrK1PJiKnqCAPae3AKL6oPZ5TW5YZB9dVNGYb4Su2dKi98OEBnoHqY5nWgOh5UdMVLSFk6lyX19PMW+aHaKt3N4sAnLsV2iAMrVbkF+dLXlaXhFKOqymuPn0oDd+yGcseUOp8THB8SZIW9PBND3AiqeyZOiF4aHnBmSWmXKMzfcLOm09K/HGhvkpOzBfQP5zvGG548tQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: landisgyr.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff122224-ce7d-4f3a-00b1-08d651271a69 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2018 09:36:11.0667 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: ee2cd48b-958f-4be4-9852-b8f104c001b9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR01MB5042 To: unlisted-recipients:; (no To-header on input) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With Micrel KSZ8061 PHY, the link may occasionally not come up after Ethernet cable connect. The vendor's (Microchip, former Micrel) errata sheet 80000688A.pdf describes the problem and possible workarounds in detail, see below. The patch implements workaround 1, which permanently fixes the issue. DESCRIPTION Link-up may not occur properly when the Ethernet cable is initially connected. This issue occurs more commonly when the cable is connected slowly, but it may occur any time a cable is connected. This issue occurs in the auto-negotiation circuit, and will not occur if auto-negotiation is disabled (which requires that the two link partners be set to the same speed and duplex). END USER IMPLICATIONS When this issue occurs, link is not established. Subsequent cable plug/unplug cycles will not correct the issue. WORK AROUND There are four approaches to work around this issue: 1. This issue can be prevented by setting bit 15 in MMD device address 1, register 2, prior to connecting the cable or prior to setting the Restart Auto-Negotiation bit in register 0h.The MMD registers are accessed via the indirect access registers Dh and Eh, or via the Micrel EthUtil utility as shown here: • If using the EthUtil utility (usually with a Micrel KSZ8061 Evaluation Board), type the following commands: > address 1 > mmd 1 > iw 2 b61a • Alternatively, write the following registers to write to the indirect MMD register: Write register Dh, data 0001h Write register Eh, data 0002h Write register Dh, data 4001h Write register Eh, data B61Ah 2. The issue can be avoided by disabling auto-negotiation in the KSZ8061, either by the strapping option, or by clearing bit 12 in register 0h. Care must be taken to ensure that the KSZ8061 and the link partner will link with the same speed and duplex. Note that the KSZ8061 defaults to full-duplex when auto-negotiation is off, but other devices may default to half-duplex in the event of failed auto-negotiation. 3. The issue can be avoided by connecting the cable prior to powering-up or resetting the KSZ8061, and leaving it plugged in thereafter. 4. If the above measures are not taken and the problem occurs, link can be recovered by setting the Restart Auto-Negotiation bit in register 0h, or by resetting or power cycling the device. Reset may be either hardware reset or software reset (register 0h, bit 15). PLAN This errata will not be corrected in a future revision. Signed-off-by: Alexander Onnasch Reviewed-by: Andrew Lunn --- drivers/net/phy/micrel.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 6c45ff6..eb85cf4 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -339,6 +339,17 @@ static int ksz8041_config_aneg(struct phy_device *phydev) return genphy_config_aneg(phydev); } +static int ksz8061_config_init(struct phy_device *phydev) +{ + int ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A); + if (ret) + return ret; + + return kszphy_config_init(phydev); +} + static int ksz9021_load_values_from_of(struct phy_device *phydev, const struct device_node *of_node, u16 reg, @@ -938,7 +949,7 @@ static struct phy_driver ksphy_driver[] = { .phy_id_mask = MICREL_PHY_ID_MASK, .features = PHY_BASIC_FEATURES, .flags = PHY_HAS_INTERRUPT, - .config_init = kszphy_config_init, + .config_init = ksz8061_config_init, .config_aneg = genphy_config_aneg, .read_status = genphy_read_status, .ack_interrupt = kszphy_ack_interrupt,