Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp194465lqs; Mon, 4 Mar 2024 21:43:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3q+9TiStdwIOCVOQOJvqL9Dzd2+nb5AETDDtVA91i/idT90TlshMrElGEs5YNjkGz/Ayn7RjT/YdEp5FZHXRR98xoEEuCRnZ6Z5XcQw== X-Google-Smtp-Source: AGHT+IFrDrFrdwNc0hhppr42hgWbSWnlee8LyjRSyMyjRJ4wm8nxh1oe07VPM/wAAs8m/n93WLiz X-Received: by 2002:ac2:5e8c:0:b0:513:2a84:c45c with SMTP id b12-20020ac25e8c000000b005132a84c45cmr612510lfq.28.1709617425410; Mon, 04 Mar 2024 21:43:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709617425; cv=pass; d=google.com; s=arc-20160816; b=lM6Fs9yvi20hqN9I79/7Cecun3URrshQeQLhatPTNLKFEXgPoQ+V480a4RWvuZTxQd t97M4so2V26krq0PO93nx9fL5L+5hq6CqsXBpPIcqknYD5Y4ETErnLRookk/iEE4w4B0 /OIaKNAzjrapgnmZOQgOF1Pg4l9ArVa892jjQSZSrFj7b1iVzAhMRXreFleug56rtqzA axB1uEnsnlD35k+bfKuaryAk4DJp2o1emnob2ntsMo2ANWj4IOWtUNC9FvS8VfoAPlt/ zXmyI9e2VT9QZvWB1NS0Lv2x0bbIA7KAGEuP4iFtqOZDDI1EfPlQXRiMyiWXuOGkDyu1 emWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=m3G7uqGep2jRTiY2MUFrRQpXBp2XUJrcB1aaHLU8GHM=; fh=o0eNrSXk7qABnqrBNE7iFfIW+IBhLIsoGsOoYuPJQd8=; b=IQxgmzi/cy+XDz5ShC70BTW0v/6LDVeIaeCl68vkFSyP1E7DJ9LvwaScP6UIXkpsGv ficeSQojsDrirY63W2xv3ANc/kO6zJhE4Utoovbc2pZO4IXOSd7mP4aYCtoSOsx7AlUc iHAC/DmztUl8FTr+DHK3gTTXnxtU8dvES5hlwflem+ZyuWtmIeRZy7t+6WoqLebWA3VZ jtjWr9TD7aAi70UxdGiMsFgik4dAB8Q20L5hbo9yAZcxdcSA/yO3ielnjVlQZBlVoBhS Q6LopE23ITaUBj05KAQpwfKOZl6OmSHRlqWbjDVhPEwAWwhtl/AqO/QUWqCtOKa4FM8k cjBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@risingedge.co.za header.s=xneelo header.b=vT1SgjPm; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-91697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91697-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d8-20020a1709067f0800b00a43fb764339si4698141ejr.365.2024.03.04.21.43.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 21:43:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@risingedge.co.za header.s=xneelo header.b=vT1SgjPm; arc=pass (i=1 spf=pass spfdomain=risingedge.co.za dkim=pass dkdomain=risingedge.co.za); spf=pass (google.com: domain of linux-kernel+bounces-91697-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91697-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C11AC1F22365 for ; Tue, 5 Mar 2024 05:43:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AD5862178; Tue, 5 Mar 2024 05:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b="vT1SgjPm" Received: from outgoing4.flk.host-h.net (outgoing4.flk.host-h.net [188.40.0.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80ECAAD5E; Tue, 5 Mar 2024 05:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.0.90 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709617413; cv=none; b=dEQ8isIgcO5ZUTfIw70vnd+THcfupf5MJaDP5Up2+AyG5XGI4tj1/MHc5q7L9RjImN9tv1iZCBx7K8g08vQpzOLVOZX4SbHwJQsPXAJrZKNx6IM1Q7xomeEOS64yipiJTXz51cbpw9G7LCvurN6Ibk0Kpvle/LAj7eh0JO3O/r8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709617413; c=relaxed/simple; bh=jHCkCAy59+qTROMlQoxSDLh+kDJYlZc1/bee+CxnHbU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=r8PnVqlKMh2EPGFXTOZ1nj2aTBRjjiiDNOLG7jon2bTR9QkaVr8Wdu/a7ybT2Oarc3DgFwlUuut6Be8QJgcISKqs3jORcrr1srgSkYoiBYoUiustfllCuRB9o6N8C47uDxCRsTmqIvqgQ0d0FbiaOQx17TLTMxYm05ZpxnyKtPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za; spf=pass smtp.mailfrom=risingedge.co.za; dkim=pass (2048-bit key) header.d=risingedge.co.za header.i=@risingedge.co.za header.b=vT1SgjPm; arc=none smtp.client-ip=188.40.0.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=risingedge.co.za Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=risingedge.co.za DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=risingedge.co.za; s=xneelo; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc:in-reply-to:references :content-type; bh=m3G7uqGep2jRTiY2MUFrRQpXBp2XUJrcB1aaHLU8GHM=; b=vT1SgjPmcYN d1lFD6XiX8in9sqYFQRcj8Eoa8XyyDdh15JEydux/xq/eVD5DNWGqiDUixS6S2adw2tk62pafAA87 51h1dmdbGKc1JoPe4ytB4NSOgIXYV7sNUqfA6ZeYjsBFrKaw1Vcr1hfUfFU4Eua8b+8hhnZmBhQyv pzrdKh3GzmHc+VR7ZsPkoZyiDSn/y4/fJd0RoXu0VTv9VjMXdNLbaDxuR+umJrjSPDBAow/kl8EVb x//uqAlDcr6nFnqG7hGH+AEmS7ckGTVJn8GfZAb3YU+OCCkjoRu5Tu6NI2t+R15YUW990vC4eE2Fc 62IwLFzyd8PO+eCqW50XQ7A==; Received: from www31.flk1.host-h.net ([188.40.1.173]) by antispam1-flk1.host-h.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rhMbc-00HBd3-Hf; Tue, 05 Mar 2024 06:40:47 +0200 Received: from [41.144.0.96] (helo=localhost.localdomain) by www31.flk1.host-h.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rhMbW-0005M8-1G; Tue, 05 Mar 2024 06:40:38 +0200 From: Justin Swartz To: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Daniel Golle , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: Justin Swartz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] net: dsa: mt7530: disable LEDs before reset Date: Tue, 5 Mar 2024 06:39:51 +0200 Message-Id: <20240305043952.21590-1-justin.swartz@risingedge.co.za> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: justin.swartz@risingedge.co.za X-Virus-Scanned: Clear X-SpamExperts-Domain: risingedge.co.za X-SpamExperts-Username: Authentication-Results: host-h.net; auth=pass (login) smtp.auth=@risingedge.co.za X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT8bSAwkwoC1TJJiWLFQYyDsPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wCPRB8bAzJcv2cv+UqiTTc2+CpNcmBnO4XM3Sck4bwNogU WCl1nkLBzZX0KuJ9bXiS85Z42w/+2OBolTNFbPomXFWCX8oNdggW7HE9XDTdSejrkEpbuUvwMvHx 3T+KSG//gbuP7hnUK8NQdLwsVWKIv+fXqqb3FJ1Z7kkAIev0U9CKH/oA07tJunDPm536TODb5GPR oyaaXp1VNA9dXvxV+mFktoWo3CKg4C3LDJ75vu2U4GT70q7ZqN/P49BncZ5XB7lfx9K88uL/WnJE LAE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lzLxTUJwIIDSVMZhrIoAWTF5tIdhy/UIEBYDcZg+Q8UhuRLyBn1+pvlH hV6a5QjptwQBGybQyDQ2/GYwPjlMcE57ESN6G+kn87CtwPdB/10jfVNpDbYnXJdSRQj8460WHJib IxmU2pb4i4DTkMZeMiNI9JSIyUbtnrlbG4BI8o81FOo91axhCaqPShJzgHH7y4ZfQxML X-Report-Abuse-To: spam@antispamquarantine.host-h.net Disable LEDs just before resetting the MT7530 to avoid situations where the ESW_P4_LED_0 and ESW_P3_LED_0 pin states may cause an unintended external crystal frequency to be selected. The HT_XTAL_FSEL (External Crystal Frequency Selection) field of HWTRAP (the Hardware Trap register) stores a 2-bit value that represents the state of the ESW_P4_LED_0 and ESW_P4_LED_0 pins (seemingly) sampled just after the MT7530 has been reset, as: ESW_P4_LED_0 ESW_P3_LED_0 Frequency ----------------------------------------- 0 1 20MHz 1 0 40MHz 1 1 25MHz The value of HT_XTAL_FSEL is bootstrapped by pulling ESW_P4_LED_0 and ESW_P3_LED_0 up or down accordingly, but: if a 40MHz crystal has been selected and the ESW_P3_LED_0 pin is high during reset, or a 20MHz crystal has been selected and the ESW_P4_LED_0 pin is high during reset, then the value of HT_XTAL_FSEL will indicate that a 25MHz crystal is present. By default, the state of the LED pins is PHY controlled to reflect the link state. To illustrate, if a board has: 5 ports with active low LED control, and HT_XTAL_FSEL bootstrapped for 40MHz. When the MT7530 is powered up without any external connection, only the LED associated with Port 3 is illuminated as ESW_P3_LED_0 is low. In this state, directly after mt7530_setup()'s reset is performed, the HWTRAP register (0x7800) reflects the intended HT_XTAL_FSEL (HWTRAP bits 10:9) of 40MHz: mt7530-mdio mdio-bus:1f: mt7530_read: 00007800 == 00007dcf >>> bin(0x7dcf >> 9 & 0b11) '0b10' But if a cable is connected to Port 3 and the link is active before mt7530_setup()'s reset takes place, then HT_XTAL_FSEL seems to be set for 25MHz: mt7530-mdio mdio-bus:1f: mt7530_read: 00007800 == 00007fcf >>> bin(0x7fcf >> 9 & 0b11) '0b11' Once HT_XTAL_FSEL reflects 25MHz, none of the ports are functional until the MT7621 (or MT7530 itself) is reset. By disabling the LED pins just before reset, the chance of an unintended HT_XTAL_FSEL value is reduced. Signed-off-by: Justin Swartz --- drivers/net/dsa/mt7530.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 3c1f65759..8fa113126 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2238,6 +2238,12 @@ mt7530_setup(struct dsa_switch *ds) } } + /* Disable LEDs before reset to prevent the MT7530 sampling a + * potentially incorrect HT_XTAL_FSEL value. + */ + mt7530_write(priv, MT7530_LED_EN, 0); + usleep_range(1000, 1100); + /* Reset whole chip through gpio pin or memory-mapped registers for * different type of hardware */ --