From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B4AB258CDF for ; Sat, 29 Nov 2025 23:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764460002; cv=none; b=QQQAIKLWEEDWBhHFbJb5UK0V3AYnA3aEUS15TQcpNWYHz1/Rtyjhzu2AlXJJhCdG5rpEl/JJwG0jUsZr3VLnyyXOLr9fUPbS2TdZky4ySfsFFA5vCedE1A3kih7OCt1i+SwoN5PBX4Wd2Tj/R9Vps5XsuLEkJqS7lOoy6nfcH1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764460002; c=relaxed/simple; bh=3Q77GzV4sA5JKej1QZN72HJTq4PSRxUUmeBLAOVou+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=n8mzSgMhOgXtl89zK48HZDhBfKQ+pnXg+7EJAjSuUK9pky0UZTNYAAw7I/ZMZmVDPWoeCtlRKIl69DxelrjZee3NeeJztxfdJK/G/Xj/rAXXEjCl1tHs8uJuHbFAB79fpm6St4RsZnZQEoVxjqEHxD3T4rF51zXkRUoUsW1kBzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sglf0lsf; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sglf0lsf" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7b852bb31d9so3431683b3a.0 for ; Sat, 29 Nov 2025 15:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764460001; x=1765064801; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qCXAC0GBbAxPWdhq7j/4nJ+adBCJDMjQOJVyf/bKFTU=; b=Sglf0lsfhUVN5uOEcCv/mbS2A3yybxeFo/cUrCEkSVTgu+M0sTfdOkHdMk6V+ELI/y IVLOJosROGDTM7jy8FtOKu4F4GGDicBl2EMGF1/05cwgYMJEVO6Qt90zQER4a823G5XI aohZ3q5XeTMXAU2LnDW381ldThlX9expxbrShENYlu7/Zff9iwXu5MhgrKiW/NCABPVA PCZjuIMkEpRyM+PXmsJ//mEoJdubF8h5wQG0Ow8U1vxZ9jdvk79i5jd6qFwkCNyu+XC0 G1o10reIAO4iCIoNKnYwW+FaLGi04CRQklqEQGlISQlHWnLy53Hy+kKQOBMTV7OZd7P5 /KBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764460001; x=1765064801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qCXAC0GBbAxPWdhq7j/4nJ+adBCJDMjQOJVyf/bKFTU=; b=i1AEwh2XerCF7bRbMfdTdhDgUtqbtFzS/RPnEn4eT+LjyQRomd7y2U9zad1j+SIxiA jjEO4me6XSBY3zmZpClLYzPyjczCb5b3drbbKqyEBq1xmx69fUsX21zVhAvPqtlVCO4H UJ74IJZO+gzJwac73Ll5EVBlBVBymiX664T0/165NiKSJNb7TqN6HnTinaTQdVkRU7us gC/oQI9SVk4nK+RYbnj4Wco7Ku2F50ZloDygVV+xj5iYF42aPNB2nwazgFDD4dbx/zK+ EyBqVPk+2o3bUF/dSZIXP+VUktAQwI5cvysyv4tw1HnLsKwIf2jPxOe6o6vO6wDRmjOW 3eVg== X-Gm-Message-State: AOJu0Yw7aOYu6h9upJ/Zikn84K5vE55bKMgyOo13QKtuUUpJAfMGLpE3 yBpy82OJ91balXOiNYLVK+gXfMhZ5KZ8kaKVc3bmb1ppArSuvvzbfApl X-Gm-Gg: ASbGncvPGdxtPR19u1mQJVJKiXV/HdhENiY7e/ZvzN8XW8J5yVdWFLIbEzH0MiYRAtC i+Y3Y1VkCvrnEkdmc9Eun696o2yQYmKuu7VGcEsEnYRTllJfVvDBCxaQlOteNY7d/SqbmiArQsF mhKO8w0onnUlwSMDWQg5/9bAUPNpc/t3uRRTRZyz5xf16Z02/MRaOuiZ7LgvNUgkEmQky6zlIZm zM3uICelfuGcIRmPSx+MMhLpQzaV1OVTDiSZ4PuvaiCZw4prXsHTKyslhisH06DXxDZJXhwcDoC IgD5GIxMgohzHNaGK/o0Abu2rlLjcicEIrcRUWf7bORVbq+n0UhDBs9uIqLpqCnSjMWdu9X2ATB /jrFDlXD3+muN8Z7oaDyfdwU+n/15PwHGvaOgypwkLCFgONJJYdLaZ5nOfSrx1ZhvefUvw1q7X2 dwwO5Z X-Google-Smtp-Source: AGHT+IEvcsMa5l/AhUy3wA67rw2nUoJkcI0nAX7R5RA7tZwpSoC+/PEIe8H7hubTPSio4L+mBgUalw== X-Received: by 2002:a05:6a20:3d1a:b0:34f:47f8:cca2 with SMTP id adf61e73a8af0-36150f424b2mr33755297637.58.1764460000749; Sat, 29 Nov 2025 15:46:40 -0800 (PST) Received: from SC-GAME.lan ([104.28.201.78]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15fc08bd1sm8921049b3a.63.2025.11.29.15.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 15:46:40 -0800 (PST) From: Chen Minqiang To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , "Chester A. Unal" , Daniel Golle , DENG Qingfang , Sean Wang , Andrew Lunn Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, Chen Minqiang Subject: [PATCH v3 2/2] net: dsa: mt7530: Use GPIO polarity to generate correct reset sequence Date: Sun, 30 Nov 2025 07:46:03 +0800 Message-Id: <20251129234603.2544-2-ptpt52@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20251129234603.2544-1-ptpt52@gmail.com> References: <20251129234603.2544-1-ptpt52@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MT7530/MT7531 reset pin is active-low in hardware, but the driver historically hardcoded a high-active reset sequence by toggling the GPIO as 0 → 1. This only worked because several DTS files incorrectly marked the reset GPIO as active-high, making both DTS and driver wrong in the same way. This patch changes the driver to respect the GPIO polarity using gpiod_is_active_low(), and generates the reset sequence as: assert = drive logical active level deassert = drive logical inactive level As a result, both cases now correctly produce the required high → low → high transition on the actual reset pin. Compatibility ------------- This change makes the driver fully backward-compatible with older, incorrect DTS files that marked the reset line as GPIO_ACTIVE_HIGH: * Old DTS marked active-high: is_active_low = 0 driver drives 0 → 1 actual levels: high → low → high (correct) * New DTS marked active-low: is_active_low = 1 driver drives 1 → 0 actual levels: high → low → high (correct) Therefore, regardless of whether a DTS is old or new, correct or incorrect, the driver now generates the correct electrical reset pulse. Going forward, DTS files should use GPIO_ACTIVE_LOW to match the hardware, but no regressions will occur with older DTS blobs. Signed-off-by: Chen Minqiang --- drivers/net/dsa/mt7530.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 548b85befbf4..615e9a5709ca 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2405,9 +2405,10 @@ mt7530_setup(struct dsa_switch *ds) usleep_range(5000, 5100); reset_control_deassert(priv->rstc); } else { - gpiod_set_value_cansleep(priv->reset, 0); + int is_active_low = !!gpiod_is_active_low(priv->reset); + gpiod_set_value_cansleep(priv->reset, is_active_low); usleep_range(5000, 5100); - gpiod_set_value_cansleep(priv->reset, 1); + gpiod_set_value_cansleep(priv->reset, !is_active_low); } /* Waiting for MT7530 got to stable */ @@ -2643,9 +2644,10 @@ mt7531_setup(struct dsa_switch *ds) usleep_range(5000, 5100); reset_control_deassert(priv->rstc); } else { - gpiod_set_value_cansleep(priv->reset, 0); + int is_active_low = !!gpiod_is_active_low(priv->reset); + gpiod_set_value_cansleep(priv->reset, is_active_low); usleep_range(5000, 5100); - gpiod_set_value_cansleep(priv->reset, 1); + gpiod_set_value_cansleep(priv->reset, !is_active_low); } /* Waiting for MT7530 got to stable */ -- 2.17.1