From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 B09562F6910 for ; Fri, 5 Jun 2026 01:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621246; cv=none; b=koUedXiFEpkcuL7rESRJJLHTEot19jECt7kTpAWXuV/2yva53QgEg7mJ4onoB+5sLHy48Jro/SSskd/kI1P890p4ZLb5DEDHAGCJLLq1KEUzgyekfVVvCBA1zOK2WuaQscIk1wB6IRk8MNUfGH3CbZkfreMZuO0lAZ8nsfuh+MM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621246; c=relaxed/simple; bh=Tnu576MfKVY9CS43sYUQz8GphW2+pJ42xoN6I+3tod0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QomNZyqmKMoQT/2DnPjXQX7a9/nQ49EnFwcC6LyLtUkTDMDJ9ncZT+YOYXH5HnWAJNPt/Ku9oUBQ2JSrMZUXPUYi5jkRzruW9TV7FYIT9FTgMUEmdac0zsqsL/OXthoH+tyqFxMzXvxMKaLC83/sk/rRfmBC/Vav1p8SlI1BkuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=CsRKk3jW; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="CsRKk3jW" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-4863cd41330so944464b6e.1 for ; Thu, 04 Jun 2026 18:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621231; x=1781226031; 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=szIQNyD+NnmIvV9OHmmg2MxKrIQLLZ2S3wbfJkga4t0=; b=CsRKk3jWi2MjyYTHcXcu+g9BIRhhDRY+CBM5IentGbpNXAGZFhXf2kglnF8AGQUZF2 EsYHRzrk0IGpSSxAmvMI6BmHKJP6unNhEYwDbOfWeKXghAxVEABDeJmeYcmw1uyYYHit bONgr7r6hm5a3TM/4fkbJvlnUYdug7pPXkS627wXhZO0QQRGrf3z9wUbwMxx/eP4Ts/d Rvt808ugmjTpbyL1zPHtsocxDknJzb+RR+r3JNU0Gfxw5HMia/o041L3M/nAZxcLj8tG IliidHW6jE81G13WfFSJIVKS5VT3AnuWnfuPt7zBMVivG3qc88elH21BbNEw6n3l5TfT G7SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621231; x=1781226031; 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=szIQNyD+NnmIvV9OHmmg2MxKrIQLLZ2S3wbfJkga4t0=; b=LRlZRVRwZ2ZdsJ3UwZatgOReDlTq13Wvl/Nb1PPd4UnsX4vCFRIfKlYCDQD8TR/4iT 2m4iGSnqwTcDvhzVaq/pT5GHTR+SkodrJHxI7Nd20ec8AqO8Anj0Y/SDqEMi3O82WOJF ss+H2+n+0bwIfpQ+wm5KI4uAhWtkj1clHaUsp8Imba71L6VSJ5lg3e3SArtMFFFtT65Z sMHsTeyXkRToNiUHM0Q1tRmCjSHaFqvChDX7wYFPNyfWzlxNa/B8XRF1IeoXVb+OSATs +BidSudO2QQZQQpezc/tFqDW19a2PunbZTBcB5ebfEmpnVZ9XtI4lSVGvEajRZMOYNQp m4fw== X-Forwarded-Encrypted: i=1; AFNElJ9cQypCycsV34/FL66RzZIwktIae9hu3TdtUIpBLXoK7QGeq98F1BuR3JqL9imPX9DyQFCHU7W/pNwEvO0=@vger.kernel.org X-Gm-Message-State: AOJu0YxRUPil6QuFxYrhJOI70gcJmkJ49j2GcVXIffmVxggq7Vm9J25m 2tH8FSrIFidrYnEmXdknadFFE6xR3FD/zC0SyCs33t5jeXOnJpau6LDscvHKXcmPeEU= X-Gm-Gg: Acq92OGgbuIVKPt5Lm+wuLEyIzF6rwr2BBgkpR1zacJKxXWs/uv+Eu+r71tYjIm8lmf XFkvbvLSHMIsdQfwNhlc+UpfA0p+Jwj3K7TKT9ivdUtHnyXcb2M9tEASD6U0xdoJtd6Rh01ZV2S e48u7bnJikQfL2uFTZ9OIyOIRtq/+qtl4pbHlY4Dp69qNIUYpBG8NUpDlFdE3mIuK8Uxugs4paW W06mvJS17ivtsGARYF9QngRcAEJoUB2v8PSnvQEDSFAON20PfmqLsK+poGNdCg0RoMsWFc0eTIb cPg6eNx2RgUUQsNfeseYPVRLMrLzPi9rrgdCTwVk9tfB7ajbA2AJFWF2ZntKvrU8fu91aTQbc5Y WrArXdCsIPWtv2Ubi0mcC9UFyKrlS5a/q19C3t/QshRwNNGPplSa73QU8PN8RYTZyPwMnImRHAZ qZ9HMOaeyJJKkJz9EaHm+0fzSdxpJgJIe+pO8+vg== X-Received: by 2002:a05:6808:30a6:b0:47b:d07b:ec9a with SMTP id 5614622812f47-48692d347d3mr155790b6e.15.1780621231634; Thu, 04 Jun 2026 18:00:31 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:31 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 01/14] dt-bindings: net: qca,qca808x: Add regulator properties Date: Thu, 4 Jun 2026 20:00:08 -0500 Message-ID: <20260605010022.968612-2-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson QCA808x has four different power rails (although in many board designs the different rails share a regulator). Add each of these supplies to the corresponding DT binding. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- .../devicetree/bindings/net/qca,qca808x.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/net/qca,qca808x.yaml b/Docum= entation/devicetree/bindings/net/qca,qca808x.yaml index e2552655902a3..3c1b7eca33caf 100644 --- a/Documentation/devicetree/bindings/net/qca,qca808x.yaml +++ b/Documentation/devicetree/bindings/net/qca,qca808x.yaml @@ -25,6 +25,18 @@ properties: enum: - ethernet-phy-id004d.d101 =20 + avdd18-supply: + description: 1.8v analog power supply. + + vdd-supply: + description: 1.05v power supply. + + vdd18-supply: + description: 1.8v power supply. + + vdd125-supply: + description: (1.25v to 1.98v) LDO regulator power supply. + unevaluatedProperties: false =20 examples: @@ -39,6 +51,8 @@ examples: compatible =3D "ethernet-phy-id004d.d101"; reg =3D <0>; =20 + vdd-supply =3D <&phy_vreg_1v8>; + leds { #address-cells =3D <1>; #size-cells =3D <0>; --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 A6E3D78C9C for ; Fri, 5 Jun 2026 01:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621252; cv=none; b=Ws7QtuEZs7KNiCR0rsbzLASKaTCrCGYxV+CyZFTPUEoRfcNO4sZCVrvuHdHSgUaWYnu9Xyr2+sHQBdjQhn6q1THKyt4n2zE/LwvUmmQ71wQn7UCeQTkanIY1LoqR70vSPEQQOaa4rVljGgb2mbnOLsfkJvgF8YRDer3gfTpRKUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621252; c=relaxed/simple; bh=vMr4jxhlvuiWi2PyxKlVKNSh14l3upUcj5Q6o8aP3EM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aJ7pOF0UWo+bDYBV84ZRepU10/3Kwqyjew7mtntE+b+cwJLH/1bJqnvti00FEYLbCzoRJPZCTEITrpg9PUEJe7V/Ok1JsHS/z/tNaV0AZiwyv268Jq7BSF8IogmLs16aMhzkkAC4utEBmTxJWMxZVsAW8lymbVbGxx1WKCFhuwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=P5NRH/k4; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="P5NRH/k4" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-48611862583so603023b6e.0 for ; Thu, 04 Jun 2026 18:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621234; x=1781226034; 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=fJ+38FTwss9ygHui1gfTl6vP2WH2KcHiorJ0gzERMpo=; b=P5NRH/k4oh2qX2Mxdd1OGFpXE8cbMm9Qg67qkD9BjzDwrunKnD461+DMCBCtWg7XJ/ ivuyG4zmFl8XBfqAxnaxlTVlEMaJtBNWUGgAa67ubcick5WLoapSlMULVLXbsoEejMPA njCAqnmHUNS1o6j9Fx6KW2VVjwH6iMltkcnVE2qwFnaK9GLCKMS3P2KGAdob0lqR7zH3 lgJUTPMkTHsrLS/HHDuoYj7sI8Rs3Dph4OdadMmHO5J/P6DD1VbijV3LcEjizTlR18TB yirDWNylk12lGSdC0PxAFOZO+yP35qc9KFzPlDH2MFDG9FatFM4+NM++S0kNd/VnQu0V YkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621234; x=1781226034; 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=fJ+38FTwss9ygHui1gfTl6vP2WH2KcHiorJ0gzERMpo=; b=dj/K0NwpoesmBDc1o2Wnz1aqY1oRJ71wj9ba2e5iU4FoxjO/aXW5AqyIQ42PNOxGQY leufrno5AopNSV8X2nbG3D09i81jvHzBE21CJVz8nZ4zb6DZBe4DkAiPhgprPIK/nvH0 sKLWNn6RqIUVj3oaQ2FqJ/sgVrwtS/2sbR6yG1sRNac1Wpm++M8RfB7Vr3l0q5LHfN3F uOb0dxvYCgh7z8vmOs9Hd+O7eFRlWAgQMFm6O3t8vmHwUl5CL6o6a0FHozec5n+eVt0P WtmzPeI8Pxb6sGQ5Iicx1/tLzm8lEQcGUAlDcft/YFyTPLON49ryKFF5uxBWVzdtKIaB h5XA== X-Forwarded-Encrypted: i=1; AFNElJ/1/ohFmh00yo0ta+yfcIq9Qs8Kmovuk9rdT+d1J5LSFzQebOI+G/VyYszN0el32qOuG7UI3Bdex2Mz4GM=@vger.kernel.org X-Gm-Message-State: AOJu0YwOPF13NB86qq8apHDIzCGDOkOvyhOwDGUnqUm1aMTD8vYcllbE Zbvt0T50PzA4Pyc83AALrpXfyJLIF+0+yt2FkVTyqRyWqTi36cEN1vRuvkNy3hGgjgs= X-Gm-Gg: Acq92OEmY1o0LZgY4RtLkudqurIT/cftAlJJypp4g5kabFKnxVs9B09J9T1mvSa2Ju8 o2yn0RMtRRlXoPVPzTAQLNCqObayQv+wWakauB+cGay0O7LYfpsRf0getc4Chqukdn5bIEVGy4+ 2C16xzZK8wnw6QKHVWSXywGHJWWwBuk6UxrESCt1YbxraNQnfu9eObBIz3Y6SrUG4OyunEhZIvk w3Fu7CSS8rXvEPLp2JuhC1W8rR/9VrYFpih/trgyJbUOJKLAXHoF0ueBLFfcTyMJFkylL7BPt0Q 3B+aQcBuqhio/hOhkh75pMUoy8uVZUPHjb45jeGslGvAGfeme0lE7P0kpSEOKHOGcwH+dAbkT0l OPFPItnJA+8JCGTV7EoPq1vJRdsm3EdaE03M+QxPm+1YQzrQ9rIyz9s5/IaYS5D2oyimKUEBJek xeAq75lVi1Q7vOReGNihxgrVzD5ZBTWwuZMHav+Q== X-Received: by 2002:a05:6808:1b25:b0:486:560d:aa9c with SMTP id 5614622812f47-4868dc63516mr816744b6e.15.1780621234618; Thu, 04 Jun 2026 18:00:34 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:34 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 02/14] net: phy: qcom: qca808x: Add regulator management Date: Thu, 4 Jun 2026 20:00:09 -0500 Message-ID: <20260605010022.968612-3-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson QCA8081 appears in embedded board designs paired with GPIO controlled regulators for its power rails. Add logic to allow these regulators to be turned on during a probe. In order to avoid the complexity of tracking state for suspend with and without WoL we take a tremendously simple "always-on" approach to regulator management, essentially relying on BMCR_PDOWN to conserve power when the phy device exists. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- drivers/net/phy/qcom/qca808x.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/phy/qcom/qca808x.c b/drivers/net/phy/qcom/qca808x.c index 8eb51b1a006c4..fc3f2cf2e55d0 100644 --- a/drivers/net/phy/qcom/qca808x.c +++ b/drivers/net/phy/qcom/qca808x.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ =20 #include +#include #include =20 #include "qcom.h" @@ -178,15 +179,44 @@ static void qca808x_fill_possible_interfaces(struct p= hy_device *phydev) __set_bit(PHY_INTERFACE_MODE_2500BASEX, possible); } =20 +static int qca808x_power_on(struct phy_device *phydev) +{ +#ifdef CONFIG_OF + static const char * const regulator_names[] =3D { + "avdd18", "vdd", "vdd18", "vdd125" + }; + struct device *dev =3D &phydev->mdio.dev; + u32 count =3D 0; + int i, ret; + + for (i =3D 0; i < ARRAY_SIZE(regulator_names); i++) { + ret =3D devm_regulator_get_enable_optional(dev, regulator_names[i]); + if (!ret) + count++; + else if (ret !=3D -ENODEV) + return ret; + } + + if (count) + fsleep(phydev->mdio.reset_assert_delay); +#endif + return 0; +} + static int qca808x_probe(struct phy_device *phydev) { struct device *dev =3D &phydev->mdio.dev; struct qca808x_priv *priv; + int ret; =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 + ret =3D qca808x_power_on(phydev); + if (ret) + return ret; + /* Init LED polarity mode to -1 */ priv->led_polarity_mode =3D -1; =20 --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (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 19F5E301493 for ; Fri, 5 Jun 2026 01:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621253; cv=none; b=uPSnsYadeFsUtPoNHoZMWcqH1NzHPyOk/xx79qNwx1Uxm6ShlWKmqvrV4zdSxJv+nX8c1AALyCh0WJ9l/dU0brUCTg7ulgNJvetF6/1B6KlwsBMlfYp0erlnMmacMkNzEzusxHzMgvjichbOpGLWhF0lEcQM9ZGxKZYVK8C0ZJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621253; c=relaxed/simple; bh=x3hFYwAiPvlZKk9+fPMM1pZD6sj2EWkFRwILmjFArYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BmzM7XACbBGYRkATcT5kpKzmGWhX1q4zh5ZvMnTKsA0RTrNbeyy3V78X8zQNUOa1akSluDyCxUJeiaKAuF+Qygupkl6BOKoHXQT8k/w8CwLJyXoqITKOPMqtT78bTtNqb461HjVBk7LloBlt0zZydvQVIfNN967V4/kagpygSQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=HumXQT81; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="HumXQT81" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-486539875c1so571210b6e.0 for ; Thu, 04 Jun 2026 18:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621238; x=1781226038; 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=PXOGCojLUBGZIqNUtQ7tDvedemfOzrCuti6WoAljgjQ=; b=HumXQT81dRRRCv6lwk4IzuFxR/rLQgkWK0lkFJXVU0HQCLJkE54RzZ50t5iz4Cl1BU vCGkN2oF1KmrU5oCasLRn8YcsEf6k1cCvl2rihWghvy2SRBZaciXvF4cFbqeLHm/DtOb roQtF9IMBWYR2/Lp6c2vm0fRPRMSBxh5ILYSx7L4nr8GV1JClEWErkrfAFiwtDuqoSr0 0N2mZbekrLDyBR4sMa7es5I0HZ0F9PGXR3SOxC1VfpPK7ou8O4ATmLMNx1829e9IVURw qsfRIRvXhasK5Uo0wwjXvkcAqW1E3UQoJtoLLE4vpyLlFSeSxFyvkoZHhXmwerrjMwgN 5urA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621238; x=1781226038; 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=PXOGCojLUBGZIqNUtQ7tDvedemfOzrCuti6WoAljgjQ=; b=nQNDO7OisYu+6A3msL6Rv2InMW9cBSytlALJC2EM0HQ/F6RdwkbMaW0J0p6ktsbiC8 EZyW3Zc4B1xMvGKnZAHk8M6rhHTAM14+Qko2+o13zFUWnl65ao0vpdNm5ZX/PiaRf2yq CDsXMDEDxEwwv0xiS9YzjVWQ8LIKdFG2FxUYxOYliecuLodB1v37atcnzOFp3nMS9uJ5 cHMtQE0jC46DLQrSGHDebqxYu7rVyNZoGq+wp4wkwuxfATnN+zUQrjByZHL1N2Jr3lcm Ml71IMBNm/42Am4SrX5CpmtR4y8TRzotZGtKxav03Sc6a56yf70SNdmaZg4IS3DDfois RNRw== X-Forwarded-Encrypted: i=1; AFNElJ+Ed8vmcI1j57ZS3y6YemjCkPz68P9O7UYySiD7nCpK1AuTkgu+fDh9NDyX9CLW8SyE5Z2Bs6jbknaOhYc=@vger.kernel.org X-Gm-Message-State: AOJu0Yxr9teMI59w3B3wCLcGEft9EgNCEUNxhHbLwAA5k4ngLC3Exdsh S7ijcbMoeOD3i9G+w9ItlTAhnGQeMcPo9FU+BRKg/2bNuLbHNdOH5IVkMpWT+5AdKyw= X-Gm-Gg: Acq92OFhMC8Ak3QHSsIvohP32Q/dMiXghym/GxTxomovgTb8Rwqj1bk8YQ+nl32/OHE rlv8b6VRNUsU1S7ilgY//u4OWWcx++Hl9gq0DaLBjFzpnLJhRA1wn/182jVULt/f2cQl9SmQBVM Ae0wNtQMXRpV+ZGWorRLYA867A/NuG/yeO6VnN96++rpL1r9U17t3+/mBzBaHt3e5dTVMSBpiYL JGoLBC6h20okjTuDOvEltNv0hRGEbEKf0RweFna1TxPQnqTEYHlQ+VPg3RZ5lSCfk14skBbm5DJ +GJfb/EXzGbUtpNe14Ld4F3x4nksudMHQxY8p/8Z/rk8BcuXTiKXW7LRgrpbvlS/9oINAE4oQyL UG6/P+XW9Y010VjAyFzZV1UB+EdxIlgb9XI7QzgEpEHy5YiiB5v5+jdYv2BHXRUJ9PbXWaqLEvK hNKVV1jfbFVmq17N9AZs68OMY0vvCaKx+6ZedtfQ== X-Received: by 2002:a05:6808:1a0d:b0:486:5275:8144 with SMTP id 5614622812f47-4868dc44e20mr851607b6e.2.1780621237642; Thu, 04 Jun 2026 18:00:37 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:37 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap Date: Thu, 4 Jun 2026 20:00:10 -0500 Message-ID: <20260605010022.968612-4-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson In some DesignWare XPCS implementatons the memory-mapped MDIO bus is allocated to a register window that does not align to a page boundary. This makes iomapping the registers problematic. For example the Toshiba TC9564 (a PCIe Ethernet-AVB/TSN bridge) provides an "eMAC" subsystem with the XPCS base address cuddled up to XGMAC registers. Let's introduce helpers to allow the driver that owns the eMAC to register an XPCS using is regmap for the memory-mapped MDIO bus. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- MAINTAINERS | 2 + drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-regmap.c | 219 ++++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs-regmap.h | 20 +++ 4 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs-regmap.c create mode 100644 include/linux/pcs/pcs-xpcs-regmap.h diff --git a/MAINTAINERS b/MAINTAINERS index eb8cdcc76324f..2aa6ea012c848 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25931,8 +25931,10 @@ F: drivers/net/ethernet/synopsys/ SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER L: netdev@vger.kernel.org S: Orphan +F: drivers/net/pcs/pcs-xpcs-regmap.c F: drivers/net/pcs/pcs-xpcs.c F: drivers/net/pcs/pcs-xpcs.h +F include/linux/pcs/pcs-xpcs-regmap.h F: include/linux/pcs/pcs-xpcs.h =20 SYNOPSYS DESIGNWARE HDMI RX CONTROLLER DRIVER diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile index 4f7920618b900..565f1b63fce0b 100644 --- a/drivers/net/pcs/Makefile +++ b/drivers/net/pcs/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers =20 -pcs_xpcs-$(CONFIG_PCS_XPCS) :=3D pcs-xpcs.o pcs-xpcs-plat.o \ - pcs-xpcs-nxp.o pcs-xpcs-wx.o +pcs_xpcs-$(CONFIG_PCS_XPCS) :=3D pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-regmap= .o \ + pcs-xpcs-plat.o pcs-xpcs-wx.o =20 obj-$(CONFIG_PCS_XPCS) +=3D pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) +=3D pcs-lynx.o diff --git a/drivers/net/pcs/pcs-xpcs-regmap.c b/drivers/net/pcs/pcs-xpcs-r= egmap.c new file mode 100644 index 0000000000000..55cd05d09c7db --- /dev/null +++ b/drivers/net/pcs/pcs-xpcs-regmap.c @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Synopsys DesignWare XPCS regmap helpers + * + * Copyright (C) 2026 RISCstar Solutions. + * Copyright (C) 2024 Serge Semin + */ + +#include +#include +#include +#include +#include +#include + +#include "pcs-xpcs.h" + +/* Page select register for the indirect MMIO CSRs access */ +#define DW_VR_CSR_VIEWPORT 0xff + +struct dw_xpcs_regmap { + struct device *dev; + struct mii_bus *bus; + struct regmap *regmap; + bool reg_indir; +}; + +static ptrdiff_t xpcs_regmap_addr_format(int dev, int reg) +{ + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); +} + +static u16 xpcs_regmap_addr_page(ptrdiff_t csr) +{ + return FIELD_GET(0x1fff00, csr); +} + +static ptrdiff_t xpcs_regmap_addr_offset(ptrdiff_t csr) +{ + return FIELD_GET(0xff, csr); +} + +static int xpcs_regmap_read_reg_indirect(struct dw_xpcs_regmap *pxpcs, int= dev, + int reg) +{ + ptrdiff_t csr, ofs; + unsigned int val; + u16 page; + int res; + + csr =3D xpcs_regmap_addr_format(dev, reg); + page =3D xpcs_regmap_addr_page(csr); + ofs =3D xpcs_regmap_addr_offset(csr); + + res =3D regmap_write(pxpcs->regmap, DW_VR_CSR_VIEWPORT, page); + if (res < 0) + return res; + + res =3D regmap_read(pxpcs->regmap, ofs, &val); + if (res < 0) + return res; + + return val & 0xffff; +} + +static int xpcs_regmap_write_reg_indirect(struct dw_xpcs_regmap *pxpcs, in= t dev, + int reg, u16 val) +{ + ptrdiff_t csr, ofs; + u16 page; + int res; + + csr =3D xpcs_regmap_addr_format(dev, reg); + page =3D xpcs_regmap_addr_page(csr); + ofs =3D xpcs_regmap_addr_offset(csr); + + res =3D regmap_write(pxpcs->regmap, DW_VR_CSR_VIEWPORT, page); + if (res < 0) + return res; + + return regmap_write(pxpcs->regmap, ofs, val); +} + +static int xpcs_regmap_read_reg_direct(struct dw_xpcs_regmap *pxpcs, int d= ev, + int reg) +{ + unsigned int val; + ptrdiff_t csr; + int res; + + csr =3D xpcs_regmap_addr_format(dev, reg); + res =3D regmap_read(pxpcs->regmap, csr, &val); + if (res < 0) + return res; + + return val & 0xffff; +} + +static int xpcs_regmap_write_reg_direct(struct dw_xpcs_regmap *pxpcs, int = dev, + int reg, u16 val) +{ + ptrdiff_t csr =3D xpcs_regmap_addr_format(dev, reg); + + return regmap_write(pxpcs->regmap, csr, val); +} + +static int xpcs_regmap_read_c22(struct mii_bus *bus, int addr, int reg) +{ + struct dw_xpcs_regmap *pxpcs =3D bus->priv; + + if (addr !=3D 0) + return -ENODEV; + + if (pxpcs->reg_indir) + return xpcs_regmap_read_reg_indirect(pxpcs, MDIO_MMD_VEND2, reg); + else + return xpcs_regmap_read_reg_direct(pxpcs, MDIO_MMD_VEND2, reg); +} + +static int xpcs_regmap_write_c22(struct mii_bus *bus, int addr, int reg, u= 16 val) +{ + struct dw_xpcs_regmap *pxpcs =3D bus->priv; + + if (addr !=3D 0) + return -ENODEV; + + if (pxpcs->reg_indir) + return xpcs_regmap_write_reg_indirect(pxpcs, MDIO_MMD_VEND2, reg, val); + else + return xpcs_regmap_write_reg_direct(pxpcs, MDIO_MMD_VEND2, reg, val); +} + +static int xpcs_regmap_read_c45(struct mii_bus *bus, int addr, int dev, in= t reg) +{ + struct dw_xpcs_regmap *pxpcs =3D bus->priv; + + if (addr !=3D 0) + return -ENODEV; + + if (pxpcs->reg_indir) + return xpcs_regmap_read_reg_indirect(pxpcs, dev, reg); + else + return xpcs_regmap_read_reg_direct(pxpcs, dev, reg); +} + +static int xpcs_regmap_write_c45(struct mii_bus *bus, int addr, int dev, + int reg, u16 val) +{ + struct dw_xpcs_regmap *pxpcs =3D bus->priv; + + if (addr !=3D 0) + return -ENODEV; + + if (pxpcs->reg_indir) + return xpcs_regmap_write_reg_indirect(pxpcs, dev, reg, val); + else + return xpcs_regmap_write_reg_direct(pxpcs, dev, reg, val); +} + +static void devm_xpcs_regmap_destroy(void *data) +{ + struct dw_xpcs *xpcs =3D data; + + xpcs_destroy(xpcs); +} + +struct dw_xpcs *devm_xpcs_regmap_register(struct device *dev, + const struct xpcs_regmap_config *config) +{ + static atomic_t id =3D ATOMIC_INIT(-1); + struct dw_xpcs_regmap *pxpcs; + struct dw_xpcs *xpcs; + int ret; + + pxpcs =3D devm_kzalloc(dev, sizeof(*pxpcs), GFP_KERNEL); + if (!pxpcs) + return ERR_PTR(-ENOMEM); + + pxpcs->dev =3D dev; + pxpcs->regmap =3D config->regmap; + pxpcs->reg_indir =3D config->reg_indir; + + pxpcs->bus =3D devm_mdiobus_alloc_size(dev, 0); + if (!pxpcs->bus) + return ERR_PTR(-ENOMEM); + + pxpcs->bus->name =3D "DW XPCS MCI/APB3"; + pxpcs->bus->read =3D xpcs_regmap_read_c22; + pxpcs->bus->write =3D xpcs_regmap_write_c22; + pxpcs->bus->read_c45 =3D xpcs_regmap_read_c45; + pxpcs->bus->write_c45 =3D xpcs_regmap_write_c45; + pxpcs->bus->phy_mask =3D ~0; + pxpcs->bus->parent =3D dev; + pxpcs->bus->priv =3D pxpcs; + + snprintf(pxpcs->bus->id, MII_BUS_ID_SIZE, + "dwxpcs-%x", atomic_inc_return(&id)); + + /* MDIO-bus here serves as just a back-end engine abstracting out + * the MDIO and MCI/APB3 IO interfaces utilized for the DW XPCS CSRs + * access. + */ + ret =3D devm_mdiobus_register(dev, pxpcs->bus); + if (ret) { + dev_err(dev, "Failed to create MDIO bus\n"); + return ERR_PTR(ret); + } + + xpcs =3D xpcs_create_mdiodev(pxpcs->bus, 0); + if (IS_ERR(xpcs)) + return xpcs; + + ret =3D devm_add_action_or_reset(dev, devm_xpcs_regmap_destroy, xpcs); + if (ret) + return ERR_PTR(ret); + + return xpcs; +} +EXPORT_SYMBOL_GPL(devm_xpcs_regmap_register); diff --git a/include/linux/pcs/pcs-xpcs-regmap.h b/include/linux/pcs/pcs-xp= cs-regmap.h new file mode 100644 index 0000000000000..19c99d4160365 --- /dev/null +++ b/include/linux/pcs/pcs-xpcs-regmap.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __LINUX_PCS_XPCS_REGMAP_H +#define __LINUX_PCS_XPCS_REGMAP_H + +#include + +struct device; +struct regmap; +struct dw_xpcs; + +struct xpcs_regmap_config { + struct regmap *regmap; + bool reg_indir; +}; + +struct dw_xpcs *devm_xpcs_regmap_register( + struct device *dev, const struct xpcs_regmap_config *config); + +#endif /* __LINUX_PCS_XPCS_REGMAP_H */ --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.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 0F51226F2A0 for ; Fri, 5 Jun 2026 01:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621257; cv=none; b=KjppYYNP3dgqBkDiSQGD6vwDB/9b1wfrcndQrOPvZpP9W85MNJV68OCaufWBova1MmKbDbiQuGmBNUmFa+Pmf+GXwWSBFSq/CIyd7H2FhFE8IEX+Q+U9NOuniUo1TN4WKxfgetyGP/6qD38aOHWJMFMKfLa12cU5BKFNROl/9PM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621257; c=relaxed/simple; bh=Fl2vvfFimqS4GlpOM20DZtsfCLCrtWoZalqmHnKTKCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GarQP0MapYmys6rj6qhClw3IXNivRux+mTjqBWqYIMyGM2csznVuZs9VHxMvTn04G+bLF3VePy1r4XxZF77B52Aqwvai8faGXtu1RydCJv8kX9q8JRG86jnO3FoPYVoOd0BrJPOn0FHBeexktTiS/5/pEjZuSo0CC1HB2jkw0Nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=hnPP2LhC; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="hnPP2LhC" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-4862ed6ab36so811669b6e.1 for ; Thu, 04 Jun 2026 18:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621241; x=1781226041; 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=EZkK5iRkM+bFu8r36hoA1oZzT41u9/qmzwRkx8FhOsM=; b=hnPP2LhCrmphc0LS/cRwIZU/py9l8iqMlf/5s76G55Vbm22SCgKVelKwBEkfF4qIZO NtHYL02toKdC1nI87qUMsmfD1yplesNL04PK7gmMP+7FPrlLHUwP7vx1KGzcLT7w+UjO od15QFIpPyVrVlCbHpUppdWGsiZfGqOKKOPzPtsR3con7QeX2QmIG0wI+hDkWGNRH/k+ 0Z/Rikks1UulXIN9VvXGldIawMTkALO+12U/8NWaFwTwfljOVJNAu/SffsPJOYtQa7LE TFYGw/qDgWbPhJ0Qjr3bSbf3C+D+z1CuU98jyXVDDbGgp95VMcf4tqUOa/gNbJCUIkrB qp1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621241; x=1781226041; 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=EZkK5iRkM+bFu8r36hoA1oZzT41u9/qmzwRkx8FhOsM=; b=cmEO6HFg+x3/7cWYzjgXt9c6qZO+3PBkmW4x2xeIaDwQG1B7oq53F3agyRXK8ycuzY jhjU1gSTOmhRi9vg58MFQ5+G2aJ+EzOPjcvjikf4f2WTZGMXFhEsf6BUdIfI5tBYBJbo d9+FZRiIEc93efPxMuII8EIXPYDo0K72T+UVYmfmtKMlPQuOfN6JzTXUhE9/JH48C4fF UHawQkBli12Mye18TDpNSO+ahLsFCjTKL2SwtpVkvQwuAI/ogFsH1nx4XAh8++2FGYWH 5Iygpu6W9rzumG1sFIhnnAxBZKHOyXXCryhkSNhKmoxu8kzVgyPwYEYXo4WoOqxXQ0q+ P5HA== X-Forwarded-Encrypted: i=1; AFNElJ/Bq9yWZS6f8dZgfFKlcpCBFSbDeky8FIpRP10BsdgrG1iD6n+VSwb9/9SIG4wHVGyzkeRL4e1TKch4gEc=@vger.kernel.org X-Gm-Message-State: AOJu0YwfSyINmJrZSUebPT2myGcAXYQ3HdK3vWmr/YO6An1MfePRuKY1 7EtxGynlRMVPB4m0vrwBCrJ17m2qxlBz3kx0+7lhhWeE4tkl5zgMRfniuAhU+/G1jgE= X-Gm-Gg: Acq92OGvVlKX1pk5iM27go7FdTRkUz0oScoOZ8pBYSeWJUh7wfdWfHVygHeeEmwzIO5 vXqa/Fc+OUFeAns1KDRQRtqNOOckgEeN8k5GJjMDifYqbmos4TyqDtm2KqWcoG7U5kHbVTck9Ng l8k4Kxznv1b0YlDlLMTMwYojf/PWYabis+N9WpB2sVfdRyi6Ac5xAeuY8KSlMOokFaW0d8ArtWE VMMsuXlNef1HP2t5JQfzDjWmFTbMWAO3oSe8VU5FHPcsULMPlpgQN8FTujKo8p0VSN95C9LmnvO 7AaxO9AwfVU9P9kPPzEyefxRbigFJZSq0LJzJvd4g67JBFHtb3YsuodjKyD6Cc8DPmAFKu8eKmd 31eN/rEzCZpco86bNBGI9cf93klfIRe6Coue3EwY4qWIkpgAdJ5LGc2oXiWYK23Qr7CclIFAbmy sozw/dvP0wGqM+j1EOLNWiynXDF/HeZEmiVsQhfw== X-Received: by 2002:a05:6808:1b0e:b0:467:5f1:fc93 with SMTP id 5614622812f47-4868dbe795amr869921b6e.9.1780621240655; Thu, 04 Jun 2026 18:00:40 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:40 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 04/14] net: pcs: xpcs: re-order xpcs_pre_config() to update after the reset Date: Thu, 4 Jun 2026 20:00:11 -0500 Message-ID: <20260605010022.968612-5-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Currently, on Wangxun platforms, the XPCS is configured during the call to xpcs_switch_interface_mode() and, if the need_reset flag is set, the XPCS is reset and the configuration will be lost. This is harmless at present because need_reset will never actually be set on these platforms. Nevertheless having xpcs_switch_interface_mode() on the wrong side of the reset is an obstacle for future changes where wiping out programmed configuration with a reset could be harmful. Reorder xpcs_pre_config() to allow the reset can happen before we switch interface mode. To make this work we have to hoist the special case logic for SGMII into the parent function. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- drivers/net/pcs/pcs-xpcs.c | 56 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index e69fa2f0a0e8d..76c04372b5b50 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -705,46 +705,50 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs,= unsigned long *interfaces) static int xpcs_switch_interface_mode(struct dw_xpcs *xpcs, phy_interface_t interface) { - int ret =3D 0; + /* Wangxun provides a full alternative implementation to handle quirks */ + if (xpcs->info.pma =3D=3D WX_TXGBE_XPCS_PMA_10G_ID) + return txgbe_xpcs_switch_mode(xpcs, interface); =20 - if (xpcs->info.pma =3D=3D WX_TXGBE_XPCS_PMA_10G_ID) { - ret =3D txgbe_xpcs_switch_mode(xpcs, interface); - } else if (xpcs->interface !=3D interface) { - if (interface =3D=3D PHY_INTERFACE_MODE_SGMII) - xpcs->need_reset =3D true; - xpcs->interface =3D interface; - } + xpcs->interface =3D interface; =20 - return ret; + return 0; } =20 static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t inter= face) { struct dw_xpcs *xpcs =3D phylink_pcs_to_xpcs(pcs); const struct dw_xpcs_compat *compat; + bool force_reset; int ret; =20 + /* + * According to the XPCS datasheet, a soft reset is required to initiate + * Clause 37 auto-negotiation when the XPCS switches interface modes. + */ + force_reset =3D interface =3D=3D PHY_INTERFACE_MODE_SGMII; + + if (force_reset || xpcs->need_reset) { + compat =3D xpcs_find_compat(xpcs, interface); + if (!compat) { + dev_err(&xpcs->mdiodev->dev, "unsupported interface %s\n", + phy_modes(interface)); + return; + } + + ret =3D xpcs_soft_reset(xpcs, compat); + if (ret) { + dev_err(&xpcs->mdiodev->dev, "soft reset failed: %pe\n", + ERR_PTR(ret)); + return; + } + + xpcs->need_reset =3D false; + } + ret =3D xpcs_switch_interface_mode(xpcs, interface); if (ret) dev_err(&xpcs->mdiodev->dev, "switch interface failed: %pe\n", ERR_PTR(ret)); - - if (!xpcs->need_reset) - return; - - compat =3D xpcs_find_compat(xpcs, interface); - if (!compat) { - dev_err(&xpcs->mdiodev->dev, "unsupported interface %s\n", - phy_modes(interface)); - return; - } - - ret =3D xpcs_soft_reset(xpcs, compat); - if (ret) - dev_err(&xpcs->mdiodev->dev, "soft reset failed: %pe\n", - ERR_PTR(ret)); - - xpcs->need_reset =3D false; } =20 static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 2F71E311C11 for ; Fri, 5 Jun 2026 01:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621263; cv=none; b=fogFcrmhuwO42xt4nZbgnHeM49Xey0lHqtl+mL2tS4/IYwGkUlNzJ25coOcX9Mk2WFIZm0igY2wovMjyjIQIR9F5Vu6QU/CEFEcV1Eua6StGMOOYem5AXw6XtmrBGjLn3B4EkxdQ7NCDsl7XvXas0+/otgcFBifT0E/6ggg+7NM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621263; c=relaxed/simple; bh=aIq/9ufivsXPLWgxyepAcfegpx7woiOwGaoVD2ffqhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rpm4zNMwikUJGFXDBJM2SYEG1Fv0F7HwsMS/uNL+1jrw7XdtTO5PR8b+DG9GRFawKETkbOJp7gYkfkhibcfPqtIGcFnRaZW7cFnUPhdun89KnvnQlTNLivKd5TI/2OLAbRi5ZMUrbvnwkIMlx78UTG3esSDscvCNcAy/METBSA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=QmWrmb4e; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="QmWrmb4e" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-4854d5cc708so851970b6e.2 for ; Thu, 04 Jun 2026 18:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621244; x=1781226044; 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=d7RcozIfkgTb1ceMrXgVzxfNf3AdsB7YSa91tWGMELg=; b=QmWrmb4eZRkT7Iv6epdW6VuHDutBj+AaUBCXhADnZAOgqQCAHLeIuNF7uQssyG1l4o dqnkYsfbdOwTLsRXwSPfyK/+K+oKhjxTmRKe7Fy/T9QwyVidQoUp+A9D0BFgEVzNW7jS fg/xVrzCXhDgcQFeLYiKri3r+5Ojad74jLhNAx9DmOybe5ER4VZr5G79tuFBcdAdd/w+ PAAxm6+NYHagd/Nz9AOpic3RHpGEvUBq3x2KT96pwtKKLgJbT5QoOqoTMN1nMwXORAkw zmwYYLr2OCaih3f0WZeF79iWTU3EDIYqYILZEhyf4QxbfMgh4BkLSivXzd81ZSqdcDl2 hJcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621244; x=1781226044; 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=d7RcozIfkgTb1ceMrXgVzxfNf3AdsB7YSa91tWGMELg=; b=PqTCQ7fWwTAhd7orheZfrkbVYozkJHioWFz3IWzsKWNzf22L86enoOKQaPL5icuyyR s+sSSvjSZHz4Wwq8Dlb5gGibApBQm+JYvuknUM942Tpfco6PX8CsUtcdhPSq4fDp/1Sl DWJH5iH/i53Kgdb7Fj2r0yyxG7RAeLUytY4PeqrY5iymBNHqcwx/gbsfuezyoXcKTMWv nfrBN3C6IBXpnwLqzxWGdfiNbFO+r0g7KR8uYRksSV8AqQ9pT7/jp4fwhHpPLMlyQj+B /zZZKi0FN6jsnecBaXFCnHwtGpzhueWFVywkxcRJI1xU64XxRJ+k/6I81KWNp8Vg6kxn pQsg== X-Forwarded-Encrypted: i=1; AFNElJ8VrYYVEM3O8qx0rTHwNJxKknkchHcrS9laC0vsPKjO8LWDNyVqyDMEBD9kIwHiNRcC8a+/ArfcxdEDghs=@vger.kernel.org X-Gm-Message-State: AOJu0YwOrERL9EzsR6MDtvQCGiuIj29bB/pUthLk5jfq7xt3S6d/PHI2 L1xO/ylXwuYz8YVdz+lrgIMG4QBmHbaCt+fl7SJr+YEQ7a5fK8hqRPL0ooNJWjCA8i0= X-Gm-Gg: Acq92OGkGiGO8Vvi/EKovsvu0fc9LP5BVnpGg9OxHxOMC7OA55oMk/ggMo2R9lL2M0r YNeFH9qeBgYlWpN7sH22/ty0FnPZwzd+4fOvz8uGdUpERS4sr2ylgn0fDilMpC75nPOUV+FspzU 7hCOPj+TmDGWhU1laKgXjDHDJKGIrE64rNDBEQ4BlKka2//dyrAeYo1xOKaWBWAlFDBUzw71ttg gn1OMX/5jfNeWyDfGclPntt8dWQs36ABAFAVw/i85S7RzhsoShDDLhg7gWx7Fy+qBLHBR4KIN8T uehKz7wetIS6LCmLwyMLLwYyf6iyIdtGZFlIcWNezQPrQqSGkfPPolAxf6gsJX1eQh9bSMn506t Hiio4G7hyCHQ/nH2BhGvPtUI4L8hyI/DwdCNAyVJslB4gze0j6E7K6PPdv78q5+hhSdWvTfXac8 HhnxmXAwB7pAdGZoZWeJFXpSDPTNnCmZK43D4qDA== X-Received: by 2002:a05:6808:a599:10b0:485:a99c:cfe3 with SMTP id 5614622812f47-4868df4dd74mr546927b6e.42.1780621243759; Thu, 04 Jun 2026 18:00:43 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:43 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 05/14] net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS Date: Thu, 4 Jun 2026 20:00:12 -0500 Message-ID: <20260605010022.968612-6-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Currently the XPCS found on Toshiba TC9564 (a.k.a. Qualcomm QPS615) is unable to operate at 2500base-X and slower with a PHY connected using SGMII/2500base-X (in our case a Qualcomm QCA8081). The problem arises because this XPCS supports 10Gbase-R. That means that the reset value of SR_XS_PCS_CTRL2:PCS_TYPE_SEL (0) is valid and this suppresses the modal switching based on bit 13 of SR_PMA_CTRL1 or SR_XS_PCS_CTRL1. A fix for this behaviour is already implemented by txgbe_xpcs_switch_mode() as part of the quirks for WangXun devices. Rather than introduce another quirk for TC956x let's attempt so solve this generically by setting SR_XS_PCS_CTRL2:PCS_TYPE_SEL to a reserved value when we detect the right we detect the right combination of phy interface and XPCS feature support. The generic strategy adopted requires the default value of PCS_TYPE_SEL to be 0 on devices that support 10Gbase-R. Based on TC9564 documentation and the logic already implemented for WangXun I believe this is likely to be the case for currently supported XPCS devices. Sadly I don't have access to generic XPCS docs to confirm. However I think the benefits of avoiding a cargo culted quirk outweights the risk of regression. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- drivers/net/pcs/pcs-xpcs.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 76c04372b5b50..e58103ae8dadd 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -705,10 +705,49 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs,= unsigned long *interfaces) static int xpcs_switch_interface_mode(struct dw_xpcs *xpcs, phy_interface_t interface) { + int mdio_stat2, ret; + /* Wangxun provides a full alternative implementation to handle quirks */ if (xpcs->info.pma =3D=3D WX_TXGBE_XPCS_PMA_10G_ID) return txgbe_xpcs_switch_mode(xpcs, interface); =20 + mdio_stat2 =3D xpcs_read(xpcs, MDIO_MMD_PCS, MDIO_STAT2); + if (mdio_stat2 < 0) + return mdio_stat2; + + /* + * If this XPCS supports 10Gbase-R then that will be the default + * operating mode. There are several interface modes where this default + * is unhelpful. Change the operating mode for interfaces were we know + * the default is wrong, and restore the default otherwise. + */ + if (mdio_stat2 & MDIO_PCS_STAT2_10GBR) { + switch (interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_1000BASEX: + case PHY_INTERFACE_MODE_2500BASEX: + /* + * Why are we writing MDIO_PCS_CTRL2_TYPE + 1? We want + * the modal behaviour that comes when we pick a + * reserved value. XPCS allocates extra bits to this + * field and allocates values from 15 down so + * MDIO_PCS_CTRL2_TYPE + 1 is the value likely to be + * allocated last (and hopefully never). + */ + ret =3D xpcs_write(xpcs, MDIO_MMD_PCS, MDIO_CTRL2, + MDIO_PCS_CTRL2_TYPE + 1); + if (ret < 0) + return ret; + break; + default: + ret =3D xpcs_write(xpcs, MDIO_MMD_PCS, MDIO_CTRL2, + MDIO_PCS_CTRL2_10GBR); + if (ret < 0) + return ret; + break; + } + } + xpcs->interface =3D interface; =20 return 0; --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 4938E30C615 for ; Fri, 5 Jun 2026 01:00:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621270; cv=none; b=HMH5sKXd8Iv/mj2PYNUt0OknAg1ml9eW7PQtfiYvBCz0VLctU+ODtA5QwDoS4u27EJcyVMMMSEjD95VYA9Idnv/ZK+ZGvg95pjc23AVXlIjoXlFuJg8p4ykudxbMHeAMZ3rO1yFG9JJtBGW7wxh918DdcwJNE9kIBi/4U+JRFUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621270; c=relaxed/simple; bh=NYqtz18Vi4h6amY79JOSwciWh5J4DGUbxj7ljZpHckA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hEcOxfvtaP01WO+C3Bb5YiXEEUoFfn72uw3ueFG+Ap39YjAryVhSUdjni554YjxrM9dBBZ/4ex508W604kEjt+768vr7Lh7d1cM7lpjFLXp8dz7MxKR4mNSltZYRGSyhcR5Ucl6Qo7/SJBgw2t2xFw3GmGnIQOZWqu5af0YX7RI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=KNWNZkX9; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="KNWNZkX9" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-4864a5c83f1so895568b6e.0 for ; Thu, 04 Jun 2026 18:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621247; x=1781226047; 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=s5/opMyYHstCvLC6D+VPIEWzznFTHx3VHFIRMnLujuM=; b=KNWNZkX9kLpS4gabua3/yI5m7wEqpDqKLZhFe0MVlq0ETSIByWF/CaCdM/03v6Rhyq kQOvv9SzdDUmj+pDq+RWiLK5VkUrNiII89iVRE1IrZtu/P5gjyi8LDSuePZkvGuA8riK PW7hV5UPNga9/Q0nKRzCZf0q5BNVwoOLT6FyY+qCIDrv8ymYx79glExRiWSEhG1sY/6+ Ky0nrMCdZAxmLHeglV6EwPUs3C2GPGrFLKmKnw5I80JhQVNGpghbPwINmPSSGjN2nm3O 6JrWd8nvUpFG1k5H9BqhQ43Z0Y1X+XheNrO3g0P6XemQn5JfFLo2zKbDIHrmA6eX8Lt3 fPUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621247; x=1781226047; 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=s5/opMyYHstCvLC6D+VPIEWzznFTHx3VHFIRMnLujuM=; b=Ulpl8x4AAHiEEn0tkpjGXxJ5S6HhvLivsRbvUtjLQMKvTLpQ3tZyYNNiPosKCiqMUo Sklg5l7JUpPNcbMNL7ntnNd+FjQcjBHMxhWZDu77CzK0r/wM45EnXGwUCp0LBJrN4MCq IMoa5HGSIRuR3f5ZLsXa1nAoTOjf/i/erBzyL/ZBvQ8GercBgMSWKFPK4xBxfTnPjlzt HcYkz9M9pJG5/kT+meuQLK6EMieHn6M9XJJDiTmv4vJtjutQYMn2NW/OnEb2jwjyWDwy hrOfOaDMP1mTu7E0cDKUKUluT17QLiMQnOf9NuSf3uOSgm/bHMzTYFkJlVGP9zcwXWOv E5bw== X-Forwarded-Encrypted: i=1; AFNElJ/r62cvhyda0yHaSZEce2awPN/wSKncdNF3lbdABXA8qyzPdweztTSG2lhnO6VhxH9UJN6eb9WCbxtzhqQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxcwpJWadKH2gQrOJnbvqVl807gqTBbEhSzXKSIxeRNlAZEC9J3 9A1y6scgWmEhq4GcePEytggbDmQmN+yELzfOar3eMzQmsfNre67+AbfxSyG+lV0pRy4= X-Gm-Gg: Acq92OHusyKe3BsOb8b2rYN0TNAymP08syE02w/h5Dcb2AlCPXKtR9lUacBrm68chQs HqWPe4dkjbYGjEmcocwIATvN+6Yy/EacAdzVHQHFKKXaW/M7j72qB55ROo42KOO279kSo05XcZN EADpfAtGz/BHx7FOfhAxacda3/NYu09tAEz4us0p5pjYjHCqLZpj0npbv6RTn38Y586x/HPabpK wvPAjDHiAucOshYHaFAAzRnC+WpkidPjAh4Kw7foP5RIt/Xampq0X7/dmqKhwcFykWaASwtUbtX Jad68TO+5TQEc+2dC489IX45UfnHMsjUSkuFKf5MdVycRR4q83yBkm5j1A/rNBSGayGdeWyZv4g PI/rGQywLw1dSAS9w9iSHRnUbskiZvEq1EkfNh1oUmJOGNUDQs5x8u/lLwQUKeZN4mpYoyN9bmK 7RQlNCFgAjKP2xhpBKxCaj6SNQOHwzHgZZREKinQ== X-Received: by 2002:a05:6808:2e4e:b0:47c:6c9c:607d with SMTP id 5614622812f47-4868dc00eeemr864279b6e.2.1780621247107; Thu, 04 Jun 2026 18:00:47 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:46 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: daniel@riscstar.com, elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 06/14] net: stmmac: dma: create a separate dma_device pointer Date: Thu, 4 Jun 2026 20:00:13 -0500 Message-ID: <20260605010022.968612-7-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Toshiba TC956x Ethernet bridge chip is an Ethernet AVN/TSN bridge that is essentially a small but specialized SoC. It provides two XGMAC Ethernet interfaces along with a number of internal IP blocks, some of which are used by both eMACs. The chip implements two internal PCIe functions, and one of these is used to manage the common internal IPs. Both of the PCIe functions use an auxiliary bus device to represent an XGMAC Ethernet interface. Separating the PCIe function from the XGMAC IP this way helps in managing the life cycle for various objects (common and per-MAC). However this separation means that the MAC device is no longer the proper device to use for DMA. To address this, we add support for a second "DMA device" pointer in the stmmac_priv structure. The DMA device pointer is used for all DMA operations, while the "normal" device pointer is used for log messages, memory allocation, runtime power management, and a few other things. To set up the DMA device pointer, we add a new device structure pointer to the plat_stmmacenet_data structure. If set, it will be assigned as the (new) dma_device pointer field in the stmmac_priv structure. If the plat_stmmacenet_data field is NULL, the "normal" device pointer is assigned as the dma_device pointer instead (preserving existing behavior). Signed-off-by: Alex Elder --- .../net/ethernet/stmicro/stmmac/chain_mode.c | 12 ++-- .../net/ethernet/stmicro/stmmac/ring_mode.c | 12 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 58 ++++++++++--------- .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 2 +- include/linux/stmmac.h | 1 + 6 files changed, 45 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net= /ethernet/stmicro/stmmac/chain_mode.c index fc04a23342cfc..331e6523ee018 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -34,10 +34,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, buf_len =3D min_t(unsigned int, nopaged_len, bmax); len =3D nopaged_len - buf_len; =20 - des2 =3D dma_map_single(priv->device, skb->data, + des2 =3D dma_map_single(priv->dma_device, skb->data, buf_len, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; tx_q->tx_skbuff_dma[entry].buf =3D des2; tx_q->tx_skbuff_dma[entry].len =3D buf_len; @@ -51,11 +51,11 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, desc =3D tx_q->dma_tx + entry; =20 if (len > bmax) { - des2 =3D dma_map_single(priv->device, + des2 =3D dma_map_single(priv->dma_device, (skb->data + bmax * i), bmax, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; tx_q->tx_skbuff_dma[entry].buf =3D des2; tx_q->tx_skbuff_dma[entry].len =3D bmax; @@ -64,11 +64,11 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, len -=3D bmax; i++; } else { - des2 =3D dma_map_single(priv->device, + des2 =3D dma_map_single(priv->dma_device, (skb->data + bmax * i), len, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; tx_q->tx_skbuff_dma[entry].buf =3D des2; tx_q->tx_skbuff_dma[entry].len =3D len; diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/= ethernet/stmicro/stmmac/ring_mode.c index 78fc6aa5bbe95..0d334c51fc1c2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -37,10 +37,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, =20 if (nopaged_len > BUF_SIZE_8KiB) { =20 - des2 =3D dma_map_single(priv->device, skb->data, bmax, + des2 =3D dma_map_single(priv->dma_device, skb->data, bmax, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; =20 tx_q->tx_skbuff_dma[entry].buf =3D des2; @@ -58,10 +58,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, else desc =3D tx_q->dma_tx + entry; =20 - des2 =3D dma_map_single(priv->device, skb->data + bmax, len, + des2 =3D dma_map_single(priv->dma_device, skb->data + bmax, len, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; tx_q->tx_skbuff_dma[entry].buf =3D des2; tx_q->tx_skbuff_dma[entry].len =3D len; @@ -72,10 +72,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, stru= ct sk_buff *skb, STMMAC_RING_MODE, 1, !skb_is_nonlinear(skb), skb->len); } else { - des2 =3D dma_map_single(priv->device, skb->data, + des2 =3D dma_map_single(priv->dma_device, skb->data, nopaged_len, DMA_TO_DEVICE); desc->des2 =3D cpu_to_le32(des2); - if (dma_mapping_error(priv->device, des2)) + if (dma_mapping_error(priv->dma_device, des2)) return -1; tx_q->tx_skbuff_dma[entry].buf =3D des2; tx_q->tx_skbuff_dma[entry].len =3D nopaged_len; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/eth= ernet/stmicro/stmmac/stmmac.h index 8ba8f03e1ce03..76c8551687998 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -278,6 +278,7 @@ struct stmmac_priv { void __iomem *ioaddr; struct net_device *dev; struct device *device; + struct device *dma_device; struct mac_device_info *hw; int (*hwif_quirks)(struct stmmac_priv *priv); struct mutex lock; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 35da51c262484..09d2640a18b3c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1730,12 +1730,12 @@ static void stmmac_free_tx_buffer(struct stmmac_pri= v *priv, if (tx_q->tx_skbuff_dma[i].buf && tx_q->tx_skbuff_dma[i].buf_type !=3D STMMAC_TXBUF_T_XDP_TX) { if (tx_q->tx_skbuff_dma[i].map_as_page) - dma_unmap_page(priv->device, + dma_unmap_page(priv->dma_device, tx_q->tx_skbuff_dma[i].buf, tx_q->tx_skbuff_dma[i].len, DMA_TO_DEVICE); else - dma_unmap_single(priv->device, + dma_unmap_single(priv->dma_device, tx_q->tx_skbuff_dma[i].buf, tx_q->tx_skbuff_dma[i].len, DMA_TO_DEVICE); @@ -2166,7 +2166,7 @@ static void __free_dma_rx_desc_resources(struct stmma= c_priv *priv, =20 size =3D stmmac_get_rx_desc_size(priv) * dma_conf->dma_rx_size; =20 - dma_free_coherent(priv->device, size, addr, rx_q->dma_rx_phy); + dma_free_coherent(priv->dma_device, size, addr, rx_q->dma_rx_phy); =20 if (xdp_rxq_info_is_reg(&rx_q->xdp_rxq)) xdp_rxq_info_unreg(&rx_q->xdp_rxq); @@ -2214,7 +2214,7 @@ static void __free_dma_tx_desc_resources(struct stmma= c_priv *priv, =20 size =3D stmmac_get_tx_desc_size(priv, tx_q) * dma_conf->dma_tx_size; =20 - dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); + dma_free_coherent(priv->dma_device, size, addr, tx_q->dma_tx_phy); =20 kfree(tx_q->tx_skbuff_dma); kfree(tx_q->tx_skbuff); @@ -2266,8 +2266,8 @@ static int __alloc_dma_rx_desc_resources(struct stmma= c_priv *priv, pp_params.flags =3D PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; pp_params.pool_size =3D dma_conf->dma_rx_size; pp_params.order =3D order_base_2(num_pages); - pp_params.nid =3D dev_to_node(priv->device); - pp_params.dev =3D priv->device; + pp_params.nid =3D dev_to_node(priv->dma_device); + pp_params.dev =3D priv->dma_device; pp_params.dma_dir =3D xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE; pp_params.offset =3D stmmac_rx_offset(priv); pp_params.max_len =3D dma_conf->dma_buf_sz; @@ -2290,7 +2290,7 @@ static int __alloc_dma_rx_desc_resources(struct stmma= c_priv *priv, =20 size =3D stmmac_get_rx_desc_size(priv) * dma_conf->dma_rx_size; =20 - addr =3D dma_alloc_coherent(priv->device, size, &rx_q->dma_rx_phy, + addr =3D dma_alloc_coherent(priv->dma_device, size, &rx_q->dma_rx_phy, GFP_KERNEL); if (!addr) return -ENOMEM; @@ -2369,7 +2369,7 @@ static int __alloc_dma_tx_desc_resources(struct stmma= c_priv *priv, =20 size =3D stmmac_get_tx_desc_size(priv, tx_q) * dma_conf->dma_tx_size; =20 - addr =3D dma_alloc_coherent(priv->device, size, + addr =3D dma_alloc_coherent(priv->dma_device, size, &tx_q->dma_tx_phy, GFP_KERNEL); if (!addr) return -ENOMEM; @@ -2898,12 +2898,12 @@ static int stmmac_tx_clean(struct stmmac_priv *priv= , int budget, u32 queue, if (likely(tx_q->tx_skbuff_dma[entry].buf && tx_q->tx_skbuff_dma[entry].buf_type !=3D STMMAC_TXBUF_T_XDP_TX)) { if (tx_q->tx_skbuff_dma[entry].map_as_page) - dma_unmap_page(priv->device, + dma_unmap_page(priv->dma_device, tx_q->tx_skbuff_dma[entry].buf, tx_q->tx_skbuff_dma[entry].len, DMA_TO_DEVICE); else - dma_unmap_single(priv->device, + dma_unmap_single(priv->dma_device, tx_q->tx_skbuff_dma[entry].buf, tx_q->tx_skbuff_dma[entry].len, DMA_TO_DEVICE); @@ -4571,9 +4571,9 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *sk= b, struct net_device *dev) first =3D desc; =20 /* first descriptor: fill Headers on Buf1 */ - des =3D dma_map_single(priv->device, skb->data, skb_headlen(skb), + des =3D dma_map_single(priv->dma_device, skb->data, skb_headlen(skb), DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, des)) + if (dma_mapping_error(priv->dma_device, des)) goto dma_map_err; =20 stmmac_set_desc_addr(priv, first, des); @@ -4599,10 +4599,10 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *= skb, struct net_device *dev) for (i =3D 0; i < nfrags; i++) { const skb_frag_t *frag =3D &skb_shinfo(skb)->frags[i]; =20 - des =3D skb_frag_dma_map(priv->device, frag, 0, + des =3D skb_frag_dma_map(priv->dma_device, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, des)) + if (dma_mapping_error(priv->dma_device, des)) goto dma_map_err; =20 stmmac_tso_allocator(priv, des, skb_frag_size(frag), @@ -4827,9 +4827,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, s= truct net_device *dev) } else { bool last_segment =3D (nfrags =3D=3D 0); =20 - dma_addr =3D dma_map_single(priv->device, skb->data, + dma_addr =3D dma_map_single(priv->dma_device, skb->data, nopaged_len, DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, dma_addr)) + if (dma_mapping_error(priv->dma_device, dma_addr)) goto dma_map_err; =20 stmmac_set_tx_skb_dma_entry(tx_q, first_entry, dma_addr, @@ -4878,9 +4878,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, s= truct net_device *dev) =20 desc =3D stmmac_get_tx_desc(priv, tx_q, entry); =20 - dma_addr =3D skb_frag_dma_map(priv->device, frag, 0, frag_size, - DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, dma_addr)) + dma_addr =3D skb_frag_dma_map(priv->dma_device, frag, 0, + frag_size, DMA_TO_DEVICE); + if (dma_mapping_error(priv->dma_device, dma_addr)) goto dma_map_err; /* should reuse desc w/o issues */ =20 stmmac_set_tx_skb_dma_entry(tx_q, entry, dma_addr, frag_size, @@ -5190,9 +5190,9 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *p= riv, int queue, =20 tx_desc =3D stmmac_get_tx_desc(priv, tx_q, entry); if (dma_map) { - dma_addr =3D dma_map_single(priv->device, xdpf->data, + dma_addr =3D dma_map_single(priv->dma_device, xdpf->data, xdpf->len, DMA_TO_DEVICE); - if (dma_mapping_error(priv->device, dma_addr)) + if (dma_mapping_error(priv->dma_device, dma_addr)) return STMMAC_XDP_CONSUMED; =20 buf_type =3D STMMAC_TXBUF_T_XDP_NDO; @@ -5201,7 +5201,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *p= riv, int queue, =20 dma_addr =3D page_pool_get_dma_addr(page) + sizeof(*xdpf) + xdpf->headroom; - dma_sync_single_for_device(priv->device, dma_addr, + dma_sync_single_for_device(priv->dma_device, dma_addr, xdpf->len, DMA_BIDIRECTIONAL); =20 buf_type =3D STMMAC_TXBUF_T_XDP_TX; @@ -5788,7 +5788,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int li= mit, u32 queue) if (!skb) { unsigned int pre_len, sync_len; =20 - dma_sync_single_for_cpu(priv->device, buf->addr, + dma_sync_single_for_cpu(priv->dma_device, buf->addr, buf1_len, dma_dir); net_prefetch(page_address(buf->page) + buf->page_offset); @@ -5867,7 +5867,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int li= mit, u32 queue) skb_mark_for_recycle(skb); buf->page =3D NULL; } else if (buf1_len) { - dma_sync_single_for_cpu(priv->device, buf->addr, + dma_sync_single_for_cpu(priv->dma_device, buf->addr, buf1_len, dma_dir); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, buf->page, buf->page_offset, buf1_len, @@ -5876,7 +5876,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int li= mit, u32 queue) } =20 if (buf2_len) { - dma_sync_single_for_cpu(priv->device, buf->sec_addr, + dma_sync_single_for_cpu(priv->dma_device, buf->sec_addr, buf2_len, dma_dir); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, buf->sec_page, 0, buf2_len, @@ -7817,6 +7817,7 @@ static int __stmmac_dvr_probe(struct device *device, =20 priv =3D netdev_priv(ndev); priv->device =3D device; + priv->dma_device =3D plat_dat->dma_device ? : device; priv->dev =3D ndev; =20 for (i =3D 0; i < MTL_MAX_RX_QUEUES; i++) @@ -7945,8 +7946,8 @@ static int __stmmac_dvr_probe(struct device *device, priv->dma_cap.host_dma_width =3D priv->dma_cap.addr64; =20 if (priv->dma_cap.host_dma_width) { - ret =3D dma_set_mask_and_coherent(device, - DMA_BIT_MASK(priv->dma_cap.host_dma_width)); + ret =3D dma_set_mask_and_coherent(priv->dma_device, + DMA_BIT_MASK(priv->dma_cap.host_dma_width)); if (!ret) { dev_info(priv->device, "Using %d/%d bits DMA host/device width\n", priv->dma_cap.host_dma_width, priv->dma_cap.addr64); @@ -7958,7 +7959,8 @@ static int __stmmac_dvr_probe(struct device *device, if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT)) priv->plat->dma_cfg->eame =3D true; } else { - ret =3D dma_set_mask_and_coherent(device, DMA_BIT_MASK(32)); + ret =3D dma_set_mask_and_coherent(priv->dma_device, + DMA_BIT_MASK(32)); if (ret) { dev_err(priv->device, "Failed to set DMA Mask\n"); goto error_hw_init; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_xdp.c index d7e4db7224b0c..7ba068f1ca88d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c @@ -25,7 +25,7 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *pri= v, if (frame_size < ETH_FRAME_LEN + VLAN_HLEN * 2) return -EOPNOTSUPP; =20 - err =3D xsk_pool_dma_map(pool, priv->device, STMMAC_RX_DMA_ATTR); + err =3D xsk_pool_dma_map(pool, priv->dma_device, STMMAC_RX_DMA_ATTR); if (err) { netdev_err(priv->dev, "Failed to map xsk pool\n"); return err; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 4430b967abdeb..02ae177d5c27d 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -245,6 +245,7 @@ struct plat_stmmacenet_data { struct stmmac_mdio_bus_data *mdio_bus_data; struct device_node *phy_node; struct device_node *mdio_node; + struct device *dma_device; struct stmmac_dma_cfg *dma_cfg; struct stmmac_safety_feature_cfg *safety_feat_cfg; int clk_csr; --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 74D793264E2 for ; Fri, 5 Jun 2026 01:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621271; cv=none; b=m9Eo/bYFnWVj5QeV4jBltziV+4tVPtknhUTPqQn8hKCQzDYrKAjQDjLLvHEizj44/4wtymed+57gCNSSmE4i2QqmM4JJLzDUmtiRqkZTUt+bNhA4lcZL5kcSwN7OdSFl9Hs8SJE+A0+c1J+E9K2yHvnR4QfDk+wMaM9kXUVULv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621271; c=relaxed/simple; bh=rWJMdH+guxvVRg/fYfPqNZhV8vkxgoYK2GCfMJpBrRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=unUNyjgpMmzWWQradIdJqvscfLug89PcMFIrInLa5F9JNwQEONkibUm57ts2iyXcHRZKChR2/G+tJ4dGfAeVtIiGI6iyjJodvZOlp0Ykyw+uzglESWklyw+GQalyI03hw+eA21sJ27PWDa9AgNmK2rX8ZXNM/FIz2ukrvvuIOS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=hsqAdUk3; arc=none smtp.client-ip=209.85.160.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="hsqAdUk3" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-43cce34c881so1084587fac.2 for ; Thu, 04 Jun 2026 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621250; x=1781226050; 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=lJZ0RqgIk8/DP02YY4aEMI6Gbsvdjs3yNWLkzeFClOw=; b=hsqAdUk3g0d8hX8GwxQMCFxWfR5jrXZTsrL+A5s1cWD0QycxMcDyH1YILlMcuJJjpP 22zvT/jDunMY5iftF2R03vk3YUgCS2FUitNn+9iIG5B2qFwbPOjwdMOFlbv5OkasBIpW 3z44NuIu3+zijT769bbC9L5/wfQKLOIEkanKhysKMwOTGV3gd61oa949rKcU7SJ7lQ/0 8JGG+CNVRUUIu25eaWL7IzFGKmeE6em+wFG3qJJG6h2XGourhmlZq257M+JPyMh8YjOM QZXv81SzWB57ryPMbtBMPXdCInLf+qn7IFOYPJEoEC1i3uHCbFQ5xBkXsr7MXt5xqJYk 6tOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621250; x=1781226050; 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=lJZ0RqgIk8/DP02YY4aEMI6Gbsvdjs3yNWLkzeFClOw=; b=jmDLrul3jKgM8US3dBoyHhaqFRPcV+aEb0QWH42FhWyY/feEfwTOCAySGpnAJRoBO6 6LA+jZ/L9I9JiMRSDiXPDrB+cfXbDPj4+w6OegVCB1dSWgsMus9J1F02xYVhlpN4hTyc xYI8TeVrPsIZ/qamRp37VQChacbhhSh9O+RtJcQONENCKgPd96r9C375M1cjPrsoGJKm QH2m5YuKF1FBsxfica9oyRgyGfYd9rd6VzftujLxJSzpNFzo19ZnCcG7jUwr40V4Vieq jwwKcVwEaxg+m91bVCH+BgYpkZTbAqlWZRdlX+MJklIrYEbCpCbTP8hZIKKr98oJIolO ulGA== X-Forwarded-Encrypted: i=1; AFNElJ+kYJ0jziCIldqJqd0SQsv1ojZeKkrYHeBLDJUhIRrphxrQ4FX11H6Fyj8i4dqq0SumGliTQgDB79bDGGM=@vger.kernel.org X-Gm-Message-State: AOJu0YywQ/LPtuKEdnz8Clz++BVNulIm4iwXpGWEjKzhj2rMbpKBq2KN eoWF4v1799mnCUWZ+czGhmdvqm/I7e5B708XyAziwsGgcQ3dWfKvOZCJCLpIKdrvpDo= X-Gm-Gg: Acq92OHVtcd/JhdVAGZcl1X+VYYNdXiQgeE1VlBQaK3azU/kWaMAYdvi7lhJX+kKOBr O8+wMH9V1sykaCUgQDf3Np7opdCFe0j13NnceDWzhjXqdDn1rW7zjbAjPCnPAyhf4rXpkvAx8Od lisLMZMmmZNETxHwC81KAfZ4zsPyywmxJyNDt1UoKsCnUoc1CjsQ9nuMTv/I2scZ0dBuu7Ly0Te O6gZn4DnKCUa/rKhGjegPOVvOVYeC1aYz+JksrjWLWy4+AOcrzpidWj/zg0986F5MnKazPtSRSe zFVyODahocWVNq3P9CPKtaSHauWEu7usA1BAwwwwDSKufZvtQiPRXd6uy0cYNVMBSOI0y2Wd8oV 6zTbQ7jLtoOxstk4mR9Z1+eYxXSPi3DjKiPF6txgT1IpQjXgS2ZduUKlu/u3mQ1q7tvnRhYIlTG zUEyhibbucBgBgdNzIZ8cyHweUFsilG4k8IgamQQ== X-Received: by 2002:a05:6808:d4d:b0:485:4601:9c84 with SMTP id 5614622812f47-4868de44d92mr853906b6e.29.1780621250160; Thu, 04 Jun 2026 18:00:50 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:49 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 07/14] net: stmmac: dwxgmac2: Add multi MSI interrupt mode Date: Thu, 4 Jun 2026 20:00:14 -0500 Message-ID: <20260605010022.968612-8-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Currently there are no XGMAC platforms integrated using the multi MSI interrupt mode. In other words no existing driver sets both DWMAC_CORE_XGMAC and STMMAC_FLAG_MULTI_MSI_EN. In order to support systems that do enable both options (such as the Toshiba TC9564 whose driver is currently being developed) we need to add logic to the XGMAC DMA callbacks. Happily we can simply replicate similar code from GMAC4. Let's do that! Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index 51943705a2b03..9b0b5cc619556 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -320,6 +320,8 @@ /* DMA Registers */ #define XGMAC_DMA_MODE 0x00003000 #define XGMAC_SWR BIT(0) +#define XGMAC_INTM_MASK GENMASK(13, 12) +#define XGMAC_INTM_MODE1 0x1 #define XGMAC_DMA_SYSBUS_MODE 0x00003004 #define XGMAC_WR_OSR_LMT GENMASK(29, 24) #define XGMAC_RD_OSR_LMT GENMASK(21, 16) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/n= et/ethernet/stmicro/stmmac/dwxgmac2_dma.c index 03437f1cf3df3..a84601ac32153 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -31,6 +31,14 @@ static void dwxgmac2_dma_init(void __iomem *ioaddr, value |=3D XGMAC_EAME; =20 writel(value, ioaddr + XGMAC_DMA_SYSBUS_MODE); + + value =3D readl(ioaddr + XGMAC_DMA_MODE); + + if (dma_cfg->multi_msi_en) + value =3D u32_replace_bits(value, XGMAC_INTM_MODE1, + XGMAC_INTM_MASK); + + writel(value, ioaddr + XGMAC_DMA_MODE); } =20 static void dwxgmac2_dma_init_chan(struct stmmac_priv *priv, --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 9CDD833F8DC for ; Fri, 5 Jun 2026 01:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621281; cv=none; b=TAOIJt/RkP/B4Kts42e7YNqUUpfoGN7Y4Tqouiu86kG6BPrmOrQr82y3rQ0xTGSOkR6YDKF+StrfME/L69xsjGwxftC3L3mNKWDrj9LMkpjrd3T69oBThaQ/9VVwIdNlxWtZs62gwB+UDbJxZ3dyj5o4upCKKBPklyklpQTvvbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621281; c=relaxed/simple; bh=rpLXgYSA9ynFB3Z3mEXcg+Fu+uSw2ie7fIqqWqhCqXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ul2AEluWuPDb26jPHqzF/3bqQ5tQutASiE4Y1eo/eR88fyUYnxH0C2dUYxoyigbilyI8p/WkCHxWHvwSPYw/Q1Xt5svzz+9E+VF71M9Z5W7uR3IzVwNTO961gEMZDlhhOAWz/oyQMVR4MD2Gl32bSi2TEO9KABZxQixQfHhnWKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=hg8jbsVK; arc=none smtp.client-ip=209.85.167.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="hg8jbsVK" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-4865b9e2719so769742b6e.3 for ; Thu, 04 Jun 2026 18:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621253; x=1781226053; 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=cuK6dXKBAsFNVUM3IcE6hxmCyNGfHV5JrrNTNHc8ejQ=; b=hg8jbsVKKDt6HQSVftMw9VZQcH5AJ+PHQMwDx3+Ym5jxtWlUXS9RI5WczFruEDwkcM N47+zcfrZ+QSlHHvAGFpFVxuZIhOYtYTSalNG+UIbSQTidg0r0lflImIGKFGe+lyOzN7 +X/OzrrxUxafeDZqzEe986p+iXv8og5kq+/jC0QLY8bTBPCUhqWe5K++KbHk9P1E6g/x KirHj0Qf6PmmdakwjmR6fntZXmcSVixFlAW49Fs+huTHN5d8nyYqB6YkTeaNdqYGSYdU Dm5N8ssSC/ttPzmN4PWRX1OXVcJ8YHpHmZULd1L67C/1EAPyLjtyjvRKzgVBIVWoKG2p YvUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621253; x=1781226053; 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=cuK6dXKBAsFNVUM3IcE6hxmCyNGfHV5JrrNTNHc8ejQ=; b=Cg9hZ5SbdxrD06I4yXvgDZh2W0+xIfyPVpAbUBA/txzgLs5wgK+6IiT5+F7QWEre/q MfPn4d0+mDEG2SulVX4YJQphXag8BVou+xlJBhoYXP2TRgESYcBUc3trsmJtR/5iq0ko UVEcDVMytad4DdssY8FTEsSjcKISsnJSCzqDbs6UWwt3kioSOneYRVobczXQCAdKO+e5 A2jvpxVCIneF52efZVrEHp7QEsHmkF4v/7Tp49425r3YZupUjVuuJt5L7h1D+sbVjP2h 7I6aZnQVvQkr+pKx8nWqCi9qftKRq2LEr1tCqrproKUrw9nHIJlKgQbKR+Kl+NrFYViw 4ahA== X-Forwarded-Encrypted: i=1; AFNElJ/hQTy2Y3mmhHSw7lHqs8hvZKFJePVRW3RoEFJz7c/Qce0eu7cLIqNstZTpNAtXDpt5gRfT9kSDACIdmcg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8WefUFb6deZQNXJkBvYZNQRB51e7bgo3gpCTcx8zexXXIItx6 vOlxb9LRM4lO+pk+wf+BFyEDOD2uFwGnkUtJ9cTjBJalXDvZ19QeWzI2XsKZAPxVXos= X-Gm-Gg: Acq92OHO10+vmkMI5EcB/Ybr1+HOk59xD6lMnQY3/I878gS9BL2Y/6J+a2t6bcDMVMk 4p0MYHa7mdx62DhZUnaVaHkmmCa3It1FJdUaDSjtORpzKZVeAYrYyj5F7qXZPtvpg9b5yC8p2Sl MH+Fxacr+8mmO/2kkWXS8eSE/tyKJbu3YsfWfub37qxr+iNv7jocrmhHeWg8Znp4tCAJBfee5QW oi8pSb414swoQTBZCXhcZglevOk2SGt41rdH/fHqrt+cSAeQv1qVn+cqO1JhwzTdJWrLE/foAGA sfXOMzeuFkQ2WMuhBe0WBCLkZkcIoGk6lGgZnRaCz2tikUjN5V96SDga8RLkdJD6NJ01P/MCBsC dSvzhevJBs7l+97Oe629fBevbJV/Yw2vwDTHoDrTRC1w+DvfvcJJbjkYgrSLYjX/lEhBrzAelFN MmCDrZ0DuewluvKyspavgp9bKqUll44QmN7wj/QQIUKCOq7UUH X-Received: by 2002:a05:6808:d49:b0:479:e869:5424 with SMTP id 5614622812f47-4868dc7df9bmr777929b6e.19.1780621253368; Thu, 04 Jun 2026 18:00:53 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:53 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 08/14] net: stmmac: dwxgmac2: Add XGMAC 3.01a support Date: Thu, 4 Jun 2026 20:00:15 -0500 Message-ID: <20260605010022.968612-9-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson XGMAC 2.x and 3.x are architecturally very similar. That means that for everything except one erratum we can simply use the XGMAC 2.x callback functions in the stmmac_dma_ops structure. Only the set_rx_ring_len callback is specific to XGMAC 3.01. It limits the number of outstanding write requests that can be serviced per DMA. The other erratum addressed in this patch is simply a comment to ensure that a feature that stmmac doesn't currently use is not enabled without contemplating the errata. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 3 ++ .../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index 9b0b5cc619556..bcf59ad8a1939 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -374,6 +374,8 @@ #define XGMAC_DMA_CH_RxDESC_TAIL_LPTR(x) (0x0000312c + (0x80 * (x))) #define XGMAC_DMA_CH_TxDESC_RING_LEN(x) (0x00003130 + (0x80 * (x))) #define XGMAC_DMA_CH_RxDESC_RING_LEN(x) (0x00003134 + (0x80 * (x))) +#define XGMAC_OWRQ GENMASK(25, 24) +#define XGMAC_RDRL GENMASK(15, 0) #define XGMAC_DMA_CH_INT_EN(x) (0x00003138 + (0x80 * (x))) #define XGMAC_NIE BIT(15) #define XGMAC_AIE BIT(14) @@ -463,6 +465,7 @@ extern const struct stmmac_ops dwxgmac210_ops; extern const struct stmmac_ops dwxlgmac2_ops; extern const struct stmmac_dma_ops dwxgmac210_dma_ops; +extern const struct stmmac_dma_ops dwxgmac301_dma_ops; extern const struct stmmac_desc_ops dwxgmac210_desc_ops; =20 #endif /* __STMMAC_DWXGMAC2_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/n= et/ethernet/stmicro/stmmac/dwxgmac2_dma.c index a84601ac32153..584ab28d7f7f5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -38,6 +38,14 @@ static void dwxgmac2_dma_init(void __iomem *ioaddr, value =3D u32_replace_bits(value, XGMAC_INTM_MODE1, XGMAC_INTM_MASK); =20 + /* + * A friendly warning to future adventurers. If Descriptor Posted + * Write support, which is off by default, is ever enabled then be sure + * to make it optional. This is required by errata for at least XGMAC + * 3.01A... and the XGMAC 2.x and 3.x are architecturally similar so we + * use dwxgmac2 support for the 3.x family as well. + */ + writel(value, ioaddr + XGMAC_DMA_MODE); } =20 @@ -490,6 +498,20 @@ static void dwxgmac2_set_rx_ring_len(struct stmmac_pri= v *priv, writel(len, ioaddr + XGMAC_DMA_CH_RxDESC_RING_LEN(chan)); } =20 +static void dwxgmac301_set_rx_ring_len(struct stmmac_priv *priv, + void __iomem *ioaddr, u32 len, u32 chan) +{ + u32 val =3D FIELD_PREP(XGMAC_RDRL, len); + + /* + * Reduce the number of outstanding write requests to 3 (from default + * of 4). This is an errata workaround for XGMAC 3.01a. + */ + val |=3D FIELD_PREP(XGMAC_OWRQ, 3); + + writel(val, ioaddr + XGMAC_DMA_CH_RxDESC_RING_LEN(chan)); +} + static void dwxgmac2_set_tx_ring_len(struct stmmac_priv *priv, void __iomem *ioaddr, u32 len, u32 chan) { @@ -619,3 +641,34 @@ const struct stmmac_dma_ops dwxgmac210_dma_ops =3D { .enable_sph =3D dwxgmac2_enable_sph, .enable_tbs =3D dwxgmac2_enable_tbs, }; + +/* All but one field are the same as dwxgmac210_dma_ops */ +const struct stmmac_dma_ops dwxgmac301_dma_ops =3D { + .reset =3D dwxgmac2_dma_reset, + .init =3D dwxgmac2_dma_init, + .init_chan =3D dwxgmac2_dma_init_chan, + .init_rx_chan =3D dwxgmac2_dma_init_rx_chan, + .init_tx_chan =3D dwxgmac2_dma_init_tx_chan, + .axi =3D dwxgmac2_dma_axi, + .dump_regs =3D dwxgmac2_dma_dump_regs, + .dma_rx_mode =3D dwxgmac2_dma_rx_mode, + .dma_tx_mode =3D dwxgmac2_dma_tx_mode, + .enable_dma_irq =3D dwxgmac2_enable_dma_irq, + .disable_dma_irq =3D dwxgmac2_disable_dma_irq, + .start_tx =3D dwxgmac2_dma_start_tx, + .stop_tx =3D dwxgmac2_dma_stop_tx, + .start_rx =3D dwxgmac2_dma_start_rx, + .stop_rx =3D dwxgmac2_dma_stop_rx, + .dma_interrupt =3D dwxgmac2_dma_interrupt, + .get_hw_feature =3D dwxgmac2_get_hw_feature, + .rx_watchdog =3D dwxgmac2_rx_watchdog, + .set_rx_ring_len =3D dwxgmac301_set_rx_ring_len, /* Only 3.01 */ + .set_tx_ring_len =3D dwxgmac2_set_tx_ring_len, + .set_rx_tail_ptr =3D dwxgmac2_set_rx_tail_ptr, + .set_tx_tail_ptr =3D dwxgmac2_set_tx_tail_ptr, + .enable_tso =3D dwxgmac2_enable_tso, + .qmode =3D dwxgmac2_qmode, + .set_bfsize =3D dwxgmac2_set_bfsize, + .enable_sph =3D dwxgmac2_enable_sph, + .enable_tbs =3D dwxgmac2_enable_tbs, +}; --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 1B15A356A12 for ; Fri, 5 Jun 2026 01:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621281; cv=none; b=lNRwHyKQEDZVGRZbAbXlSoTAN0ZvnxKaC/p/HXboh6HO8pNopR8LJtI6iCgbgob5brI2KTXBdt+n9ZbmTt5QNZszJlhUxtGpkybhmbVQ/2wCto8oKfEvVtyCe9OsgjRCi141MLfKC8F+V30JAD43uXQbXBFSHL2yRj1qYDJcvUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621281; c=relaxed/simple; bh=jVce/FGPrlppCYirHntYfI3PY05wNfUxhYZHb68/6qI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EMUuqHZs98rGdl9OybJk9OylYTsjiAUQDl9ZZU1OkzdqqwaafArSWry+5fbJZ58wWg5QL40OuD1LT9F7BQV1TbybjjrUrurtBlFmFpsSeZc71VxHgDXkMhyCFp15P0aMwAIh5nxmOJV2jHu9JXNt4P3qLgQs9oRTJLGB8i4H0ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=w06WhaNI; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="w06WhaNI" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-48650c78e09so564412b6e.2 for ; Thu, 04 Jun 2026 18:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621257; x=1781226057; 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=7bUHKe8xq0j7moOuD73/H9vKbxT6KczY0fAxl1satXM=; b=w06WhaNI0tK9parGISgOsJDUgg+EH1tx+BYvqyGqjEyDScU7oQ5LFXfdFTmN9qLEDv caBecHYIXYjrjf2Sn2SgFaStgF1VLff0gRuWMFURgGC421uIEkqv4gdodYzxuTPzXx51 13LcOwmJxFqIjIs7qAN8vqorYhukvfBmn+1E9sxHZrcX7F+AarmSklfOEHAe1vn5XJaC 6j6fWSH74qW0899k1lxAmiaCkEfuSa6ytGa88CR2yu0QLd/kgLagO2d3EA4/yPIXzAIv /SGRe4HmaZIpK3U0yHWTN24SZkn/qkdEQbFbGjeVoYdk1XMmfr7tFaOJrgHfj6YwIJ4k S47Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621257; x=1781226057; 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=7bUHKe8xq0j7moOuD73/H9vKbxT6KczY0fAxl1satXM=; b=jJ1KD+E5iDeKzaRdRpPMcekMkYNlboX/FwfERx14fIjuikRe4XXPMr3jK8jDzU7YWI ZK0/ZsTu0fmq8UImw1R/qbU/02D3d1ZWeJgtlSWDdm0ksD+J4f4ZoR/MvMlXAvjJkrUD 48NWdmlbn8Qt08+xFm5gjDsAYeeQjVRRAcei8WbOdY3A2jf9gRSlfmmF6e5Ts9W60kuR MdztKO1JlBlTVx+QS0+WVXq8Rs7zJz1cUGnrNIwNbcy3TCCueINjQpzovq6gxuVjn+gi d3A+EHRFHf412AROY1aSmh0f+2MChsnKJ9vngVPZ+bLo58t5M9OluP8J4RtBm4XaHP+B mTpQ== X-Forwarded-Encrypted: i=1; AFNElJ9MOXkxYCWUGBgb0fFn+vEooJQh5RfhR9N+5Qh6NlhftexbKLL4IPSNjkj3eR/oE5igqV8lxhGMSBzlP6o=@vger.kernel.org X-Gm-Message-State: AOJu0YwJWGrMmIZiO2q5rL0CoB4OOKBzaN1XfBV8snUO9UbU7BJFHoW8 wvsu7pmPe+qOWVfmFpGZKCTquFjYSKCxrN528LudjGQ3BhB2p04+hgHKxD8kriZcluA= X-Gm-Gg: Acq92OGi6wLiyhgenRG1HxsRHaGbWvGf4kYAqTfOZxqOHJlZ/SgjsyLaRr0hrGJnNi6 4m4T47jJeqRZF24dEDC/boCQaKm6hqwbMunzt6/+3Epm2ueF4nA4Wy3TithQ3pFyZEPsWOJ8jN4 MbxBBRsn4I0QaAIe8KyTRhZzOCI4VgPwsp8Gg5QDY/H8kYLtYe2WIF0RR3Or70+k+TdrZ1saEBG R1zjm2qFAEdzopq4nmGgGjYMgSy4If6fMyoCiAknA9a1sZaki9pdclxS9BdPjCBfgtY9mkzAuQU rQFZzLPodHadxybgI/bwg9OipLs2z9TurItzwUuDd+voB51yIzM3WKGt/BfwWsBaW0wkN5wiRLh EFqAaJhshQ8anE+HORH0KpXiZLVgXNHKywmA0rC5FA39Yp3ja9x1dnpItdSLWDN566gTVail8QD lXCcB/BqF7Sl/Vv6otyShmXFjxmbxB+Ft6bIYRtw== X-Received: by 2002:a05:6808:1794:b0:486:3537:2193 with SMTP id 5614622812f47-4868dc58812mr926917b6e.11.1780621256480; Thu, 04 Jun 2026 18:00:56 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:55 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 09/14] net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA Date: Thu, 4 Jun 2026 20:00:16 -0500 Message-ID: <20260605010022.968612-10-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialised SoC. Ethernet on this chip is provided by a DesignWare XGMAC. One consequence of the SoC-like design is that the internal AXI bus (used by the XGMAC for DMA) maps the PCI DMA space with a non-zero base address. This requires a translation step (happily just simple addition) to convert the PCI DMA address to the hardware DMA address. This is pretty funky so rather than push that translation logic into the core driver we intend to keep that logic inside the TC956x platform code. In order to do that we need to export a few symbols to allow us to override some of the DMA and descriptor op tables. FWIW this approach to overriding the ops tables is similar to the mechanism currently found in dwmac-loongson.c (with the exception that we have also exported a couple of functions so we don't have to replicate their content in the TC956x platform code). Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 7 +++++++ .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 1 + .../net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index bcf59ad8a1939..8cecde1bef8a1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -468,4 +468,11 @@ extern const struct stmmac_dma_ops dwxgmac210_dma_ops; extern const struct stmmac_dma_ops dwxgmac301_dma_ops; extern const struct stmmac_desc_ops dwxgmac210_desc_ops; =20 +void dwxgmac2_dma_init_rx_chan(struct stmmac_priv *priv, void __iomem *ioa= ddr, + struct stmmac_dma_cfg *dma_cfg, dma_addr_t phy, + u32 chan); +void dwxgmac2_dma_init_tx_chan(struct stmmac_priv *priv, void __iomem *ioa= ddr, + struct stmmac_dma_cfg *dma_cfg, dma_addr_t phy, + u32 chan); + #endif /* __STMMAC_DWXGMAC2_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/= net/ethernet/stmicro/stmmac/dwxgmac2_core.c index f02b434bbd505..c9547dc6912a3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1556,6 +1556,7 @@ int dwxgmac2_setup(struct stmmac_priv *priv) =20 return 0; } +EXPORT_SYMBOL_GPL(dwxgmac2_setup); =20 int dwxlgmac2_setup(struct stmmac_priv *priv) { diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers= /net/ethernet/stmicro/stmmac/dwxgmac2_descs.c index b5f200a874840..cc67d8e1a920a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c @@ -368,3 +368,4 @@ const struct stmmac_desc_ops dwxgmac210_desc_ops =3D { .set_vlan =3D dwxgmac2_set_vlan, .set_tbs =3D dwxgmac2_set_tbs, }; +EXPORT_SYMBOL_GPL(dwxgmac210_desc_ops); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/n= et/ethernet/stmicro/stmmac/dwxgmac2_dma.c index 584ab28d7f7f5..f564b9bd7d128 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -62,10 +62,10 @@ static void dwxgmac2_dma_init_chan(struct stmmac_priv *= priv, writel(XGMAC_DMA_INT_DEFAULT_EN, ioaddr + XGMAC_DMA_CH_INT_EN(chan)); } =20 -static void dwxgmac2_dma_init_rx_chan(struct stmmac_priv *priv, - void __iomem *ioaddr, - struct stmmac_dma_cfg *dma_cfg, - dma_addr_t phy, u32 chan) +void dwxgmac2_dma_init_rx_chan(struct stmmac_priv *priv, + void __iomem *ioaddr, + struct stmmac_dma_cfg *dma_cfg, + dma_addr_t phy, u32 chan) { u32 rxpbl =3D dma_cfg->rxpbl ?: dma_cfg->pbl; u32 value; @@ -77,11 +77,11 @@ static void dwxgmac2_dma_init_rx_chan(struct stmmac_pri= v *priv, writel(upper_32_bits(phy), ioaddr + XGMAC_DMA_CH_RxDESC_HADDR(chan)); writel(lower_32_bits(phy), ioaddr + XGMAC_DMA_CH_RxDESC_LADDR(chan)); } +EXPORT_SYMBOL_GPL(dwxgmac2_dma_init_rx_chan); =20 -static void dwxgmac2_dma_init_tx_chan(struct stmmac_priv *priv, - void __iomem *ioaddr, - struct stmmac_dma_cfg *dma_cfg, - dma_addr_t phy, u32 chan) +void dwxgmac2_dma_init_tx_chan(struct stmmac_priv *priv, void __iomem *ioa= ddr, + struct stmmac_dma_cfg *dma_cfg, dma_addr_t phy, + u32 chan) { u32 txpbl =3D dma_cfg->txpbl ?: dma_cfg->pbl; u32 value; @@ -93,6 +93,7 @@ static void dwxgmac2_dma_init_tx_chan(struct stmmac_priv = *priv, writel(upper_32_bits(phy), ioaddr + XGMAC_DMA_CH_TxDESC_HADDR(chan)); writel(lower_32_bits(phy), ioaddr + XGMAC_DMA_CH_TxDESC_LADDR(chan)); } +EXPORT_SYMBOL_GPL(dwxgmac2_dma_init_tx_chan); =20 static void dwxgmac2_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi) { @@ -672,3 +673,4 @@ const struct stmmac_dma_ops dwxgmac301_dma_ops =3D { .enable_sph =3D dwxgmac2_enable_sph, .enable_tbs =3D dwxgmac2_enable_tbs, }; +EXPORT_SYMBOL_GPL(dwxgmac301_dma_ops); --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 EDF0136403D for ; Fri, 5 Jun 2026 01:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621286; cv=none; b=hQFKnborRndUNvZQKweAI8rpocXQtRHcF/Rf9jmvoOJyzoe5vpo3UuYs78b7MaS7kGqaGNe/cUzQo3vBHmoTLnuj677I53zzN1DXjVhktsU0+Anc19TcLgacHHid3hWdBSHlNSIHqNmRRiNDM9sW1kxkOG9LZQpT4tTh4swzM2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621286; c=relaxed/simple; bh=Q/ZNVyWH5+7aUXeLq9mlW50Vwgq0fqg1xk8VkFefUX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=okRBhtGNC61VodgBmAbYDUzARZB4OMXAlnyhhQ1gtyH5VrH8tptHotbQeoa4QgkMC9/Kwvm+dy2VPKiYJm98yM04W+R740BJL1Uc4EYKDZeUh5gRQA0rIkPazwxMrYLFNbFPiKwj1fBpp8f/fZ+9RDg5eLCfyANW8vSKLzZhB+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=VBA0oiYL; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="VBA0oiYL" Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-486118ecd5dso877143b6e.0 for ; Thu, 04 Jun 2026 18:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621260; x=1781226060; 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=/ZIGHz/o3y+3ogj7r6nfssUl4myckUIIzkFFbrT9qoc=; b=VBA0oiYLEp5RT1MN3a1hVsJ8aRjH4SnEjm8N5ALMhxnEZFGvXRgXW34Zan/sKl+2x5 deTqZHtZXgnm2dOSmEAm+PTuNrLpnF1OsuLx6ixjUnOyTcyesBZe5KEwogK+OY9HEu66 rVMgEtkStXsK3Pj5d3ODn57cpdsvFOgeritiO7eAdpEbwCcRelRrDh38Av2IqceiEWlf 594CitBmTaWgZU0eG+zjXP9rq9k++r7nyvZo3wJMZ3VfKBGJr/8Yn5uksoGqC/0LZcun PeQsD6SW9F3FTfxRr2T7e/Bo6u7mP9nOo1jfT+QxRPIk6VL7pqNDdqEVS5yk7//ZAhMQ 9g8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621260; x=1781226060; 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=/ZIGHz/o3y+3ogj7r6nfssUl4myckUIIzkFFbrT9qoc=; b=GEsiNKukF0mjiuU3FZfOg1ExFFeHwexRqP3XQbIy4oQxkNmXAU0B02s/kgrPY1NAYv Vtv/lTlWOklzjWFEAi9npuTEg40rmkT0KlHpW9bIfFQzM5omCU1r0a/JAmLOsOyqZOaV gzGEZGYn8puYcMwz6KZAi7YZD14uNMc+JiC37KNjOTTSqMboFM4sYFqP24vGpd3Ekn5g YSYDzCmrhhLuNw40Ftr7o2t/qQCqY07TZ5oLaqcOzhVpebg4771rAZa2ifT1WWl3krWR ewNHWMrVWWS4Intp77PIcYjvKMYlVtz3Gc5sC6CVb/1x/iq5XaahY2foXdZjZ2pIen/8 /Ypw== X-Forwarded-Encrypted: i=1; AFNElJ83VQI3wudJrOt7JuJ+xcg2PCkWZC4becCvQLTkrFe6EcW6q0qcoIzcF04ca0GWeJsnberkdX8sZ3jdmQU=@vger.kernel.org X-Gm-Message-State: AOJu0YySdz/MdDQJBWTh4I/NSUFMtSH6a2DTAQjOPR+uXvz/h4akjuKu 22i2gtvvdI24RnTddrO6G4VHuoH8m2BGYUhz1bs809XM4klfOZ5xo/F6ZJPjQUQB7Wk= X-Gm-Gg: Acq92OHdL0G29vZklkQA8umCdzH8D4kUMh271A1wbUDnDBqxJz22lM5eQn6QJbITc/a lBvWX++ozaL6EQcGTOoKacA/7Q72h9q/ArwzoqwxGFSOwIghwFPpXTO9F+mT2RClJ+y7DDNz+K/ 64H6MfW3C4fIaC0DkPMDTD9QepsVf+LZ0ax3DAbLftRs+FJj32XMYqETure5aQewR87CSM93Teq JCBLfzcTCweLJfXOnmlz4s33Eb1bC+ZhMMKjaMz/XHEULIOVx1M0f6s24XZP4KRPlfcXOa1r+7E xXMMI30cUr8WVcihiXTiJVL6ivYzd+uQ5629U0I4Udjr2Uf7JVjvmVbydY2V1KvEvLE5Gl/QpPT xT/5ZSmLjmSWH2RYsfRVeWM0Mlx2KPUshS4t61u7cdO6Uxr/d2N034wb8TNvUspCCDciqn6lmQr WJ2+wbAZQF5IYWEJfyxHm7Tt2qh4wpjE1U9VXKWA== X-Received: by 2002:a05:6808:11cb:b0:467:de0e:feb6 with SMTP id 5614622812f47-4868dc583f1mr883548b6e.11.1780621259486; Thu, 04 Jun 2026 18:00:59 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:00:59 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge Date: Thu, 4 Jun 2026 20:00:17 -0500 Message-ID: <20260605010022.968612-11-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges. The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation. The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused. The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers. Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/toshiba,tc9564-dw= mac.yaml diff --git a/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yam= l b/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file mode 100644 index 0000000000000..6e7a63dfcf86a --- /dev/null +++ b/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/toshiba,tc9564-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC956x Ethernet-AVB/TSN Controller + +maintainers: + - Alex Elder + - Daniel Thompson + +description: | + The Toshiba TC9564 (and more generally, TC956x) incorporates a PCIe + gen 3 switch with one upstream and three downstream ports. The first + two downstream ports are exposed externally, while the third is used + by an internal PCIe endpoint. The PCIe endpoint implements two PCIe + functions, and attached to each of these is a 10 Gbps capable Synopsys + Ethernet controller. + + The TC956x additionally implements other internal IP blocks, and in + particular it implements a GPIO controller. Ten of the 35 GPIO lines + implemented are exposed externally and are usable by the platform. + It is platform-dependent whether the GPIO function must be exposed, + and if it is, PCIe function 0 supplies it. + + ---------------------------------- + | Host | + ------+...+----------+........+--- + |i2c| | PCIe | + ----------------+...+----------+........+------ + | TC956x |I2C| |upstream| | + | ----- --+--------+--- | + | ----- ------ ------- | PCIe switch | | + | |SPI| |GPIO| |reset| | | | + | ----- ------ |clock| | DS3 DS2 DS1 | | + | ------- ---++--++--++-- | + | ----- ------ downstream// \\ \\ | downstream + | |MCU| |SRAM| /=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D/ \\ \=3D=3D= =3D=3D=3D PCIe port 1 + | ----- ------ //PCIe port 3 \\ | + | || \=3D=3D=3D=3D=3D=3D=3D downstr= eam + | ----+-----------++-----------+---- | PCIe port 2 + | | M | internal PCIe endpoint | M | | + | | S |------------------------| S | ------ | + | | I | PCIe | | PCIe | I | |UART| | + | | G |function 0| |function 1| G | ------ | + | | E |----++----| |----++----| E | | + | | N | eMAC 0 | | eMAC 1 | N | | + --------+.......+------+.....+----------------- + |USXGMII| |SGMII| + --+.......+-- --+.....+-- + | ARQ113C | | QEP8121 | + | PHY | | PHY | + ------------- ----------- + +properties: + compatible: + enum: + - pci1179,0220 # Toshiba TC9564 (a.k.a. Qualcomm QPS615) + + gpio: + type: object + description: Embedded GPIO controller + $ref: /schemas/gpio/gpio.yaml# + + ethernet: + type: object + description: XGMAC Ethernet controller + $ref: /schemas/net/ethernet-controller.yaml# + properties: + mdio: + $ref: snps,dwmac.yaml#/properties/mdio + required: + - mdio + +required: + - compatible + +allOf: + - $ref: /schemas/pci/pci-device.yaml# + - $ref: /schemas/pci/pci-bus-common.yaml# + +unevaluatedProperties: false + +examples: + - | + pcie { + #address-cells =3D <3>; + #size-cells =3D <2>; + + pci@0,0 { + compatible =3D "pci1179,0220"; + reg =3D <0x50000 0x0 0x0 0x0 0x0>; + #address-cells =3D <3>; + #size-cells =3D <2>; + device_type =3D "pci"; + ranges; + + gpio { + gpio-controller; + #gpio-cells =3D <2>; + }; + + ethernet { + phy-mode =3D "10gbase-r"; + phy-handle =3D <&tc9564_emac0_phy>; + + mdio { + compatible =3D "snps,dwmac-mdio"; + #address-cells =3D <1>; + #size-cells =3D <0>; + + tc9564_emac0_phy: ethernet-phy@1c { + compatible =3D "ethernet-phy-id311c.1c12"; + reg =3D <0x1c>; + }; + }; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 2aa6ea012c848..f976c9fa9d9c0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27052,6 +27052,12 @@ F: Documentation/devicetree/bindings/media/i2c/tos= hiba,tc358743.txt F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h =20 +TOSHIBA TC956X/QUALCOMM QPS615 DWMAC ETHERNET DRIVER +M: Alex Elder +M: Daniel Thompson +S: Maintained +F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos L: platform-driver-x86@vger.kernel.org --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 DE51D34F24E for ; Fri, 5 Jun 2026 01:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621292; cv=none; b=kfteUkrQ3IX6V+FZUpE8a1KV4xnMRbXO8yjPuwTsaQK9xJBJm6KkXZKZx1J0dNLexf62abiXfR4kVLfgMS32Un11cER2PVj9InZ8lHIPoEPiCIYGVUxk4+Jq18FwyipSplqql/Xm0Dkv4WQ9s0XNrHxyoYEW/jP34HR0NunFSvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621292; c=relaxed/simple; bh=DYCc2F1HcMDAHGMN+auKTRA5r6GlyDQMIIEJkbGncUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3wtHAroKKCdLk4itbUXzYSHGiqml3gUcQ4keVxIzItNMOJqGPVEC4+SwkzwV78atIv7XIc5cs+fUrsf0R2G+hCm2NVDwY/uNnWr86w17Jv+qXaGSn8NCK5RJ5RfsYWi8wxkoyyWl5Pzt6GZcOMRR8nXpnSMkQR3Vfk4WuEMFUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=kfjzkJkK; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="kfjzkJkK" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-4864a8e80bbso912343b6e.0 for ; Thu, 04 Jun 2026 18:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621263; x=1781226063; 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=VyP4bGzsJtjaWXxhoSrnojShl21NcNcWQsL4rRu4OI4=; b=kfjzkJkKTstaUw1CdbXeEEF9ezv/E+4QAg3f0XURMXramgapiOdNaBW+5xuiih6fpv 8oqljuc/54NfEZtJUpEPQKxKPLwupkGkIbxOuoxt1MuY1H+iIfksuGSa8XkZeHrO0pgD bN1YgCIwl5K0SDTB+kARj6y+LegvTwDKFDlFbrMGvU2nYrVQLStUxvQ4q1u/AAs2vBbs 5Vd9/vQp1Mnw5v+dpDOt7rJOY5SwsbyDtA3FqgApJHXGhcrk5LwPh4SFWsvkDD3+CcpY Nq3wYfrTN4YFLqZWK3fX2kvAgTAntqgMuyrvurFrKRguHcO/RYtRhl5+qspT1gGzOjfV +nzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621263; x=1781226063; 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=VyP4bGzsJtjaWXxhoSrnojShl21NcNcWQsL4rRu4OI4=; b=OHSgfhCF6T4WOUHmTgT1jZ+W9syq5Nwt7gvyapsu+1a8HLrFNWdn1uUgTRdyah5LOl PyLCQJYfgVGFaamaVvXzvdysn5Bb6OifsaxcIeGDlheot+QP7LyZV26rvP4yH41kOCwC 3j231NY3lS3Vd9CELVsgcSpYEkH93ThvzWsD0S01lu9JSKp7HkxGJDua4SRZzCfPB0OW PFMQiyGGNzvoc/zrIs0nTqoOj6OCWbISLJDKUb6tyWEhgJCPYXIVUXrJPKOzvRM1We/v VsI2jXWVcUn5r0cjwoPFuHQY23zFB6ikW+49QpxxI1XTYHaPVOPMTYFFmeFUwupJ7DI6 H0Ig== X-Forwarded-Encrypted: i=1; AFNElJ8wULRtKP0q2LDPxvQ5MrycoNca8dt6WGmYv4r/RRpCKsVQ7EqM6r7XpRfsVe6IbaiOicaBt1neCf3xBrU=@vger.kernel.org X-Gm-Message-State: AOJu0Yyz+3YnIPxyKWqtVukGhJFS128rLVEJzE6Tqatv3oujwf3FOvZ+ RY3leI3cTfFJPvjNfVEt8IUEGH8emK3zBmrU+28UStKJ9z1NcCJSdnhpGjgiiF5q8eI= X-Gm-Gg: Acq92OFNHMhSih5Ks+RyG8lyHwOpM1h11smOW2Ksjlq651ZG5mFg8oR5oNLZ84PeKwR V1r3K9BZv95AET5ihjkCmCWlFsdNIkP8/4FrZc8GV40HX+rCR1eG8P3vCDCo9D8hMfH9StY3JJ+ x4FVAnJmrg5xe3D9yO2Kuo8ewGQSv/jiNYZfsUbaoY2KNELkleWB86EffzoslnxUIOkdd6RbvJ2 9LtSblQj27h64SgubnkIPBu5hDoAmCKN/cQhHL6tycxX7DyYE78WVtX2MKrDWz3BAxOFe/Euan1 BRV6G7s+NMAWnRomuBSMtPG9YZjXYusaGe7Fr9XWHU1Fk/bGAk6TNtWmJfAzthe9Qc0RqXiFuJO 4u/MpSpHvxNXeRO6QSnW/zRJO5A5rtldD5tP4zqOllcnTL2ZXm/xLdcJk4JAjMoCVq8vicI/NSx BX1x/aFBlJfPNwPXrRr9cDcXmUZgGLydxH5F9zrQ== X-Received: by 2002:a05:6808:1310:b0:479:ac7d:6d94 with SMTP id 5614622812f47-4868de5a7fcmr773609b6e.24.1780621262648; Thu, 04 Jun 2026 18:01:02 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:01:02 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: daniel@riscstar.com, elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 11/14] misc: tc956x_pci: add TC956x/QPS615 support Date: Thu, 4 Jun 2026 20:00:18 -0500 Message-ID: <20260605010022.968612-12-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Toshiba TC956x is an Ethernet AVB/TSN bridge, and is essentially a small and highly-specialized SoC. It implements a number of internal functions, including a GPIO controller, registers that manage internal reset and clock control signals, a PCIe switch, an internal PCIe endpoint, and mapping hardware that translates between PCIe and internal addressing. The internal PCIe endpoint implements two PCIe functions, each of which has an attached eMAC. Two devices represent each of these: a PCIe function; and the eMAC. The PCIe function driver serves as the primary driver, creating other associated devices using the auxiliary bus. PCIe function 0 is responsible for managing common features on the TC956x chip. It initializes a "chip" data structure that keeps track of common information, and makes that available via its platform_data pointer to its PCIe function 1 peer. It also configures the address mapping hardware, and if a "gpio" devicetree sub-node is found, it creates an auxiliary device to represent the GPIO controller embedded in the TC956x. For both PCIe function 0 and function 1, an "ethernet" devicetree sub-node indicates that the attached XGMAC Ethernet controller should be active. In this case, an auxiliary device is created to represent that hardware. A block of information is set up to be shared with the auxiliary device. It provides the IRQ to be used by the MAC device, as well as a some memory-mapped I/O pointers and a few other bits of information about the chip. This information is supplied via the auxiliary device's platform_data pointer. Co-developed-by: Daniel Thompson Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- MAINTAINERS | 1 + drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/tc956x_pci.c | 741 +++++++++++++++++++++++++++++ include/soc/toshiba/tc956x-dwmac.h | 84 ++++ 5 files changed, 839 insertions(+) create mode 100644 drivers/misc/tc956x_pci.c create mode 100644 include/soc/toshiba/tc956x-dwmac.h diff --git a/MAINTAINERS b/MAINTAINERS index f976c9fa9d9c0..0924f7ec43cb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27057,6 +27057,7 @@ M: Alex Elder M: Daniel Thompson S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/misc/tc956x_pci.c =20 TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 00683bf06258f..e7152c641278d 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -644,6 +644,18 @@ config MCHP_LAN966X_PCI - lan966x-miim (MDIO_MSCC_MIIM) - lan966x-switch (LAN966X_SWITCH) =20 +config TOSHIBA_TC956X_PCI + tristate "Toshiba TC956X PCI function support" + depends on PCI + select AUXILIARY_BUS + select REGMAP + select REGMAP_MMIO + help + This enables support for the two PCI functions implemented by + the embedded PCIe endpoint in the Toshiba TC956X. This driver + creates auxiliary devices and requires drivers for these devices + to function. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index b32a2597d2467..644d508338382 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -75,3 +75,4 @@ obj-$(CONFIG_MCHP_LAN966X_PCI) +=3D lan966x-pci.o obj-y +=3D keba/ obj-y +=3D amd-sbi/ obj-$(CONFIG_MISC_RP1) +=3D rp1/ +obj-$(CONFIG_TOSHIBA_TC956X_PCI) +=3D tc956x_pci.o diff --git a/drivers/misc/tc956x_pci.c b/drivers/misc/tc956x_pci.c new file mode 100644 index 0000000000000..88865712f00de --- /dev/null +++ b/drivers/misc/tc956x_pci.c @@ -0,0 +1,741 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reser= ved. + */ + +/* + * The Toshiba TC956X implements a PCIe Gen 3 switch that connects an + * upstream x4 port to three downstream PCIe ports--two external ones + * and an internal one which implements an internal PCIe endpoint. The + * endpoint implements two PCIe functions, each having a Synopsys XGMAC + * Ethernet interface. + * + * The TC956X implements other functionality, including an embedded + * MCU, a UART, a GPIO controller, internal resets and clocks, and + * interrupt handling. These features are separate from (and in some + * cases used by) both Ethernet XGMACs. Each Ethernet MAC must be + * attached to a working PHY for it to be functional, and for this + * reason either of them (or both!) might not be usable/used. + * + * To support the non-XGMAC functionality on the TC956X regardless of + * the presence of either Ethernet PHY, the Ethernet functions are + * treated as two parts: a PCIe function; and a Synopsys XGMAC component. + * The PCIe function has access to the BARs used by the XGMAC, and maps + * them for use. Each XGMAP is treated as an auxiliary sub-device of + * its (parent) PCIe function, and is probed and bound separate from it. + * + * This PCI driver binds to the Toshiba TC956X (physical) PCI function + * (VID 0x1179, DID 0x0220). There are two of these present on the + * TC956X SoC. This driver maps the PCI BARs and performs other initial + * setup, then creates auxiliary devices. + * + * Embedded PCI function 0 manages non-MAC functionality. This includes + * creating and registering the GPIO auxiliary device (if necessary), as + * well as asserting and deasserting internal reset signals and enabling + * and disabling internal clocks. + * + * Both PCI functions create auxiliary devices to implement an Ethernet + * XGMAC. A block of data (struct tc956x_dwmac_data) is shared using + * the auxiliary device's platform data with the stmmac driver that + * binds to the XGMAC auxiliary device. This includes a number of + * pointers to memory regions used by the stmmac driver. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define DRIVER_NAME TC956X_PCIE_DRIVER_NAME + +#define GPIO_DEVICE_NAME "tc9564-gpio" + +#define PCI_DEVICE_ID_TOSHIBA_TC956X 0x0220 + +/* PCI BAR assignments */ +#define PCI_BAR_BRIDGE_CONFIG 0 /* For TAMAP */ +#define PCI_BAR_SFR 4 /* For all other features */ + +/* Chip and revision ID register */ +#define NCID_OFFSET 0x0000 +#define NCID_REV_ID_MASK GENMASK(7, 0) + +/* Reset and clock register offsets. MAC resets and clocks are controlled + * by bits in register 0 for MAC0, register 1 for MAC1. Other non-MAC + * resets and clocks (whose IDs are defined here) are controlled by bits + * in register 0. + * + * These are relative to the base of the clock/reset regmap. + */ +#define RSTCTRL0_OFFSET 0x0008 +#define RSTCTRL1_OFFSET 0x0010 +#define CLKCTRL0_OFFSET 0x0004 +#define CLKCTRL1_OFFSET 0x000c + +/* Resets (asserted or deasserted) */ +enum reset_id { + RESET_MCU =3D 0, + RESET_MCU1 =3D 1, + RESET_MSIGEN =3D 18, + RESET_INTC =3D 4, + RESET_UART0 =3D 16, +}; + +/* Clocks (enabled or disabled) */ +enum clock_id { + CLOCK_MCU =3D 0, + CLOCK_SRAM =3D 13, + CLOCK_MSIGEN =3D 18, + CLOCK_PLL =3D 24, + CLOCK_SGMII =3D 25, + CLOCK_REFCLKO =3D 26, /* 25 MHz clock output signal */ + CLOCK_INTC =3D 4, + CLOCK_UART0 =3D 16, +}; + +/* + * The TAMAP function has four AXI translation tables each with eight + * 4-byte registers. The Ethernet MAC accesses PCI resources through + * addressses based at TC956X_SLV00_SRC_ADDR, and the first translation + * table converts those to PCIe address space starting based at 0x0. + * We don't use the other three available TAMAC tables. + */ +#define ATR_AXI4_SLV0_OFFSET 0x0800 +#define AXI4_TABLE_ENTRY_COUNT 4 +#define AXI4_ENTRY_BASE(id) ((id) * AXI4_TABLE_STRIDE) +#define AXI4_TABLE_STRIDE 0x20 + +/* Address translation space parameters used for entry 0 */ +#define SLV00_ATR_SIZE 35 /* 2^36 (64 gigabytes) */ +/* TC956X_SLV00_SRC_ADDR is the source address, defined in the common head= er */ +#define SLV00_TRSL_ADDR 0x0000000000000000ULL + +/* Translation entry registers, fields, and values used */ +#define SRC_ADDR_LO_OFFSET 0x0000 +#define ATR_IMPL BIT(0) /* 1 =3D enabled */ +#define ATR_SIZE_MASK GENMASK(6, 1) /* size 2^(ATR + 1) */ +#define SRC_ADDR_HI_OFFSET 0x0004 +#define TRSL_ADDR_LO_OFFSET 0x0008 +#define TRSL_ADDR_HI_OFFSET 0x000c +#define TRSL_PARAM_OFFSET 0x0010 +#define TRSL_ID_MASK GENMASK(3, 0) +#define TRSL_ID_PCIE_TX_RX 0 +#define TRSL_PARAM_MASK GENMASK(27, 16) + +/* + * The TC956X implements an "SFR" address space, which provides access + * to *all* internal IP block registers, both MAC and non-MAC. This + * space is also accessible via an I2C interface used by the PCI pwrctl + * driver (in "pci-pwrctrl-tc9563.c"), though that driver accesses the + * range in a very limited way. For the MAC functions we divide up the + * range, providing specific addresses needed by the stmmac driver. + */ +#define EMAC_CTL_OFFSET(_mac_id) ((_mac_id) ? 0x1074 : 0x1070) +#define MSIGEN_OFFSET(_mac_id) ((_mac_id) ? 0xf100 : 0xf000) +#define DWMAC_OFFSET(_mac_id) ((_mac_id) ? 0x48000 : 0x40000) + +/* + * struct tc956x_chip - Common information related to the TC956X chip + * @dev: Device structure for function 0 + * @sfr: Mapped SFR regions (BAR 4, one per PCI function) + * @bridge_config: Regmap used for bridge configuration (BAR 0) + * @reset_clock_regmap: Regmap used for resets and clocks + * @rev_id: Chip revision ID (for quirks) + */ +struct tc956x_chip { + struct device *dev; + void __iomem *sfr[2]; + void __iomem *bridge_config; + struct regmap *reset_clock_regmap; + u8 rev_id; +}; + +static const struct regmap_config gpio_regmap_config =3D { + .name =3D "tc956x-gpio", + .reg_bits =3D 32, + .reg_stride =3D 4, + .reg_base =3D 0x1200, /* Register GPIOI0 */ + .val_bits =3D 32, + .max_register =3D 0x1214, /* Register GPIOO1 */ +}; + +static const struct regmap_config reset_clock_regmap_config =3D { + .name =3D "tc956x-clk-reset", + .reg_bits =3D 32, + .reg_stride =3D 4, + .reg_base =3D 0x1000, /* Register NCTLSTS */ + .val_bits =3D 32, + .max_register =3D 0x1010, /* Register NRSTCTRL1 */ +}; + +/* Common clock/reset register update function (also used for MACs) */ +void tc956x_reset_clock_set(const struct tc956x_chip *chip, bool reset, + bool reg0, bool set, u8 bit) +{ + u32 mask =3D BIT(bit); + u32 offset; + + if (reset) + offset =3D reg0 ? RSTCTRL0_OFFSET : RSTCTRL1_OFFSET; + else + offset =3D reg0 ? CLKCTRL0_OFFSET : CLKCTRL1_OFFSET; + + /* Note: no need to check for errors on read/write for MMIO regmap */ + (void)regmap_update_bits(chip->reset_clock_regmap, offset, mask, + set ? mask : 0); +} +EXPORT_SYMBOL_GPL(tc956x_reset_clock_set); + +static void chip_reset_assert(const struct tc956x_chip *chip, enum reset_i= d id) +{ + tc956x_reset_clock_set(chip, true, true, true, (u8)id); +} + +static void chip_reset_deassert(const struct tc956x_chip *chip, + enum reset_id id) +{ + tc956x_reset_clock_set(chip, true, true, false, (u8)id); +} + +static void chip_clock_enable(const struct tc956x_chip *chip, enum clock_i= d id) +{ + tc956x_reset_clock_set(chip, false, true, true, (u8)id); +} + +static void chip_clock_disable(const struct tc956x_chip *chip, + enum clock_id id) +{ + tc956x_reset_clock_set(chip, false, true, false, (u8)id); +} + +static void adev_release(struct device *dev) +{ + struct auxiliary_device *adev =3D to_auxiliary_dev(dev); + + of_node_put(adev->dev.of_node); + kfree(adev); +} + +static void adev_remove(void *data) +{ + struct auxiliary_device *adev =3D data; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +/* The of_node reference is always be dropped (success or not) */ +static int adev_device_add(struct device *dev, const char *name, u32 id, + struct device_node *of_node, void *platform_data) +{ + struct auxiliary_device *adev; + int ret; + + adev =3D kzalloc_obj(*adev); + if (!adev) { + of_node_put(of_node); + return -ENOMEM; + } + + adev->id =3D id; + adev->name =3D name; + adev->dev.parent =3D dev; + adev->dev.platform_data =3D platform_data; + adev->dev.release =3D adev_release; + adev->dev.of_node =3D of_node; + + ret =3D auxiliary_device_init(adev); + if (ret) { + of_node_put(of_node); + kfree(adev); + return ret; + } + + ret =3D auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, adev_remove, adev); +} + +/* Returns a reference to the GPIO's DT sub-node, or a null pointer */ +static struct device_node *dev_node_child_gpio(struct device *dev) +{ + struct device_node *np; + + /* The GPIO sub-node is not required (platform might not need it) */ + for_each_child_of_node(dev->of_node, np) + if (!strcmp(np->name, "gpio")) + break; + if (!np) + return NULL; + + /* If it's there, make sure it contains its required properties */ + if (!of_property_present(np, "gpio-controllerX")) + dev_err(dev, "gpio node contains no gpio-contrller property\n"); + else if (!of_property_present(np, "#gpio-cellsX")) + dev_err(dev, "gpio node contains no #gpio-cells property\n"); + else + return np; /* Found a GPIO sub-node */ + + /* If we reported a problem, pretend there was no gpio node */ + of_node_put(np); + + return NULL; +} + +/* The embedded GPIO controller has an auxiliary device driver */ +static int chip_gpio_adev_add(struct tc956x_chip *chip) +{ + struct device *dev =3D chip->dev; + struct device_node *np; + struct regmap *regmap; + + np =3D dev_node_child_gpio(dev); + if (!np) + return 0; + + regmap =3D devm_regmap_init_mmio(dev, chip->sfr[0], &gpio_regmap_config); + if (IS_ERR(regmap)) { + of_node_put(np); + return PTR_ERR(regmap); + } + + return adev_device_add(dev, GPIO_DEVICE_NAME, 0, np, regmap); +} + +/* The two embedded XGMAC controllers have an auxiliary device driver */ +static int function_xgmac_adev_add(struct pci_dev *pdev, + struct tc956x_chip *chip, + unsigned int msigen_irq) +{ + u8 mac_id =3D PCI_FUNC(pdev->devfn); + struct device *dev =3D &pdev->dev; + struct tc956x_dwmac_data *data; + struct device_node *np; + void __iomem *sfr; + int ret; + + if (mac_id > 1) + return -EINVAL; + + /* If there's no ethernet subnode, there's nothing to do */ + for_each_child_of_node(dev->of_node, np) + if (!strcmp(np->name, "ethernet")) + break; + if (!np) + return 0; + + data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) { + of_node_put(np); + return -ENOMEM; + } + + sfr =3D chip->sfr[mac_id]; + + data->chip =3D chip; + data->msigen =3D sfr + MSIGEN_OFFSET(mac_id); + data->msigen_irq =3D msigen_irq; + data->emac =3D sfr + DWMAC_OFFSET(mac_id); + data->emac_ctl =3D sfr + EMAC_CTL_OFFSET(mac_id); + data->rev_id =3D chip->rev_id; + data->mac_id =3D mac_id; + + ret =3D adev_device_add(dev, TC956X_XGMAC_DEV_NAME, mac_id, np, data); + if (ret) + return ret; + + return 0; +} + +static int chip_reset_clock_init(struct tc956x_chip *chip) +{ + void __iomem *base =3D chip->sfr[0]; + struct device *dev =3D chip->dev; + struct regmap *regmap; + + regmap =3D devm_regmap_init_mmio(dev, base, &reset_clock_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + chip->reset_clock_regmap =3D regmap; + + return 0; +} + +static int chip_tamap_init(struct tc956x_chip *chip, struct pci_dev *pdev) +{ + void __iomem *base; + + base =3D pcim_iomap_region(pdev, PCI_BAR_BRIDGE_CONFIG, DRIVER_NAME); + if (IS_ERR(base)) + return PTR_ERR(base); + + chip->bridge_config =3D base + ATR_AXI4_SLV0_OFFSET; + + return 0; +} + +/** + * chip_tamap_config() - Configure the table address map registers + * @chip: The TC956X chip pointer + * + * Populate the registers used to translate AXI bus accesses to PCI TLPs. + * TC956X_SLV00_SRC_ADDR defines the base address of the AXI address range. + * AXI addresses are translated to the PCIe address range, whose base addr= ess + * is defined by SLV00_TRSL_ADDR (which is 0x0). + */ +static void chip_tamap_config(struct tc956x_chip *chip) +{ + void __iomem *table_base =3D chip->bridge_config; + void __iomem *entry_base; + u32 trsl_param_val; + u32 atr_size_val; + u32 val; + u32 i; + + /* + * The lower bits of the source address must be zero, because the + * SRC_ADDR_LO register encodes the address translation space size + * and "implmented" bit there. The size field defines the size of + * the translation space (2^(ATR_SIZE + 1)). The minimum size is + * 4096 bytes, so ATR_SIZE value must be 11 or more. + */ + BUILD_BUG_ON(!!u32_get_bits(lower_32_bits(TC956X_SLV00_SRC_ADDR), + ATR_SIZE_MASK)); + BUILD_BUG_ON(TC956X_SLV00_SRC_ADDR & ATR_IMPL); + BUILD_BUG_ON(SLV00_ATR_SIZE < 11); + + /* + * We only use the first AXI4 slave TAMAC table: + * EDMA address region: 0x10 0000 0000 - 0x1f ffff ffff + * is translated to: 0x00 0000 0000 - 0x0f ffff ffff + */ + entry_base =3D table_base + AXI4_ENTRY_BASE(0); + + atr_size_val =3D u32_encode_bits(SLV00_ATR_SIZE, ATR_SIZE_MASK); + atr_size_val |=3D ATR_IMPL; + val =3D lower_32_bits(TC956X_SLV00_SRC_ADDR) | atr_size_val; + writel(val, entry_base + SRC_ADDR_LO_OFFSET); + + val =3D upper_32_bits(TC956X_SLV00_SRC_ADDR); + writel(val, entry_base + SRC_ADDR_HI_OFFSET); + + val =3D lower_32_bits(SLV00_TRSL_ADDR); + writel(val, entry_base + TRSL_ADDR_LO_OFFSET); + + val =3D upper_32_bits(SLV00_TRSL_ADDR); + writel(val, entry_base + TRSL_ADDR_HI_OFFSET); + + /* This TRSL_PARAM value is assigned for all four TAMAC tables */ + trsl_param_val =3D u32_encode_bits(TRSL_ID_PCIE_TX_RX, TRSL_ID_MASK); + + writel(trsl_param_val, entry_base + TRSL_PARAM_OFFSET); + + /* Set all other unused entries to default values (no translation) */ + for (i =3D 1; i < AXI4_TABLE_ENTRY_COUNT; i++) { + entry_base =3D table_base + AXI4_ENTRY_BASE(i); + + writel(0x0, entry_base + SRC_ADDR_LO_OFFSET); + writel(0x0, entry_base + SRC_ADDR_HI_OFFSET); + writel(0x0, entry_base + TRSL_ADDR_LO_OFFSET); + writel(0x0, entry_base + TRSL_ADDR_HI_OFFSET); + writel(trsl_param_val, entry_base + TRSL_PARAM_OFFSET); + } +} + +static void chip_msigen_enable(struct tc956x_chip *chip) +{ + chip_clock_enable(chip, CLOCK_MSIGEN); + chip_reset_deassert(chip, RESET_MSIGEN); +} + +static void chip_msigen_disable(struct tc956x_chip *chip) +{ + chip_reset_assert(chip, RESET_MSIGEN); + chip_clock_disable(chip, CLOCK_MSIGEN); +} + +static void chip_init_state(struct tc956x_chip *chip) +{ + /* The only IP block we currently use is MSIGEN */ + chip_reset_assert(chip, RESET_MCU); + chip_reset_assert(chip, RESET_MCU1); + chip_reset_assert(chip, RESET_INTC); + chip_reset_assert(chip, RESET_UART0); + chip_clock_disable(chip, CLOCK_MCU); + chip_clock_disable(chip, CLOCK_SRAM); + chip_clock_disable(chip, CLOCK_PLL); + chip_clock_disable(chip, CLOCK_SGMII); + chip_clock_disable(chip, CLOCK_REFCLKO); + chip_clock_disable(chip, CLOCK_INTC); + chip_clock_disable(chip, CLOCK_UART0); + + /* Start with MSIGEN in reset with its clock disabled */ + chip_msigen_disable(chip); +} + +static void chip_link_del(void *data) +{ + struct device_link *link =3D data; + + device_link_del(link); +} + +/* + * Function 0 will allocate the chip structure that is shared by both + * functions. Once it has allocated the structure it assigns it as + * the PCI device platform data. Function 1 can access the shared + * chip structure by looking up the function 0 device to use its + * platform data.. + * + * Returns a chip structure pointer, or a pointer-coded error. + */ +static struct tc956x_chip *chip_get(struct pci_dev *pdev) +{ + unsigned int devfn =3D pdev->devfn; + struct device *dev =3D &pdev->dev; + struct tc956x_chip *chip; + struct device_link *link; + struct pci_dev *slot0; + int ret; + + /* Function 0 just allocates the chip structure */ + if (!PCI_FUNC(devfn)) { + chip =3D devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return ERR_PTR(-ENOMEM); + + /* + * The function whose device pointer matches the chip's + * device pointer manages common resources (like MSIGEN). + */ + chip->dev =3D dev; + + return chip; + } + + /* Function 1 has to get the chip structure from function 0 */ + slot0 =3D pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(devfn), 0)); + if (!slot0) + return ERR_PTR(-ENXIO); + + /* If function 0 hasn't set up the chip yet, try again later */ + chip =3D dev_get_platdata(&slot0->dev); + if (!chip) { + ret =3D -EPROBE_DEFER; + goto err_put_slot; + } + + /* Mark function 1's device as dependent on function 0 */ + link =3D device_link_add(dev, &slot0->dev, DL_FLAG_STATELESS); + if (!link) { + ret =3D -ENODEV; + goto err_put_slot; + } + + ret =3D devm_add_action_or_reset(dev, chip_link_del, link); + if (ret) + goto err_put_slot; + + return chip; + +err_put_slot: + pci_dev_put(slot0); + + return ERR_PTR(ret); +} + +static int chip_init(struct tc956x_chip *chip, struct pci_dev *pdev) +{ + u32 id =3D PCI_FUNC(pdev->devfn) ? 1 : 0; + u32 val; + int ret; + + /* Both chips need to map their SFR region */ + chip->sfr[id] =3D pcim_iomap_region(pdev, PCI_BAR_SFR, DRIVER_NAME); + if (IS_ERR(chip->sfr[id])) + return PTR_ERR(chip->sfr[id]); + + /* Function 0 handles common initialization */ + if (id) + return 0; + + ret =3D chip_tamap_init(chip, pdev); + if (ret) + return ret; + + ret =3D chip_reset_clock_init(chip); + if (ret) + return ret; + + chip_init_state(chip); + + ret =3D chip_gpio_adev_add(chip); + if (ret) + return ret; + + /* Get the revision ID */ + val =3D readl(chip->sfr[0] + NCID_OFFSET); + chip->rev_id =3D u32_get_bits(val, NCID_REV_ID_MASK); + + chip_tamap_config(chip); + chip_msigen_enable(chip); + + return 0; +} + +static void pcim_free_irq_vectors(void *data) +{ + struct pci_dev *pdev =3D data; + + pci_free_irq_vectors(pdev); +} + +static int pcim_alloc_irq_vectors(struct pci_dev *pdev, unsigned int min_v= ecs, + unsigned int max_vecs, unsigned int flags) +{ + int ret; + + ret =3D pci_alloc_irq_vectors(pdev, min_vecs, max_vecs, flags); + if (ret) + return ret; + + return devm_add_action_or_reset(&pdev->dev, pcim_free_irq_vectors, pdev); +} + +static int +tc956x_function_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct device *dev =3D &pdev->dev; + struct tc956x_chip *chip; + unsigned int msigen_irq; + int ret; + + /* Despite being a PCI device, we require devicetree */ + if (!dev->of_node) + return dev_err_probe(dev, -EINVAL, "no devicetree node\n"); + + ret =3D pcim_enable_device(pdev); + if (ret) + return ret; + + pci_set_master(pdev); + + /* Function 1 gets -EPROBE_DEFER until function 0 sets platform data */ + chip =3D chip_get(pdev); + if (IS_ERR(chip)) + return dev_err_probe(dev, PTR_ERR(chip), "failed to get chip\n"); + + /* We called pcim_enable_device() so this will be freed automatically */ + ret =3D pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); + if (ret < 1) + return dev_err_probe(dev, ret ? : -EIO, + "failed to allocate IRQ vectors\n"); + + ret =3D pci_irq_vector(pdev, 0); + if (ret < 1) + return dev_err_probe(dev, ret ? : -EIO, "failed to get IRQ\n"); + msigen_irq =3D ret; + + ret =3D chip_init(chip, pdev); + if (ret) + return dev_err_probe(dev, ret, "failed to initialize chip\n"); + + ret =3D function_xgmac_adev_add(pdev, chip, msigen_irq); + if (ret) + return dev_err_probe(dev, ret, "failed to add xgmap device\n"); + + /* We're ready; the other function can now probe */ + dev->platform_data =3D chip; + + return 0; +} + +static void tc956x_function_remove(struct pci_dev *pdev) +{ + struct tc956x_chip *chip =3D dev_get_platdata(&pdev->dev); + + if (&pdev->dev =3D=3D chip->dev) + chip_msigen_disable(chip); + + pci_free_irq_vectors(pdev); + + pci_clear_master(pdev); +} + +static const struct pci_device_id tc956x_function_id_table[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TC956X), }, + { }, +}; +MODULE_DEVICE_TABLE(pci, tc956x_function_id_table); + +static int tc956x_chip_suspend_noirq(struct device *dev) +{ + struct tc956x_chip *chip =3D dev_get_platdata(dev); + struct pci_dev *pdev =3D to_pci_dev(dev); + + if (dev =3D=3D chip->dev) + chip_msigen_disable(chip); + + /* It seems most callers ignore the return value here */ + pci_save_state(pdev); + pci_wake_from_d3(pdev, true); + + return 0; +} + +static int tc956x_chip_resume_noirq(struct device *dev) +{ + struct tc956x_chip *chip =3D dev_get_platdata(dev); + struct pci_dev *pdev =3D to_pci_dev(dev); + + pci_wake_from_d3(pdev, false); + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + if (dev !=3D chip->dev) + return 0; + + /* Reconfigure tamap tables following suspend */ + chip_tamap_config(chip); + + chip_msigen_enable(chip); + + return 0; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(tc956x_chip_pm_ops, + tc956x_chip_suspend_noirq, + tc956x_chip_resume_noirq); + +static struct pci_driver tc956x_function_driver =3D { + .name =3D DRIVER_NAME, + .id_table =3D tc956x_function_id_table, + .probe =3D tc956x_function_probe, + .remove =3D tc956x_function_remove, + .driver =3D { + .name =3D DRIVER_NAME, + .owner =3D THIS_MODULE, + .pm =3D pm_sleep_ptr(&tc956x_chip_pm_ops), + }, +}; + +module_pci_driver(tc956x_function_driver); + +MODULE_DESCRIPTION("Toshiba TC956X PCIe Embedded Function Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/soc/toshiba/tc956x-dwmac.h b/include/soc/toshiba/tc956= x-dwmac.h new file mode 100644 index 0000000000000..5ca39cf764be9 --- /dev/null +++ b/include/soc/toshiba/tc956x-dwmac.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reser= ved. + */ + +#ifndef __TOSHIBA_TC956X_DWMAC_H__ +#define __TOSHIBA_TC956X_DWMAC_H__ + +#include +#include + +#define TC956X_PCIE_DRIVER_NAME "tc956x_pci" + +#define TC956X_XGMAC_DEV_NAME "dwmac-tc956x" + +/* Starting address of the space translated by the PCIe endpoint bridge */ +#define TC956X_SLV00_SRC_ADDR 0x0000001000000000ULL + +enum tc956x_reset_id { + MAC_RESET_MAC =3D 7, + MAC_RESET_PMA =3D 30, + MAC_RESET_XPCS =3D 31, +}; + +enum tc956x_clock_id { + MAC_CLOCK_TX =3D 7, + MAC_CLOCK_RX =3D 14, + MAC_CLOCK_ALL =3D 31, + MAC_CLOCK_125M =3D 29, + MAC_CLOCK_312_5M =3D 30, + MAC_CLOCK_RMII =3D 15, /* eMAC 1 only */ +}; + +/** + * struct tc956x_dwmac_data - Structure passed to stmmac auxiliary devices. + * @chip: Context pointer needed for reset and clock operations + * @emac: I/O mapped address used by eMAC + * @emac_ctl: I/O mapped address used for eMAC control + * @msigen: I/O mapped address used by MSIGEN + * @msigen_irq: IRQ number used by MSIGEN + * @rev_id: Chip revision ID (for quirks) + * @mac_id: Unique device ID (0 or 1) + * + * This structure is passed via platform data to the stmmac auxiliary devi= ces. + */ +struct tc956x_dwmac_data { + const struct tc956x_chip *chip; + void __iomem *emac; + void __iomem *emac_ctl; + void __iomem *msigen; + unsigned int msigen_irq; + u8 rev_id; + u8 mac_id; +}; + +extern void tc956x_reset_clock_set(const struct tc956x_chip *chip, bool re= set, + bool reg0, bool set, u8 bit); + +static inline void tc956x_reset_assert(const struct tc956x_chip *chip, + u8 mac_id, enum tc956x_reset_id id) +{ + tc956x_reset_clock_set(chip, true, !mac_id, true, (u8)id); +} + +static inline void tc956x_reset_deassert(const struct tc956x_chip *chip, + u8 mac_id, enum tc956x_reset_id id) +{ + tc956x_reset_clock_set(chip, true, !mac_id, false, (u8)id); +} + +static inline void tc956x_clock_enable(const struct tc956x_chip *chip, + u8 mac_id, enum tc956x_clock_id id) +{ + tc956x_reset_clock_set(chip, false, !mac_id, true, (u8)id); +} + +static inline void tc956x_clock_disable(const struct tc956x_chip *chip, + u8 mac_id, enum tc956x_clock_id id) +{ + tc956x_reset_clock_set(chip, false, !mac_id, false, (u8)id); +} + +#endif /* __TOSHIBA_TC956X_DWMAC_H__*/ --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 DEAC6296BCC for ; Fri, 5 Jun 2026 01:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621295; cv=none; b=WFvmdbXIVA7i8mLkRubp2HrDoiOnh5ZlwPKTuncdECRXqpmGcxx/wOr3H/slW8NkEk5gXuuiDQPBY8jAOSTN9v+sV8g4FVLq1O0afNyv0QLUVGKLq7VHzykX9yG/1+jQktyt3tFymRyx2eKn2yDwtsVBKEdMfU23f0+xx8iiANw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621295; c=relaxed/simple; bh=DskkOmkT3L3PshxePtNyn75KTWZeOUxtFBYOtovIgZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HQjiQ+Y9Su+JglEDbRC1ErG8FZECCcpqYFtf5y5rrzXLZRkTrltLdj7M/mue18LqxnGAF4mENBSXZRVnOP7gwZO0/IKotkBjbnMhnHraA1nL/a6ClyxOCCKqorORDYD4BgP9hBQuAuwZCtycSui59Kh/TJsX2emCm233Z5/DZZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=tdp+lbVN; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="tdp+lbVN" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-485ecc0f2dfso1164336b6e.3 for ; Thu, 04 Jun 2026 18:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621266; x=1781226066; 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=eQ5vHkiQeOYKz2ok7U7StyNKqN17UnhE019AHLlCqDQ=; b=tdp+lbVNF8ki1pq4WXdgeVYFONHKZ8XjWjtU1CQBWEmnSIQiV4MUciu/1FTYpH/Lb7 +i56foS6npV0V/gGtOTOiZeA7bl34JMQswqsKg+aU3g7chKTlm408W3miBee40Ijl6kF UDkDuK8Jn/KQgaL58zhaAuee+LGchClnfCFPQaTTEzBiGC7XvN3K9769Z6CvyKTAF1tG aeFdEBwCA/PQ3DV2UmSpbKJ+70gpwf42pGBPEndP2ZhNop+qd4I8HpXZsxEvZRQ+9/+0 nUJLcxuSwC8JvcjlqhJCDg+0mKAhNuydz2l0IeHhgdNXeEouRZlC3T1SxixAz8Q58351 asTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621266; x=1781226066; 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=eQ5vHkiQeOYKz2ok7U7StyNKqN17UnhE019AHLlCqDQ=; b=VOj36PeThLFnq6Hj0lDsnj80pRI+b5++grqZt54E8uWCzpuok1sdICboyrYpRgQ9zG uX/DQRVNguTseSV9OrE8CL4XFTBFnloJq1s9a0Z2OSRltbU28LLgfp8zGrwL2uhNgk48 yuuqPpo/xJ6J9UYDMCTebIt8bc1TJ2ry9QQJ/O74DQMuo9m1Qxwx0PPKwfCtJKV1SFa+ 9LodSOB8pUIiNSL1EGZNnd52q4IKCU9wp9swfm6O4btg0qs3JcZ6V/FayOPSJaCD4T42 5J6VgcCM1y46K3U6Y+ASFiKtBHNP3IsbyVlikseXHuUItc83LycVoQM8T854BqDIK8V1 JFNQ== X-Forwarded-Encrypted: i=1; AFNElJ+aXHvV2BBvGIzD2Q64gsu7Ozl5HeBRh5rNxTvsBbSnS08wNBeVNSE30tDHqJEt3woUu5OSmGt0Z2W+v4A=@vger.kernel.org X-Gm-Message-State: AOJu0YwWD215bqM7weKco0IMkbGug9EA6gJ5MiDCjoVbyea0+2398Wv9 ymeTSAyB5ovJaiE4nd96N4Exkd87HZhHzwDTmdHOKkGugkkMwM2C2G+Dm5H7qoajxcM= X-Gm-Gg: Acq92OGGk/3aoGgk7tn3IfBRmKUYz1SHTsI/LJe8MZWuQaiO82soMhHeAQUVmTnklsr Df2e3QIPX2Dyv9FwAdjC/rTarpNeLJIBW4C7ZfjTrLTgaK+SCnzXq72nTwM+8Reeb8yuWFJ11lV 2nuXaEkKdry3VVKf9ji1x0wqjzWxIxvnBwtHhDFIzYU7YFym9XAkgolSY8F2LlIB8sdee6Oz7m3 DIbtUG6TlWfGswwB44/NOmWWcHi2PD0JWgh/9+u0MmwCoudtjqCSZA5TQR1N6e187Daqf59v2kM mXNIP/SM5pWjRETCdvzDE5hZQ2DnDLD3wCCD4uwTZPPK9unQzxo3XhRga0uzvemIYppyYCoZyPC 6KLWJF+cIOm+ohQM7cC0LusuPyHyFwOASHxzyQBmIlm6CJygsmfQq3/8PuLYkuYuCq6FLHdvR+B kTwgjZKrWhDvBsDduoS6KRDfsoGqJkOk5hlsAb/Q== X-Received: by 2002:a05:6808:c227:b0:485:4443:dbed with SMTP id 5614622812f47-4868dbf7a46mr899700b6e.8.1780621265613; Thu, 04 Jun 2026 18:01:05 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:01:05 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: daniel@riscstar.com, elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support Date: Thu, 4 Jun 2026 20:00:19 -0500 Message-ID: <20260605010022.968612-13-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver. This driver is implemented using the generic regmap-based GPIO driver. Co-developed-by: Daniel Thompson Signed-off-by: Daniel Thompson Signed-off-by: Alex Elder --- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/gpio/gpio-tc956x.c diff --git a/MAINTAINERS b/MAINTAINERS index 0924f7ec43cb0..0439607d1155f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27057,6 +27057,7 @@ M: Alex Elder M: Daniel Thompson S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c =20 TOSHIBA WMI HOTKEYS DRIVER diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 020e51e30317a..36631ca722fa3 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -743,6 +743,18 @@ config GPIO_TB10X select GPIO_GENERIC select GENERIC_IRQ_CHIP =20 +config GPIO_TC956X + tristate "Toshiba TC956X GPIO support" + depends on TOSHIBA_TC956X_PCI + select GPIO_REGMAP + default m + help + This enables support for the GPIO controller embedded in the Toshiba + TC956X (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. On some platforms, a few of the GPIO lines are used to + manage external resets. + config GPIO_TEGRA tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRA diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index b267598b517de..c3584e7cba9b4 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -178,6 +178,7 @@ obj-$(CONFIG_GPIO_SYSCON) +=3D gpio-syscon.o obj-$(CONFIG_GPIO_TANGIER) +=3D gpio-tangier.o obj-$(CONFIG_GPIO_TB10X) +=3D gpio-tb10x.o obj-$(CONFIG_GPIO_TC3589X) +=3D gpio-tc3589x.o +obj-$(CONFIG_GPIO_TC956X) +=3D gpio-tc956x.o obj-$(CONFIG_GPIO_TEGRA186) +=3D gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) +=3D gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) +=3D gpio-thunderx.o diff --git a/drivers/gpio/gpio-tc956x.c b/drivers/gpio/gpio-tc956x.c new file mode 100644 index 0000000000000..0dc6b1028d970 --- /dev/null +++ b/drivers/gpio/gpio-tc956x.c @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reser= ved. + */ + +/* + * The Toshiba TC956X implements a PCIe Gen 3 switch that connects an + * upstream x4 port to two downstream PCIe x2 ports. It incorporates + * an internal endpoint on a internal PCIe port that implements two + * Synopsys XGMAC Ethernet interfaces. + * + * 35 GPIOs are also implemented by an embedded GPIO controller. Three + * registers control the first 32 GPIOs (other than 20 and 21, which are + * reserved). Three other registers control GPIOs 32 through 36. GPIOs + * 22-24, 27-28, 31, and 34 are treated as "input only". + * + * There is a TC956X PCI power controller driver that accesses the + * direction and output value registers for GPIOs 2 and 3. These + * GPIOs control the reset signal for the two downstream PCIe ports. + * Their values will never change during operation of this driver, and + * this driver reserves these two GPIOS. + */ + +#include +#include +#include +#include +#include + +#define DRIVER_NAME "tc956x-gpio" + +#define TC956X_GPIO_COUNT 37 /* Number of GPIOs (20-21 reserved) */ + +/* The GPIO offsets are relative to 0x1200 in TC956X SFR space. */ +#define GPIO_IN0_OFFSET 0x00 /* Input value (0-31) */ +#define GPIO_EN0_OFFSET 0x08 /* 0: out; 1: in (0-31) */ +#define GPIO_OUT0_OFFSET 0x10 /* Output value (0-31) */ + +/* + * There are two sets of registers, each representing (up to) 32 GPIOs wit= h a + * stride of 4 bytes (IN1 is 4 bytes past IN0, EN1 is 4 bytes past EN0, et= c.). + */ +#define GPIO_PER_REG 32 +#define GPIO_REG_STRIDE 4 + +static int tc956x_gpio_init_valid_mask(struct gpio_chip *gc, + unsigned long *valid_mask, + unsigned int ngpios) +{ + /* + * GPIOs 2 and 3 are used by the PCI power control driver, and + * we don't allow them to be used. GPIOs 20 and 21 are reserved + * (and not usable). + */ + bitmap_fill(valid_mask, ngpios); + bitmap_clear(valid_mask, 2, 2); + bitmap_clear(valid_mask, 20, 2); + + return 0; +} + +static int tc956x_gpio_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + DECLARE_BITMAP(zeroes, TC956X_GPIO_COUNT); + DECLARE_BITMAP(fixed, TC956X_GPIO_COUNT); + struct gpio_regmap_config config =3D { }; + struct gpio_regmap *gpio_regmap; + struct device *dev =3D &adev->dev; + + /* We need the regmap pointer, stored in our platform data */ + if (!dev->platform_data) + return -EINVAL; + + /* + * Only some of our GPIOs are fixed direction: + * 22, 23, 24, 27, 28, 31, and 34 (all input-only) + * Set up the fixed bitmap to indicate which are fixed. + */ + bitmap_zero(fixed, TC956X_GPIO_COUNT); + bitmap_set(fixed, 22, 3); + bitmap_set(fixed, 27, 2); + set_bit(31, fixed); + set_bit(34, fixed); + + /* All fixed GPIOs are input; the zeroes bitmap indicates that. */ + bitmap_zero(zeroes, TC956X_GPIO_COUNT); + + config.parent =3D dev; + config.regmap =3D dev->platform_data; + config.label =3D DRIVER_NAME; + config.ngpio =3D TC956X_GPIO_COUNT; + config.reg_dat_base =3D GPIO_REGMAP_ADDR(GPIO_IN0_OFFSET); + config.reg_set_base =3D GPIO_REGMAP_ADDR(GPIO_OUT0_OFFSET); + config.reg_dir_in_base =3D GPIO_REGMAP_ADDR(GPIO_EN0_OFFSET); + config.reg_stride =3D GPIO_REG_STRIDE; + config.ngpio_per_reg =3D GPIO_PER_REG; + config.init_valid_mask =3D tc956x_gpio_init_valid_mask; + config.fixed_direction_mask =3D fixed; + config.fixed_direction_output =3D zeroes; + + gpio_regmap =3D devm_gpio_regmap_register(dev, &config); + if (IS_ERR(gpio_regmap)) + return PTR_ERR(gpio_regmap); + + return 0; +} + +static const struct auxiliary_device_id tc956x_gpio_ids[] =3D { + { .name =3D "tc956x_pci.tc9564-gpio", }, + { } +}; +MODULE_DEVICE_TABLE(auxiliary, tc956x_gpio_ids); + +static struct auxiliary_driver tc956x_gpio_driver =3D { + .name =3D DRIVER_NAME, + .probe =3D tc956x_gpio_probe, + .id_table =3D tc956x_gpio_ids, + .driver =3D { + .name =3D DRIVER_NAME, + .owner =3D THIS_MODULE, + .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, + }, +}; +module_auxiliary_driver(tc956x_gpio_driver); + +MODULE_DESCRIPTION("Toshiba TC956X PCIe GPIO Driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("auxiliary:" DRIVER_NAME); --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 39A5437AA78 for ; Fri, 5 Jun 2026 01:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621303; cv=none; b=dbAGzb1xECV/dS26+L91yMaG+ALZaFPd3k3DuXd6SwZoAtfx1n20fkl1NJUxccTcl7a8qMrpKGSc/7b7KDZyf6a9ObD6nzu0frJI9YzjkXdeworhE0g5sAT8yhdfjZ4eRIOVccYIzGi5XCHpkyKtrQkNEuqNiFbGKJriaM7XPK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621303; c=relaxed/simple; bh=DPw2zZiO9iGEXWEdt08zYtM9x6AxYhElR7FfY0H9Q/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIEcAfSBz7oxsL5XcxUgyOKjyzDFHJREa50SFW1N2VeOwVCHKIUWEFuop7s+83HsBFXSA+mKdbgH8XWzYXZ2f7W/Zv/7hdJNaxnYCtXn7sDwCj5pAIthDrN67yvQOzLtTFbemPeQXKozTYFfAIE61uYgL0nQP0PsUlu7W4dSb4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=i0iU3DW4; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="i0iU3DW4" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-48677c167b7so661210b6e.1 for ; Thu, 04 Jun 2026 18:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621269; x=1781226069; 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=keRrUcWeaqsNKhpvJvQPT0J0ua19qEmtTXZDFb0cKTU=; b=i0iU3DW4np9a9NL2ijcxv5Zjf7DCl8Q04VhIo2AHCeTlWvNnEgo+nB8mI0tTWJ0Vpx M5YuHHhdSMqxpG7K6p+p+yYGByo0kn9+c9Gm24WUY0NcQalwpi+xoytY6yEf1C9wAzWr EzADYcJu43pYcdsHDrnEWB5XDB6KSQm+lA0S365gHtxgXJuZKj8bZi/Mgm34onY2ox5w aqDlBwtjRwn3vPRv+af0o4tzTxO9j7Chbtx/Sm+ehUqfF4MhZ/3CnsX6iXy2A9HSYAA6 oxz/lKQqbICk6+aVShmEQplEp1Wu83dbCLudSa7IgZWuPmc5vib9l3MdCdGir9AsJWBm aUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621269; x=1781226069; 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=keRrUcWeaqsNKhpvJvQPT0J0ua19qEmtTXZDFb0cKTU=; b=gEyPKlCMNIlyDe2/kDxTGKTlH2HZPdNjpB08OYXDheXQLB3QIOhndFtyc84mCQrnaJ APZLzZhkKDuoyR4QOWSTynaZMvgJsY6tsJIqsUIk7VX4XuAnM9O9UbynU755BH0eTC2p Plkfl3PUzHTUjw7i8h8SKtaDyEE1ME0hLuHvwWMdpxMJZxvETqfioeARrVjwI4S9C5yS +HVmSTP3cjYqvJp58x/d+kmMw5nPrlNvPfRClY/dRfhVmhpQm2lWouGl4r4CzC6KWiLz UCazlSvnF/LzzDhPOCuH2X1dY5ghXti0Ckd9ETF6lgmhohWMc4E3YkMJkhCBh60ewEV2 ZLwQ== X-Forwarded-Encrypted: i=1; AFNElJ/Pq7q4hR+Wasp8wMAoBkWXOOYiZc8MxdVmZ1t79Te5jmyNnYFXiTZZ5E5g0d8sI6wqAY/5iNXMx0Qq3vY=@vger.kernel.org X-Gm-Message-State: AOJu0YxqujxvDHV4gZXMx5ZB0o3I7D/5eZPsWH69GOBOYUOSDIjez/YM mGoW21eCgTKAsmN+LZmH/4ZNU/zGROlfTAD78TkIqDnBrtQ1NZLWdg7bxWiz0sPwv08= X-Gm-Gg: Acq92OGs5D4hUZnnORuIK42ato8bXcDpINRXzBHWXjnjB2lARMINPZopLx8TaAd/TXY NTdJHHuDNKmYNvQwMTVx83hdPYv/5lhKyihGGUwqi1FhMSLxa46EG1gyHq5oMEbZK1mtYXeho7j sTQ36SxvBLozy29+WeRKR0V/VVHM+/jGcvNG65JWu1MWwoHoZbsCKuwHG7X9vpzequXttQoi4Ta u1ew1A2wrViimYFMa8tkZ5nTsgqki+MtLA5efk6w47V9QgaUxVqV44SSvCCf719/cvF/cPs5/Ch sdwwL7RRFhfHeLcuEjyXnmKxCnd8OhgL+0qv13hgJzlQ3J3mGK8hxoOviWxEP8qRq1Yx17EVy/5 xYUky+7C3Bn3roaN8956fPJExR0qa6LEETQ1TLC4aiFYrcm27uEuAaggy/rLFXwD/ZwD50nhytG FN3wkXfVdZ2VRVfkpS8tgV+SCMurLFDmJuyXpb3m667ql3Qupd X-Received: by 2002:a05:6808:1310:b0:467:1941:1f0d with SMTP id 5614622812f47-4868dc8f006mr912741b6e.11.1780621268713; Thu, 04 Jun 2026 18:01:08 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:01:08 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support Date: Thu, 4 Jun 2026 20:00:20 -0500 Message-ID: <20260605010022.968612-14-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC. The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs. Add a driver for the eMAC/MSIGEN combination. Co-developed-by: Alex Elder Signed-off-by: Alex Elder Signed-off-by: Daniel Thompson --- MAINTAINERS | 2 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ 4 files changed, 836 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c diff --git a/MAINTAINERS b/MAINTAINERS index 0439607d1155f..418537cbefbbb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27059,6 +27059,8 @@ S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c +F: drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c +F: include/soc/toshiba/tc956x-dwmac.h =20 TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethe= rnet/stmicro/stmmac/Kconfig index e3dd5adda5aca..8d247e033e356 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -404,6 +404,20 @@ config DWMAC_MOTORCOMM This enables glue driver for Motorcomm DWMAC-based PCI Ethernet controllers. Currently only YT6801 is supported. =20 +config DWMAC_TC956X + tristate "Toshiba TC956X DWMAC support" + depends on PCI + depends on COMMON_CLK + depends on TOSHIBA_TC956X_PCI + default TOSHIBA_TC956X_PCI + select GENERIC_IRQ_CHIP + help + This selects the Toshiba TC956X (and Qualcomm QPS615) support in the + stmmac driver. + + This provides support for the ethernet controllers found on these + devices. + config STMMAC_PCI tristate "STMMAC PCI bus support" depends on PCI diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/eth= ernet/stmicro/stmmac/Makefile index a1cea2f57252e..e8e7f95dbe3e8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -51,4 +51,6 @@ obj-$(CONFIG_STMMAC_PCI) +=3D stmmac-pci.o obj-$(CONFIG_DWMAC_INTEL) +=3D dwmac-intel.o obj-$(CONFIG_DWMAC_LOONGSON) +=3D dwmac-loongson.o obj-$(CONFIG_DWMAC_MOTORCOMM) +=3D dwmac-motorcomm.o +obj-$(CONFIG_TC956X_PCI) +=3D tc956x-pci.o +obj-$(CONFIG_DWMAC_TC956X) +=3D dwmac-tc956x.o stmmac-pci-objs:=3D stmmac_pci.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c b/drivers/n= et/ethernet/stmicro/stmmac/dwmac-tc956x.c new file mode 100644 index 0000000000000..c77585e4a50e6 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c @@ -0,0 +1,818 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reser= ved. + * + * Derived from code having the following copyrights: + * Copyright (C) 2011-2012 Vayavya Labs Pvt Ltd + * Copyright (C) 2025 Toshiba Electronic Devices & Storage Corporation + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "common.h" +#include "dwxgmac2.h" +#include "stmmac.h" + +#define DRIVER_NAME "dwmac-tc956x" + +#define TC956X_PTP_CLOCK_RATE (250 * HZ_PER_MHZ) + +#define TC956X_RX_FIFO_KB 46 /* Shared by all RX queues */ +#define TC956X_TX_FIFO_KB 46 /* Shared by all TX queues */ + +/* Fields and values for the EMACTL registers */ +#define EMAC_SP_SEL_MASK GENMASK(3, 0) +#define SP_SEL_2500BASEX 4 +#define SP_SEL_SGMII_1000M 5 +#define SP_SEL_SGMII_100M 6 +#define SP_SEL_SGMII_10M 7 +#define EMAC_PHY_INF_SEL_MASK GENMASK(5, 4) +#define PCS_CLK_PHY 1 /* Clock from PHY */ +#define EMAC_INV_SGM_SIG_DET BIT(6) /* 1 =3D polarity inverted */ +#define EMAC_LPIHWCLKEN BIT(8) /* 1 =3D low power mode */ +#define EMAC_INIT_DONE BIT(21) + +/* MSIGEN Registers */ +#define MSI_OUT_EN_OFFSET 0x0000 +#define MSI_MASK_CLR_OFFSET 0x000c +#define MSI_MASK_VALUE BIT(0) +#define MSI_INT_STS_OFFSET 0x0010 + +enum msigen_hwirq { + HWIRQ_LPI =3D 0, + HWIRQ_PMT =3D 1, + HWIRQ_EVENT =3D 2, + HWIRQ_TX0 =3D 3, + HWIRQ_RX0 =3D 11, + HWIRQ_XPCS =3D 19, + HWIRQ_PHY =3D 20, + HWIRQ_PFMAILBOX =3D 21, + HWIRQ_MSIREQ_PLS =3D 24 +}; + +#define HWIRQ_COUNT 25 + +/* Offset to the XPCS memory block, relative to the EMAC address range */ +#define DWMAC_XPCS_OFFSET 0x3a00 + +/* Offset to the PMATOP memory block, relative to the EMAC address range */ +#define DWMAC_PMATOP_OFFSET 0x4000 + +#define PMA_CML_GL_PM_CFG0 0x01b8 + +/* + * Five sets three registers must be configured for PMA. The HWT_REFCLK + * registers are each separated by 0x14 bytes. The Common0 configuration + * registers are separated by 0x8 bytes. + */ +#define PMA_REG_COUNT 5 + +#define PMA_HWT_REFCK_R_EN 0x1080 +#define PMA_HWT_REFCK_TERM_EN 0x1090 +#define PMA_HWT_REFCK_STRIDE 0x0014 + +#define PMA_COMM_CFG_0_1 0x1888 +#define PMA_COMM_CFG_0_1_STRIDE 0x0008 + +/* PMA_COMM_CFG_0_1 fields (WRITE_MASK is a field name) */ +#define COMM_CFG_WRITE_MASK_MASK GENMASK(16, 9) +#define WRITE_MASK_VALUE 0xf7 /* Power-on value */ +#define COMM_CFG_ENABLE BIT(8) +#define COMM_CFG_WRITE_DATA_MASK GENMASK(7, 0) +#define WRITE_DATA_VALUE 0x04 /* Power-on value */ + +/** + * struct tc956x_data - Toshiba-specific platform data + * @dev: Device pointer + * @irq_domain: MSIGEN IRQ domain + * @auxbus_data: Pointer to data passed from the parent device + * @plat: Pointer to our stmmac platform data + * @dma_cfg: DMA config buffer used by plat_stmmacenet_data + * @mdio_bus_data: MDIO bus data used by plat_stmmacenet_data + * @axi: AXI data used by plat_stmmacenet_data + * @res: Structure passed to stmmac_dvr_probe() + * @desc: DMA descriptor data used by mac_device_info + * @dma: DMA operations data used by mac_device_info + */ +struct tc956x_data { + struct device *dev; + struct irq_domain *irq_domain; + struct tc956x_dwmac_data *auxbus_data; + struct plat_stmmacenet_data *plat; + + /* These three fields are used by the plat_stmmacenet_data structure */ + struct stmmac_dma_cfg dma_cfg; + struct stmmac_mdio_bus_data mdio_bus_data; + struct stmmac_axi axi; + + /* This field is data passed to stmmac_dvr_probe() */ + struct stmmac_resources res; + + /* These two fields are used by the mac_device_info structure */ + struct stmmac_desc_ops desc; + struct stmmac_dma_ops dma; +}; + +struct tc956x_mac_speed { + phy_interface_t phy_interface; + int speed; + u32 sp_sel; +}; + +static struct tc956x_mac_speed mac_speed[] =3D { + { PHY_INTERFACE_MODE_2500BASEX, SPEED_2500, SP_SEL_2500BASEX }, + { PHY_INTERFACE_MODE_SGMII, SPEED_1000, SP_SEL_SGMII_1000M }, + { PHY_INTERFACE_MODE_SGMII, SPEED_100, SP_SEL_SGMII_100M }, + { PHY_INTERFACE_MODE_SGMII, SPEED_10, SP_SEL_SGMII_10M }, +}; + +/* TC956x uses indirect addressing so this need only describe a 1KiB range= */ +static const struct regmap_config xpcs_regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_base =3D 0x00, /* Minimum XPCS reg offset */ + .max_register =3D 0xff, /* Register DW_VR_CSR_VIEWPORT */ + .reg_shift =3D REGMAP_UPSHIFT(2), +}; + +static void tc956x_msigen_irq_handler(struct irq_desc *desc) +{ + struct irq_domain *irq_domain =3D irq_desc_get_handler_data(desc); + struct irq_chip *chip =3D irq_desc_get_chip(desc); + struct irq_chip_generic *gc; + unsigned long status; + unsigned int hwirq; + + gc =3D irq_get_domain_generic_chip(irq_domain, 0); + + chained_irq_enter(chip, desc); + + status =3D irq_reg_readl(gc, MSI_INT_STS_OFFSET); + for_each_set_bit(hwirq, &status, HWIRQ_COUNT) + generic_handle_domain_irq(irq_domain, hwirq); + + /* + * Clear the MSI flag. Most interrupts within TC956X are level-high + * type. If any interrupts are still asserted then clearing this flag + * will cause the (edge-triggered) MSI to be regenerated. + */ + irq_reg_writel(gc, MSI_MASK_VALUE, MSI_MASK_CLR_OFFSET); + + chained_irq_exit(chip, desc); +} + +static int tc956x_msigen_irq_chip_init(struct irq_chip_generic *gc) +{ + struct tc956x_data *td =3D gc->domain->host_data; + + gc->reg_base =3D td->auxbus_data->msigen; + gc->chip_types[0].regs.mask =3D MSI_OUT_EN_OFFSET; + gc->chip_types[0].chip.irq_mask =3D irq_gc_mask_clr_bit; + gc->chip_types[0].chip.irq_unmask =3D irq_gc_mask_set_bit; + + /* Disable all interrupts */ + irq_reg_writel(gc, 0, MSI_OUT_EN_OFFSET); + + return 0; +} + +static void tc956x_msigen_irq_chip_exit(struct irq_chip_generic *gc) +{ + irq_reg_writel(gc, 0, MSI_OUT_EN_OFFSET); +} + +static int tc956x_msigen_irq_domain_init(struct irq_domain *irq_domain) +{ + struct tc956x_data *td =3D irq_domain->host_data; + + irq_set_chained_handler_and_data(td->auxbus_data->msigen_irq, + tc956x_msigen_irq_handler, + irq_domain); + + return 0; +} + +static void tc956x_msigen_irq_domain_exit(struct irq_domain *irq_domain) +{ + struct tc956x_data *td =3D irq_domain->host_data; + + irq_set_chained_handler_and_data(td->auxbus_data->msigen_irq, + NULL, NULL); +} + +/* We have one IRQ chip instance with 25 IRQs in its domain */ +static struct irq_domain * +tc956x_msigen_irq_domain_instantiate(struct tc956x_data *td) +{ + struct irq_domain_chip_generic_info dgc_info; + struct irq_domain_info info; + + dgc_info.name =3D devm_kasprintf(td->dev, GFP_KERNEL, "tc956x-msigen-%d", + td->auxbus_data->mac_id); + if (!dgc_info.name) + return ERR_PTR(-ENOMEM); + + dgc_info.handler =3D handle_level_irq; + dgc_info.irqs_per_chip =3D HWIRQ_COUNT; + dgc_info.num_ct =3D 1; + dgc_info.init =3D tc956x_msigen_irq_chip_init; + dgc_info.exit =3D tc956x_msigen_irq_chip_exit; + + info.domain_flags =3D IRQ_DOMAIN_FLAG_DESTROY_GC; + info.size =3D HWIRQ_COUNT; + info.hwirq_max =3D HWIRQ_COUNT; + info.ops =3D &irq_generic_chip_ops; + info.host_data =3D td; + info.dgc_info =3D &dgc_info; + info.init =3D tc956x_msigen_irq_domain_init; + info.exit =3D tc956x_msigen_irq_domain_exit; + + return devm_irq_domain_instantiate(td->dev, &info); +} + +/** + * tc956x_pma_init() - Initialize PMA + * @td: bsp_priv pointer + * + * Initialize (or re-initialize) the PMA, configure the clocks and wait fo= r the + * eMAC to be ready. + */ +static void tc956x_pma_init(struct tc956x_data *td) +{ + const struct tc956x_chip *chip =3D td->auxbus_data->chip; + void __iomem *emac_ctl =3D td->auxbus_data->emac_ctl; + u32 id =3D td->auxbus_data->mac_id; + void __iomem *pmatop; + u32 val; + u32 i; + + /* + * When we re-initialize the PMA then the reset will already have + * been deasserted. We must make sure the PMA reset is asserted + * before we change the clock settings. + */ + tc956x_reset_assert(chip, id, MAC_RESET_PMA); + + pmatop =3D td->auxbus_data->emac + DWMAC_PMATOP_OFFSET; + + /* Power on CML buffer (0 =3D normal mode, 1 =3D power down) */ + writel(0, pmatop + PMA_CML_GL_PM_CFG0); + + /* This value switches clock from C0_REFCK to CLK_REF_I */ + val =3D u32_encode_bits(WRITE_MASK_VALUE, COMM_CFG_WRITE_MASK_MASK); + val |=3D COMM_CFG_ENABLE; + val |=3D u32_encode_bits(WRITE_DATA_VALUE, COMM_CFG_WRITE_DATA_MASK); + + for (i =3D 0; i < PMA_REG_COUNT; i++) { + u32 offset =3D i * PMA_HWT_REFCK_STRIDE; + + /* Disable C0_REFCK and 100 ohm termination */ + writel(0, pmatop + PMA_HWT_REFCK_R_EN + offset); + writel(0, pmatop + PMA_HWT_REFCK_TERM_EN + offset); + + /* Switch clock from C0_REFCK to CLK_REF_I */ + offset =3D i * PMA_COMM_CFG_0_1_STRIDE; + writel(val, pmatop + PMA_COMM_CFG_0_1 + offset); + } + + tc956x_reset_deassert(chip, id, MAC_RESET_PMA); + + WARN_ON(readl_poll_timeout(emac_ctl, val, val & EMAC_INIT_DONE, + 50, 1000000)); +} + +static int tc956x_mac_speed_select(struct tc956x_data *td, + phy_interface_t interface, int speed) +{ + struct net_device *netdev; + int i; + + for (i =3D 0; i < ARRAY_SIZE(mac_speed); i++) { + if (mac_speed[i].speed && mac_speed[i].speed !=3D speed) + continue; + + if (mac_speed[i].phy_interface =3D=3D interface) + return mac_speed[i].sp_sel; + } + netdev =3D dev_get_drvdata(td->dev); + netdev_err(netdev, "%s/%d unsupported\n", + phy_modes(interface), speed); + + return -EOPNOTSUPP; +} + +static int tc956x_mac_configure(struct tc956x_data *td, + phy_interface_t interface, int speed) +{ + void __iomem *emac_ctl =3D td->auxbus_data->emac_ctl; + int sp_sel; + u32 val; + + sp_sel =3D tc956x_mac_speed_select(td, interface, speed); + if (sp_sel < 0) + return sp_sel; + + val =3D readl(emac_ctl); + val |=3D EMAC_LPIHWCLKEN; + val &=3D ~EMAC_INV_SGM_SIG_DET; + val =3D u32_replace_bits(val, PCS_CLK_PHY, EMAC_PHY_INF_SEL_MASK); + val =3D u32_replace_bits(val, sp_sel, EMAC_SP_SEL_MASK); + writel(val, emac_ctl); + + return 0; +} + +static void tc956x_mac_enable(struct tc956x_data *td) +{ + const struct tc956x_chip *chip =3D td->auxbus_data->chip; + u32 id =3D td->auxbus_data->mac_id; + + tc956x_clock_enable(chip, id, MAC_CLOCK_TX); + tc956x_clock_enable(chip, id, MAC_CLOCK_RX); + tc956x_clock_enable(chip, id, MAC_CLOCK_ALL); + if (id) + tc956x_clock_enable(chip, id, MAC_CLOCK_RMII); + + tc956x_reset_deassert(chip, id, MAC_RESET_MAC); + tc956x_pma_init(td); + tc956x_reset_deassert(chip, id, MAC_RESET_XPCS); +} + +static void tc956x_mac_disable(struct tc956x_data *td) +{ + const struct tc956x_chip *chip =3D td->auxbus_data->chip; + u32 id =3D td->auxbus_data->mac_id; + + tc956x_reset_assert(chip, id, MAC_RESET_MAC); + tc956x_reset_assert(chip, id, MAC_RESET_PMA); + tc956x_reset_assert(chip, id, MAC_RESET_XPCS); + + tc956x_clock_disable(chip, id, MAC_CLOCK_ALL); + tc956x_clock_disable(chip, id, MAC_CLOCK_RX); + tc956x_clock_disable(chip, id, MAC_CLOCK_TX); + if (id) + tc956x_clock_disable(chip, id, MAC_CLOCK_RMII); +} + +static void tc956x_mac_init_state(struct tc956x_data *td) +{ + const struct tc956x_chip *chip =3D td->auxbus_data->chip; + u32 id =3D td->auxbus_data->mac_id; + + tc956x_clock_disable(chip, id, MAC_CLOCK_125M); + tc956x_clock_disable(chip, id, MAC_CLOCK_312_5M); + + tc956x_mac_disable(td); +} + +/* + * Override method for dwxgmac301_dma_ops->init_rx_chan + * + * This differs from the dwxgmac301_dma_ops->init_rx_chan by translating t= he DMA + * address for TC956x internal bus. The window that provides DMA access to= PCI + * is linearly mapped at 0x10_0000_0000. + */ +static void tc956x_dma_init_rx_chan(struct stmmac_priv *priv, + void __iomem *ioaddr, + struct stmmac_dma_cfg *dma_cfg, + dma_addr_t phy, u32 chan) +{ + u64 translated =3D phy + TC956X_SLV00_SRC_ADDR; + + dwxgmac2_dma_init_rx_chan(priv, ioaddr, dma_cfg, phy, chan); + + writel(upper_32_bits(translated), + ioaddr + XGMAC_DMA_CH_RxDESC_HADDR(chan)); + writel(lower_32_bits(translated), + ioaddr + XGMAC_DMA_CH_RxDESC_LADDR(chan)); +} + +/* Override method for dwxgmac301_dma_ops->init_tx_chan */ +static void tc956x_dma_init_tx_chan(struct stmmac_priv *priv, + void __iomem *ioaddr, + struct stmmac_dma_cfg *dma_cfg, + dma_addr_t phy, u32 chan) +{ + u64 translated =3D phy + TC956X_SLV00_SRC_ADDR; + + dwxgmac2_dma_init_tx_chan(priv, ioaddr, dma_cfg, phy, chan); + + writel(upper_32_bits(translated), + ioaddr + XGMAC_DMA_CH_TxDESC_HADDR(chan)); + writel(lower_32_bits(translated), + ioaddr + XGMAC_DMA_CH_TxDESC_LADDR(chan)); +} + +/* Override method for dwxgmac210_desc_ops->set_addr */ +static void tc956x_desc_set_addr(struct dma_desc *p, dma_addr_t addr) +{ + u64 translated =3D addr + TC956X_SLV00_SRC_ADDR; + + p->des0 =3D cpu_to_le32(lower_32_bits(translated)); + p->des1 =3D cpu_to_le32(upper_32_bits(translated)); +} + +/* Override method for dwxgmac210_desc_ops->set_sec_addr */ +static void tc956x_desc_set_sec_addr(struct dma_desc *p, dma_addr_t addr, + bool is_valid) +{ + u64 translated =3D addr + TC956X_SLV00_SRC_ADDR; + + p->des2 =3D cpu_to_le32(lower_32_bits(translated)); + p->des3 =3D cpu_to_le32(upper_32_bits(translated)); +} + +/* + * Use mac_setup to apply the override methods above. + * + * The memory for the modified ops structures is pre-allocated as part of + * struct tc956x_data. + */ +static int tc956x_mac_setup(void *apriv, struct mac_device_info *mac) +{ + struct stmmac_priv *priv =3D apriv; + struct tc956x_data *td; + + td =3D priv->plat->bsp_priv; + + /* dwxgmac301_dma_ops needs extending to provide DMA address translation = */ + td->dma =3D dwxgmac301_dma_ops; + td->dma.init_rx_chan =3D tc956x_dma_init_rx_chan; + td->dma.init_tx_chan =3D tc956x_dma_init_tx_chan; + mac->dma =3D &td->dma; + + /* dwxgmac210_desc_ops also needs extending for the same reason */ + td->desc =3D dwxgmac210_desc_ops; + td->desc.set_addr =3D tc956x_desc_set_addr; + td->desc.set_sec_addr =3D tc956x_desc_set_sec_addr; + mac->desc =3D &td->desc; + + priv->hw =3D mac; + + return dwxgmac2_setup(priv); +} + +static int tc956x_pcs_init(struct stmmac_priv *priv) +{ + struct xpcs_regmap_config xpcs_regmap_cfg; + void __iomem *emac =3D priv->ioaddr; + struct regmap *xpcs_regmap; + void __iomem *xpcs_addr; + struct dw_xpcs *xpcs; + + xpcs_addr =3D emac + DWMAC_XPCS_OFFSET; + xpcs_regmap =3D devm_regmap_init_mmio(priv->device, xpcs_addr, + &xpcs_regmap_config); + if (IS_ERR(xpcs_regmap)) + return PTR_ERR(xpcs_regmap); + + xpcs_regmap_cfg.regmap =3D xpcs_regmap; + xpcs_regmap_cfg.reg_indir =3D true; + + xpcs =3D devm_xpcs_regmap_register(priv->device, &xpcs_regmap_cfg); + if (IS_ERR(xpcs)) + return PTR_ERR(xpcs); + + xpcs_config_eee_mult_fact(xpcs, priv->plat->mult_fact_100ns); + priv->hw->phylink_pcs =3D xpcs_to_phylink_pcs(xpcs); + + return 0; +} + +static struct phylink_pcs *tc956x_select_pcs(struct stmmac_priv *priv, + phy_interface_t interface) +{ + return priv->hw->phylink_pcs; +} + +static void tc956x_fix_mac_speed(void *bsp_priv, phy_interface_t interface, + int speed, unsigned int mode) +{ + struct tc956x_data *td =3D bsp_priv; + + tc956x_mac_configure(td, interface, speed); + tc956x_pma_init(td); +} + +static int tc956x_dwmac_suspend(struct device *dev, void *bsp_priv) +{ + struct tc956x_data *td =3D bsp_priv; + + tc956x_mac_disable(td); + + return 0; +} + +static int tc956x_dwmac_resume(struct device *dev, void *bsp_priv) +{ + struct tc956x_data *td =3D bsp_priv; + + tc956x_mac_enable(td); + + return 0; +} + +/* Called by tc956x_dwmac_probe(); return errors with dev_err_probe() */ +static int tc956x_dwmac_parse_dt(struct tc956x_data *td) +{ + struct device_node *mdio_node; + struct device *dev =3D td->dev; + struct device_node *np; + + np =3D dev_of_node(dev); + if (!np) + return dev_err_probe(dev, -EINVAL, "no devicetree node\n"); + + /* Find the MDIO bus */ + for_each_child_of_node(np, mdio_node) { + if (of_device_is_compatible(mdio_node, + "snps,dwmac-mdio")) + break; + } + + /* Pass the MDIO bus (if there is one) to the core driver */ + if (mdio_node) { + td->plat->mdio_node =3D mdio_node; + td->plat->mdio_bus_data->needs_reset =3D true; + } + + return 0; +} + +static int tc956x_lookup_max_speed(phy_interface_t phy_interface) +{ + switch (phy_interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_2500BASEX: + return SPEED_2500; + + default: + return -EOPNOTSUPP; + } +} + +/* Called by tc956x_dwmac_probe(); return errors with dev_err_probe() */ +static int tc956x_plat_dat_init(struct tc956x_data *td) +{ + struct plat_stmmacenet_data *plat; + phy_interface_t phy_interface; + struct device *dev =3D td->dev; + struct stmmac_axi *axi; + u32 speed; + int ret; + u32 i; + + ret =3D device_get_phy_mode(dev); + if (ret < 0) + return -ENODEV; + phy_interface =3D ret; + + /* The platform structure is allocated with devm_kzalloc() */ + plat =3D stmmac_plat_dat_alloc(dev); + if (!plat) + return -ENOMEM; + + ret =3D tc956x_lookup_max_speed(phy_interface); + if (ret < 0) + return dev_err_probe(dev, ret, "unsupported phy speed\n"); + speed =3D ret; + + plat->core_type =3D DWMAC_CORE_XGMAC; + plat->bus_id =3D td->auxbus_data->mac_id; + plat->phy_interface =3D phy_interface; + plat->mdio_bus_data =3D &td->mdio_bus_data; + /* Parent PCI device is used for DMA */ + plat->dma_device =3D dev->parent; + plat->dma_cfg =3D &td->dma_cfg; + plat->dma_cfg->pbl =3D 32; + plat->dma_cfg->pblx8 =3D true; + + /* + * Our MAC clock rate is fixed at 125 MHz. For XGMAC, clk_csr 0 + * represents "divide by 62" and gets the best rate under 2.5 MHz. + */ + plat->clk_csr =3D 0; /* MDC clock =3D clk_csr_i / 62 */ + plat->default_an_inband =3D true; + plat->force_sf_dma_mode =3D true; + plat->max_speed =3D speed; + plat->unicast_filter_entries =3D 32; + + /* + * TC956x has 8 RX queues but we observe significantly reduced RX + * bandwidth if we don't have at least 8k FIFO space per queue, so + * by default we avoid using all the queues. + */ + plat->rx_queues_to_use =3D 4; + + /* + * TC956x has 8 TX queues but only #0 to #3 work for general IP traffic. + * For now we will limit the driver to only these queues. + */ + plat->tx_queues_to_use =3D 4; + + /* + * Oversized FIFOs result in reduced performance in bandwidth tests. + * Limit them to 8KiB per queue, or the total available. + */ + plat->tx_fifo_size =3D + min(TC956X_TX_FIFO_KB, 8 * plat->tx_queues_to_use) * SZ_1K; + plat->rx_fifo_size =3D + min(TC956X_RX_FIFO_KB, 8 * plat->rx_queues_to_use) * SZ_1K; + plat->host_dma_width =3D 36; + + plat->rx_sched_algorithm =3D MTL_RX_ALGORITHM_SP; + plat->tx_sched_algorithm =3D MTL_TX_ALGORITHM_WRR; + + /* Default RX chan is set to queue index (0..rx_queues_to_use-1) */ + for (i =3D 0; i < plat->rx_queues_to_use; i++) + plat->rx_queues_cfg[i].mode_to_use =3D MTL_QUEUE_DCB; + + for (i =3D 0; i < plat->tx_queues_to_use; i++) { + plat->tx_queues_cfg[i].weight =3D 12; + plat->tx_queues_cfg[i].mode_to_use =3D MTL_QUEUE_DCB; + + /* Only queues 5-8 support time-based scheduling on TC956X */ + if (i >=3D 5) + plat->tx_queues_cfg[i].tbs_en =3D 1; + } + + plat->fix_mac_speed =3D tc956x_fix_mac_speed; + plat->suspend =3D tc956x_dwmac_suspend; + plat->resume =3D tc956x_dwmac_resume; + plat->mac_setup =3D tc956x_mac_setup; + plat->pcs_init =3D tc956x_pcs_init; + plat->select_pcs =3D tc956x_select_pcs; + + plat->bsp_priv =3D td; + plat->clk_ptp_rate =3D TC956X_PTP_CLOCK_RATE; + + /* AXI Configuration */ + axi =3D &td->axi; + axi->axi_lpi_en =3D 1; + axi->axi_wr_osr_lmt =3D 31; + axi->axi_rd_osr_lmt =3D 31; + /* All sizes (2^2..2^8) are supported */ + axi->axi_blen_regval =3D DMA_AXI_BLEN_MASK; + plat->axi =3D axi; + + plat->mac_port_sel_speed =3D speed; + plat->flags =3D STMMAC_FLAG_MULTI_MSI_EN | STMMAC_FLAG_TSO_EN; + + td->plat =3D plat; + + return 0; +} + +/* + * The domain was created with IRQ_DOMAIN_FLAG_DESTROY_GC, so any mapped I= RQs + * will be disposed when the domain is removed (when the device is destroy= ed). + */ +static int tc956x_stmmac_resources_init(struct tc956x_data *td) +{ + struct irq_domain *irq_domain =3D td->irq_domain; + struct stmmac_resources *res =3D &td->res; + u32 i; + + res->irq =3D irq_create_mapping(irq_domain, HWIRQ_EVENT); + if (!res->irq) + return -EINVAL; + + for (i =3D 0; i < td->plat->tx_queues_to_use; i++) { + res->tx_irq[i] =3D irq_create_mapping(irq_domain, HWIRQ_TX0 + i); + if (!res->tx_irq[i]) + return -EINVAL; + } + + for (i =3D 0; i < td->plat->rx_queues_to_use; i++) { + res->rx_irq[i] =3D irq_create_mapping(irq_domain, HWIRQ_RX0 + i); + if (!res->rx_irq[i]) + return -EINVAL; + } + + res->addr =3D td->auxbus_data->emac; + + return 0; +} + +static void tc956x_stmmac_resources_exit(struct tc956x_data *td) +{ + struct stmmac_resources *res =3D &td->res; + u32 i; + + for (i =3D 0; i < td->plat->rx_queues_to_use; i++) + irq_dispose_mapping(res->rx_irq[i]); + + for (i =3D 0; i < td->plat->tx_queues_to_use; i++) + irq_dispose_mapping(res->tx_irq[i]); + + irq_dispose_mapping(res->irq); +} + +static int tc956x_dwmac_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct device *dev =3D &adev->dev; + struct tc956x_data *td; + int ret; + + td =3D devm_kzalloc(dev, sizeof(*td), GFP_KERNEL); + if (!td) + return -ENOMEM; + + td->dev =3D dev; + td->auxbus_data =3D dev_get_platdata(dev); + if (!td->auxbus_data) + return dev_err_probe(dev, -EINVAL, "no platform data\n"); + + ret =3D tc956x_plat_dat_init(td); + if (ret) + return ret; + + /* If successful, we hold a reference to the platform MDIO DT node */ + ret =3D tc956x_dwmac_parse_dt(td); + if (ret) + return ret; + + td->irq_domain =3D tc956x_msigen_irq_domain_instantiate(td); + if (IS_ERR(td->irq_domain)) { + ret =3D dev_err_probe(dev, PTR_ERR(td->irq_domain), + "failed to instantiate IRQ domain\n"); + goto err_put_mdio; + } + + ret =3D tc956x_stmmac_resources_init(td); + if (ret) { + ret =3D dev_err_probe(dev, ret, + "failed to initialize stmmac resources\n"); + goto err_put_mdio; + } + + /* Put the MAC in a known initial state, then enable it */ + tc956x_mac_init_state(td); + tc956x_mac_enable(td); + + ret =3D stmmac_dvr_probe(dev, td->plat, &td->res); + if (ret) { + ret =3D dev_err_probe(dev, ret, "failed stmmac probe\n"); + goto err_disable_mac; + } + + return 0; + +err_disable_mac: + tc956x_mac_disable(td); + tc956x_stmmac_resources_exit(td); +err_put_mdio: + of_node_put(td->plat->mdio_node); + + return ret; +} + +static void tc956x_dwmac_remove(struct auxiliary_device *adev) +{ + struct device *dev =3D &adev->dev; + struct net_device *ndev =3D dev_get_drvdata(dev); + struct stmmac_priv *priv =3D netdev_priv(ndev); + struct tc956x_data *td =3D priv->plat->bsp_priv; + + stmmac_dvr_remove(dev); + tc956x_mac_disable(td); + tc956x_stmmac_resources_exit(td); + of_node_put(td->plat->mdio_node); +} + +static const struct auxiliary_device_id tc956x_dwmac_ids[] =3D { + { .name =3D TC956X_PCIE_DRIVER_NAME "." TC956X_XGMAC_DEV_NAME, }, + { }, +}; +MODULE_DEVICE_TABLE(auxiliary, tc956x_dwmac_ids); + +static struct auxiliary_driver tc956x_dwmac_driver =3D { + .name =3D DRIVER_NAME, + .probe =3D tc956x_dwmac_probe, + .remove =3D tc956x_dwmac_remove, + .id_table =3D tc956x_dwmac_ids, + .driver =3D { + .name =3D DRIVER_NAME, + .pm =3D &stmmac_simple_pm_ops, + .owner =3D THIS_MODULE, + }, +}; +module_auxiliary_driver(tc956x_dwmac_driver); + +MODULE_DESCRIPTION("Toshiba TC956x PCIe Ethernet Network Driver"); +MODULE_LICENSE("GPL"); --=20 2.51.0 From nobody Mon Jun 8 07:22:06 2026 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 0C9CA37F8AD for ; Fri, 5 Jun 2026 01:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621303; cv=none; b=t93DH3ol1F4QfDlfYGq9MSwQ2ghUQyFS+QBCfwzphjOeL31SxinsztoC3+/+r6e+OO/FrSKN85wrtlZKKS/XknUOBueASsIz2h5Po7uX4IZxxea/5N2LosEAO5ZiZBcuHGoeqPUdvPGDLm1mO0GGzvCrbutYr2JTTgKRIr6nxis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621303; c=relaxed/simple; bh=bNdzZCp4H4EqUayBYK6F7gzfqkb9PzdmXuPOgMv/cjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nGgkJH2IM7DbBmAjMmtDvvysIc1wglEXe7TISeGKB/nRnHzzcdWrkWGfmfiGF07u6+EgiWcoVGS/gYvOT/iz+dnqDvSl9oARp3EjE+0W20PMntu5dxWITPgQEnIjOCCeWjryMWTwL+YH/CtfLHhz8LXWa0qx+NsmV/oEk6WnQ9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b=FbyFCMbr; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20251104.gappssmtp.com header.i=@riscstar-com.20251104.gappssmtp.com header.b="FbyFCMbr" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-4854166e1efso1259994b6e.3 for ; Thu, 04 Jun 2026 18:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20251104.gappssmtp.com; s=20251104; t=1780621272; x=1781226072; 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=47bS3KYOz0HXJEWz/g//BdjKiICUn63lin6d0JHBcp8=; b=FbyFCMbrcdE33xYJfmSU0PdE/SwPh+C7CaeDFSXmLHoGc25fvOSL4JI0qHenNYnf+k RRnnw+KIZtMIaM3kKgm/ILskMrxxGQGJX0frZo3QxRIsAJndGKv0Ocuurx04t7Ses7ar 5Qud2JgujPHybNuEWD2VL3yqCFzH/1sn4UGEL+6qygiLMpoRT+AqCpNPFyhtB3Dwqfa1 eM/NFqVhK59r1l8pFBlscaGBm0IX2TUoPxKbI+tjjmqlfwG1pPGJVeTqya0KOBhffoWn wUGvKOfLVEu3FkkQ4pyt8mazPQfXc0FYEDw6PHsOR6l08EF9VFwFznFjsvNyivu4qgVG UoOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621272; x=1781226072; 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=47bS3KYOz0HXJEWz/g//BdjKiICUn63lin6d0JHBcp8=; b=BTAXOtOocCLHjHSIECXVuMafY6Ecc3syZ1G7bJjWoqXFpLEDE4F3hsGJSRZN1Mn1wO XP8wnJeCiX7byJGCwof0PBKHmUNRMs1BCCc613NuYWHkkPLMipzWuqHzfhwHm67uanAR lOz0YeimXtIl/FifQKXzzkp/ERo4dcj0XA3KrlVCNqUGAjYR/2mMCRqhjbK/ZdtcB63Y jT49/JSChRMNJvyaVQDe4D1/OTyZKQlFnVKDuHGVdRJtMpMWJjoo2kM2nJjb6BF2XsaT ixfaIjeZf54CHCvx14le6d8YUcQz6AAQyG8igJ+qn5UI3oGs4RFB9mlNjKVgiEoWj2Og Ui3g== X-Forwarded-Encrypted: i=1; AFNElJ/Q7xLGrkHo3c1UAEdldn8xhVnZo7eM3FutpJUmBFlJuF9PXEdCPd9D4rei0Z1OVVE14Nmw5/j0W6Sck6Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxMw5GXKKmqKwYqITT296tx0stVnN8kNAm0ypqSL777prxD2s42 QvyzPrDrhs732FJ820FmBVqvtv3CIUdzmTmVWoMr3xDgnxVIiYkGlxY2xeARc7DfpOM= X-Gm-Gg: Acq92OG1XLKji7nRU1AVx+40lrba9hLAmqciPjWzWRxGSh68kZ8iLxpY7qDM8MMuxxR GGG7EEa660aZemCNo5oQRBToVt23fdu/SMdYBELOs7hYXfLuNRhAPqfpQ5t/XiJhSrXlBayTJOc WQwn9ruEG8K5vZzsybAKFWJqoObFdhOlYzz1WDruWD6FGgdb+Tu8EZqInrSddH9JYIpgtmLvYWp i9wZTC1s84HgpFwmS8XVu2H5lgHGE/B5Wg9FCO0gKJfy337SiFVstBpRf9nrmkGbuG0VpSyO/Uo Tu0IVmzQnrZif5ivOJ7Dirs8pILzF6evCgbOLN/Xq5WVX3trF2jTtt1t5pxQwLNDwO/u3ak+C+M bDjE8JyToOVG56emiyv5yPH68Hb/hj2KOJyoIcLu09VHFH59mLm+0MgDr5cKMhHWxqkUI4ez3n9 LkRZNhe3GmzErM63L8s3sulGQS9BdZEW8ZJ9CWtQ== X-Received: by 2002:a05:6808:1804:b0:467:27d2:96a7 with SMTP id 5614622812f47-4868dd0463amr865195b6e.15.1780621271933; Thu, 04 Jun 2026 18:01:11 -0700 (PDT) Received: from zippy.localdomain ([73.62.185.64]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4865b6ec694sm5544631b6e.5.2026.06.04.18.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 18:01:11 -0700 (PDT) From: Alex Elder To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, rmk+kernel@armlinux.org.uk, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linusw@kernel.org, brgl@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: Daniel Thompson , elder@riscstar.com, mohd.anwar@oss.qualcomm.com, a0987203069@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org, boon.khai.ng@altera.com, chenchuangyu@xiaomi.com, chenhuacai@kernel.org, daniel@iogearbox.net, hawk@kernel.org, hkallweit1@gmail.com, inochiama@gmail.com, john.fastabend@gmail.com, julianbraha@gmail.com, livelycarpet87@gmail.com, mcoquelin.stm32@gmail.com, me@ziyao.cc, prabhakar.mahadev-lad.rj@bp.renesas.com, richardcochran@gmail.com, rohan.g.thomas@altera.com, sdf@fomichev.me, siyanteng@cqsoftware.com.cn, weishangjuan@eswincomputing.com, wens@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 14/14] arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081 phy Date: Thu, 4 Jun 2026 20:00:21 -0500 Message-ID: <20260605010022.968612-15-elder@riscstar.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260605010022.968612-1-elder@riscstar.com> References: <20260605010022.968612-1-elder@riscstar.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Thompson The QCS6490 RB3Gen2 includes a Toshiba TC9564 (a.k.a. Qualcomm QPS615). TC9564 is an twin Ethernet-AVB/TSN bridge with an integrated PCIe switch. Downstream PCIe switch port 3 has an embedded PCIe endpoint, which includes two functions. The GPIO controller embedded within the TC9564 is accessed via memory-mapped I/O through the first PCIe function's BAR4. Both embedded PCIe functions have an attached Synopsys XGMAC, but not all RB3gen2 builds include PHYs on both ports. All versions include a TC9564 combined with a single QCA8081 attached to eMAC1. Add properties to the existing PCI nodes to describe how the TC9564 and QCA8081 are connected to each other (and to the host SoC). Signed-off-by: Daniel Thompson Co-developed-by: Alex Elder Signed-off-by: Alex Elder --- Checkpatch notes: - pci1179 is not a recognized vendor ID - Some lines are longer than recommented arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts b/arch/arm64/boot= /dts/qcom/qcs6490-rb3gen2.dts index e393ccf1884af..1d83b07360a33 100644 --- a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +++ b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts @@ -308,6 +308,15 @@ vdd_ntn_1p8: regulator-vdd-ntn-1p8 { regulator-enable-ramp-delay =3D <10000>; }; =20 + qep_1p8: regulator-qep-1p8 { + compatible =3D "regulator-fixed"; + regulator-name =3D "qep_1p8"; + gpio =3D <&pm7325_gpios 8 GPIO_ACTIVE_HIGH>; + regulator-min-microvolt =3D <1800000>; + regulator-max-microvolt =3D <1800000>; + enable-active-high; + }; + wcn6750-pmu { compatible =3D "qcom,wcn6750-pmu"; pinctrl-0 =3D <&bt_en>; @@ -938,19 +947,51 @@ pcie@3,0 { bus-range =3D <0x5 0xff>; =20 pci@0,0 { + compatible =3D "pci1179,0220"; reg =3D <0x50000 0x0 0x0 0x0 0x0>; #address-cells =3D <3>; #size-cells =3D <2>; device_type =3D "pci"; ranges; + + tc9564_gpio0: gpio { + gpio-controller; + #gpio-cells =3D <2>; + }; }; =20 pci@0,1 { + compatible =3D "pci1179,0220"; reg =3D <0x50100 0x0 0x0 0x0 0x0>; #address-cells =3D <3>; #size-cells =3D <2>; device_type =3D "pci"; ranges; + + ethernet { + phy-mode =3D "sgmii"; + phy-handle =3D <&tc9564_emac1_phy>; + + mdio { + compatible =3D "snps,dwmac-mdio"; + #address-cells =3D <1>; + #size-cells =3D <0>; + + tc9564_emac1_phy: ethernet-phy@1c { + compatible =3D "ethernet-phy-id004d.d101"; + reg =3D <0x1c>; + snps,reset =3D <&tc9564_gpio0 1 GPIO_ACTIVE_LOW>; + reset-assert-us =3D <11000>; + reset-deassert-us =3D <70000>; + + vdd18-supply =3D <&qep_1p8>; + + pinctrl-names =3D "default"; + pinctrl-0 =3D <&qep_irq_pin>; + interrupts-extended =3D <&tlmm 101 IRQ_TYPE_LEVEL_LOW>; + }; + }; + }; }; }; }; @@ -1524,6 +1565,13 @@ usb_hub_reset_state: usb-hub-reset-state { drive-strength =3D <2>; bias-disable; }; + + qep_irq_pin: qep-irq-state { + pins =3D "gpio101"; + function =3D "gpio"; + drive-strength =3D <2>; + bias-disable; + }; }; =20 &lpass_audiocc { --=20 2.51.0