From patchwork Wed Sep 9 10:04:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 261264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F02CC43461 for ; Wed, 9 Sep 2020 10:04:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CE7121D7A for ; Wed, 9 Sep 2020 10:04:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="boqs782B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgIIKEo (ORCPT ); Wed, 9 Sep 2020 06:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbgIIKEf (ORCPT ); Wed, 9 Sep 2020 06:04:35 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F02BC061755 for ; Wed, 9 Sep 2020 03:04:35 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id y15so1753200wmi.0 for ; Wed, 09 Sep 2020 03:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GwN0+i/cI/n/+0mqzm/sKQPMpFX4gdPhYIC5uk3bMbQ=; b=boqs782B2W+C5l6qBV381hB/DTlNglszD1gTKGL5qNNp2eEM8I2dRcEOBQq90bZJRM GAvUYHNAibM2oWAPWSzZYJC1Or5MRZqhOezyQXteQvSoD2quJTkK/EgQBVAz0j3lWMpy zdMLJYUuyLGEg8pjez6mKMMFtQH7zvNFrWUf4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GwN0+i/cI/n/+0mqzm/sKQPMpFX4gdPhYIC5uk3bMbQ=; b=d+7cFuQiOWzb9M/HH9jpC55vF7l2H3bN3Shh5DvUx9x2iv2AekmQOlK8qFm0ZXscfr Gm/YJPRl+Q3Vp7OsrfniDtDh0Yb6bQepgB+wfFWq4YX5XW/i2ZBf5MMXcxWwx9Vc93c3 x5Z5cuszFbE1ig7BtF5slDXiMhE6m2dLu/4YmukV146NGAcmIH06bAx6rxEskOKXtVR6 m6kUIB2PlhInCHPqSI4MLoHDglw6qT7MfuL5bptNxaItAPPTxC0hNUBqy7KMlN0ZfxOd w+MKPN7qGkieMY56wmXLvcXG9Dw0KtvZhKdpGopYdgUblrxHbUhUGCOEFKhPvWp6nk3/ swlg== X-Gm-Message-State: AOAM533zRiYJbgAXqn7Cw98+E56rgw76jM1HPt0KJcMK6hpRqP/O9xMy scKtVsocLXdq8F7E/4hA/mEM3w== X-Google-Smtp-Source: ABdhPJxRg3eSGd/mkl5lmr8frJ6I4Rdr+h739do/YtaV3JyH4Mz2h4mMjHbszBUgUoPv0gQMACrafg== X-Received: by 2002:a7b:c404:: with SMTP id k4mr2247339wmi.168.1599645874087; Wed, 09 Sep 2020 03:04:34 -0700 (PDT) Received: from ar2.home.b5net.uk ([213.48.11.149]) by smtp.gmail.com with ESMTPSA id l16sm3828237wrb.70.2020.09.09.03.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 03:04:33 -0700 (PDT) From: Paul Barker To: Woojung Huh , Microchip Linux Driver Support , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S . Miller" Cc: Paul Barker , netdev@vger.kernel.org Subject: [PATCH v3 1/4] net: dsa: microchip: Make switch detection more informative Date: Wed, 9 Sep 2020 11:04:14 +0100 Message-Id: <20200909100417.380011-2-pbarker@konsulko.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909100417.380011-1-pbarker@konsulko.com> References: <20200909100417.380011-1-pbarker@konsulko.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org To make switch detection more informative print the result of the ksz9477/ksz9893 compatibility check. With debug output enabled also print the contents of the Chip ID registers as a 40-bit hex string. As this detection is the first communication with the switch performed by the driver, making it easy to see any errors here will help identify issues with SPI data corruption or reset sequencing. Signed-off-by: Paul Barker Reviewed-by: Florian Fainelli --- drivers/net/dsa/microchip/ksz9477.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 3cb22d149813..df5ecd0261fa 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1426,10 +1426,12 @@ static int ksz9477_switch_detect(struct ksz_device *dev) /* Default capability is gigabit capable. */ dev->features = GBIT_SUPPORT; + dev_dbg(dev->dev, "Switch detect: ID=%08x%02x\n", id32, data8); id_hi = (u8)(id32 >> 16); id_lo = (u8)(id32 >> 8); if ((id_lo & 0xf) == 3) { /* Chip is from KSZ9893 design. */ + dev_info(dev->dev, "Found KSZ9893\n"); dev->features |= IS_9893; /* Chip does not support gigabit. */ @@ -1438,6 +1440,7 @@ static int ksz9477_switch_detect(struct ksz_device *dev) dev->mib_port_cnt = 3; dev->phy_port_cnt = 2; } else { + dev_info(dev->dev, "Found KSZ9477 or compatible\n"); /* Chip uses new XMII register definitions. */ dev->features |= NEW_XMII; From patchwork Wed Sep 9 10:04:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 261263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0163C43461 for ; Wed, 9 Sep 2020 10:04:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EE8221D7A for ; Wed, 9 Sep 2020 10:04:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="EsiWTg2D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728360AbgIIKEs (ORCPT ); Wed, 9 Sep 2020 06:04:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgIIKEi (ORCPT ); Wed, 9 Sep 2020 06:04:38 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7F9C061755 for ; Wed, 9 Sep 2020 03:04:38 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id c18so2252701wrm.9 for ; Wed, 09 Sep 2020 03:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pRUN7p1qzh/z0sF2kkFkWXZEvmC67k/rtM33VZEr1RY=; b=EsiWTg2DgucOy7ksi0tfoaZP/MIDdLVdJK6TrCTZfdujWCAm0vtNaoQsxNyys0HHjk UN/wZNC1fFhLtMWN+LqYZLyzaHHa7QBPfVqxj0zSMTOqwF4DSYX5WDXnEPP2otEm4VgA +IKEqwFdqSbPfJrSTn/N4fMX11qScykaIqZig= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pRUN7p1qzh/z0sF2kkFkWXZEvmC67k/rtM33VZEr1RY=; b=dPZlpcaOn5fxpofMjKluvkenic6RPMb4hZKYUk6o63Na1MwFDC/J9iWQSTO6Supy6g doSYyjZKtQnNtpOKyMp5lF/7jBakenwXFlz/zzHynkMF9gjlk8qCezgOr6ap7LNueWcK NojvAcfA4JgCigfsF14KlyHYGjgp7i8QKoWMH5ZQGvOrmjc0+UiINk/G8ubyUlBtKFBS GaHoYnl6uXMnYMr5mn6gtKooiGaza4YtCyLU2cV6xihMroS33oGutIkE1FEJX/71QWCP VB8Ctmg6nwczg4YbNDk9rUmsUOyVLG/306rrD1HJa4lLkMy41pohcqCEbPGzt19KL9Qs H7cw== X-Gm-Message-State: AOAM533m3ITvj9ZMAoqdM+oonvvtqOqyI0V1UNFhJM/ykn1AsJUwbpqi RnsbKZAUTnTzQBw199b3etpOqA== X-Google-Smtp-Source: ABdhPJzswvZt4mmoAPxtvxnzDKiIP+BRMmg7AkmT1c0NdWDTfK22qJv1fOUxhe0V0WqcmqSOfNvRqg== X-Received: by 2002:a5d:60cc:: with SMTP id x12mr3132553wrt.84.1599645876890; Wed, 09 Sep 2020 03:04:36 -0700 (PDT) Received: from ar2.home.b5net.uk ([213.48.11.149]) by smtp.gmail.com with ESMTPSA id l16sm3828237wrb.70.2020.09.09.03.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 03:04:36 -0700 (PDT) From: Paul Barker To: Woojung Huh , Microchip Linux Driver Support , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S . Miller" Cc: Paul Barker , netdev@vger.kernel.org Subject: [PATCH v3 4/4] net: dsa: microchip: Implement recommended reset timing Date: Wed, 9 Sep 2020 11:04:17 +0100 Message-Id: <20200909100417.380011-5-pbarker@konsulko.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909100417.380011-1-pbarker@konsulko.com> References: <20200909100417.380011-1-pbarker@konsulko.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The datasheet for the ksz9893 and ksz9477 switches recommend waiting at least 100us after the de-assertion of reset before trying to program the device through any interface. Also switch the existing msleep() call to usleep_range() as recommended in Documentation/timers/timers-howto.rst. The 2ms range used here is somewhat arbitrary, as long as the reset is asserted for at least 10ms we should be ok. Signed-off-by: Paul Barker Reviewed-by: Florian Fainelli --- drivers/net/dsa/microchip/ksz_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 8d53b12d40a8..a31738662d95 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -400,8 +400,9 @@ int ksz_switch_register(struct ksz_device *dev, if (dev->reset_gpio) { gpiod_set_value_cansleep(dev->reset_gpio, 1); - mdelay(10); + usleep_range(10000, 12000); gpiod_set_value_cansleep(dev->reset_gpio, 0); + usleep_range(100, 1000); } mutex_init(&dev->dev_mutex);