mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: linux-arm-kernel@lists.infradead.org
Cc: "Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Vinod Koul" <vkoul@kernel.org>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Yendapally Reddy Dhananjaya Reddy"
	<yendapally.reddy@broadcom.com>,
	linux-phy@lists.infradead.org (open list:GENERIC PHY FRAMEWORK),
	devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND
	FLATTENED DEVICE TREE BINDINGS),
	linux-kernel@vger.kernel.org (open list),
	linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
Subject: [PATCH 3/9] phy: broadcom: ns-usb3: Coordinate NSP USB2 and USB3 initialization
Date: Wed, 21 Oct 2026 10:28:12 -0700	[thread overview]
Message-ID: <20261021172819.668120-4-florian.fainelli@broadcom.com> (raw)
In-Reply-To: <20261021172819.668120-1-florian.fainelli@broadcom.com>

The iProc SDK holds both USB2 and USB3 cores in reset while programming
the USB3 PLL, then releases USB2 before USB3. It also enables the USB2
IDM interface clock. The Northstar Bx initialization used by NSP does
not perform the USB2 setup or retain the SDK settling intervals.

Implement an NSP variant with the coordinated reset sequence and
interface clock enable. Sharing one PHY between the HCDs lets the PHY
core serialize and reference-count initialization, preventing a later
host probe from resetting an already active USB2 controller.

Retain the downstream delays around reset and MDIO operations, and
leave both NSP cores reset if programming fails. Keep existing
Northstar Ax and Bx reset behavior unchanged.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/phy/broadcom/phy-bcm-ns-usb3.c | 55 ++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/phy/broadcom/phy-bcm-ns-usb3.c b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
index b40033144080..b3b5b74ead09 100644
--- a/drivers/phy/broadcom/phy-bcm-ns-usb3.c
+++ b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
@@ -44,12 +44,14 @@ enum bcm_ns_family {
 	BCM_NS_UNKNOWN,
 	BCM_NS_AX,
 	BCM_NS_BX,
+	BCM_NSP,
 };
 
 struct bcm_ns_usb3 {
 	struct device *dev;
 	enum bcm_ns_family family;
 	void __iomem *dmp;
+	void __iomem *usb2_dmp;
 	struct mdio_device *mdiodev;
 	struct phy *phy;
 };
@@ -63,6 +65,10 @@ static const struct of_device_id bcm_ns_usb3_id_table[] = {
 		.compatible = "brcm,ns-bx-usb3-phy",
 		.data = (int *)BCM_NS_BX,
 	},
+	{
+		.compatible = "brcm,nsp-usb3-phy",
+		.data = (void *)BCM_NSP,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, bcm_ns_usb3_id_table);
@@ -86,6 +92,9 @@ static int bcm_ns_usb3_write_seq(struct bcm_ns_usb3 *usb3,
 		err = bcm_ns_usb3_mdio_phy_write(usb3, seq[i].reg, seq[i].value);
 		if (err)
 			return err;
+
+		if (usb3->family == BCM_NSP)
+			usleep_range(10000, 20000);
 	}
 
 	return 0;
@@ -121,8 +130,18 @@ static int bcm_ns_usb3_phy_init_ns_bx(struct bcm_ns_usb3 *usb3)
 	if (err)
 		return err;
 
+	if (usb3->usb2_dmp) {
+		writel(0, usb3->usb2_dmp + BCMA_RESET_CTL);
+		readl(usb3->usb2_dmp + BCMA_RESET_CTL);
+		usleep_range(10000, 20000);
+	}
+
 	/* Deasserting USB3 system reset */
 	writel(0, usb3->dmp + BCMA_RESET_CTL);
+	if (usb3->family == BCM_NSP) {
+		readl(usb3->dmp + BCMA_RESET_CTL);
+		usleep_range(10000, 20000);
+	}
 
 	return bcm_ns_usb3_write_seq(usb3, phy_seq, ARRAY_SIZE(phy_seq));
 }
@@ -160,16 +179,35 @@ static int bcm_ns_usb3_phy_init_ns_ax(struct bcm_ns_usb3 *usb3)
 static int bcm_ns_usb3_phy_init(struct phy *phy)
 {
 	struct bcm_ns_usb3 *usb3 = phy_get_drvdata(phy);
+	u32 val;
 	int err;
 
+	/*
+	 * NSP requires both hosts to remain in reset while programming the PLL.
+	 * Sharing this PHY between all three HCDs makes the PHY core serialize
+	 * and reference-count this sequence, regardless of their probe order.
+	 */
+	if (usb3->usb2_dmp) {
+		val = readl(usb3->usb2_dmp + BCMA_IOCTL);
+		writel(val | BCMA_IOCTL_CLK, usb3->usb2_dmp + BCMA_IOCTL);
+		writel(BCMA_RESET_CTL_RESET, usb3->usb2_dmp + BCMA_RESET_CTL);
+		readl(usb3->usb2_dmp + BCMA_RESET_CTL);
+		usleep_range(10000, 20000);
+	}
+
 	/* Perform USB3 system soft reset */
 	writel(BCMA_RESET_CTL_RESET, usb3->dmp + BCMA_RESET_CTL);
+	if (usb3->family == BCM_NSP) {
+		readl(usb3->dmp + BCMA_RESET_CTL);
+		usleep_range(10000, 20000);
+	}
 
 	switch (usb3->family) {
 	case BCM_NS_AX:
 		err = bcm_ns_usb3_phy_init_ns_ax(usb3);
 		break;
 	case BCM_NS_BX:
+	case BCM_NSP:
 		err = bcm_ns_usb3_phy_init_ns_bx(usb3);
 		break;
 	default:
@@ -177,6 +215,11 @@ static int bcm_ns_usb3_phy_init(struct phy *phy)
 		err = -ENOTSUPP;
 	}
 
+	if (err && usb3->usb2_dmp) {
+		writel(BCMA_RESET_CTL_RESET, usb3->usb2_dmp + BCMA_RESET_CTL);
+		writel(BCMA_RESET_CTL_RESET, usb3->dmp + BCMA_RESET_CTL);
+	}
+
 	return err;
 }
 
@@ -225,6 +268,18 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
 	if (IS_ERR(usb3->dmp))
 		return PTR_ERR(usb3->dmp);
 
+	if (usb3->family == BCM_NSP) {
+		syscon_np = of_parse_phandle(dev->of_node, "usb2-dmp-syscon", 0);
+		err = of_address_to_resource(syscon_np, 0, &res);
+		of_node_put(syscon_np);
+		if (err)
+			return err;
+
+		usb3->usb2_dmp = devm_ioremap_resource(dev, &res);
+		if (IS_ERR(usb3->usb2_dmp))
+			return PTR_ERR(usb3->usb2_dmp);
+	}
+
 	usb3->phy = devm_phy_create(dev, NULL, &ops);
 	if (IS_ERR(usb3->phy)) {
 		dev_err(dev, "Failed to create PHY\n");
-- 
2.53.0


  parent reply	other threads:[~2026-10-21 17:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 17:28 [PATCH 0/9] Fix USB2 and USB3 on NSP SoCs Florian Fainelli
2026-10-21 17:28 ` [PATCH 2/9] dt-bindings: phy: bcm-ns-usb3-phy: Describe the NSP variant Florian Fainelli
2026-10-21 17:28 ` Florian Fainelli [this message]
2026-10-21 17:28 ` [PATCH 6/9] dt-bindings: usb: generic-ehci: Add the NSP compatible Florian Fainelli
2026-10-21 17:28 ` [PATCH 7/9] usb: host: ehci-platform: Set the FIFO threshold on NSP Florian Fainelli
2026-10-21 17:28 ` [PATCH 8/9] ARM: dts: broadcom: Identify the NSP EHCI controller Florian Fainelli
2026-10-21 17:28 ` [PATCH 9/9] ARM: dts: broadcom: Use noncoherent USB DMA on BCM958625HR Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261021172819.668120-4-florian.fainelli@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rafal@milecki.pl \
    --cc=rjui@broadcom.com \
    --cc=robh@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=stern@rowland.harvard.edu \
    --cc=vkoul@kernel.org \
    --cc=yendapally.reddy@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®