From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FC98606A31C for ; Sun, 29 Nov 2026 09:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dLaBGx7E DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=FSrewYnBIh21r/GYXybyxec5F85Q8RdVOYoQN1ATIZ0=; b=dLaBGx7E+rbKGYIoFpW5uw582F 3YpRJ4ZhAeOfYdwn3ARDYI9MrDPZMzNf3V1iEHtkeBHwvyyQdQrkVLPgb+ZhSn2GjkIg7rb6Fi8ch w3fJ341UFO6iADLnkwubdkOWFN1Mcn7naWJSgSBbo9gFUI08O1/pjguc9sFBHbHzXNuRL2FYM/nrk RnkQVunu7fQ6KavBya0J9D1MboTIpqzVpIvfNByh5Y4wuBmrTlteABk9k8dzfKjGPitxRJF6R3z1n 8zvI/ZUcvzspdQXX7DVR8PL84SSMyk65CDxPNs/qH2zpP4Rd1XYMissxzqlRMigTzQQmihp6h848r JjzHCq3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXbDY-00000001kGd-0LOR; Sun, 29 Nov 2026 09:29:08 +0000 Received: from mail-wr1-f47.google.com ([209.85.221.47]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXbCl-00000001ji4-2eBk for linux-amlogic@lists.infradead.org; Sun, 29 Nov 2026 09:28:23 +0000 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-492690dd5daso7289710f8f.1 for ; Sun, 29 Nov 2026 01:28:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795944498; x=1796549298; 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:content-type; bh=zxie58zR4/JW7vqsXzF1LKErCaPavjE15MsKw9L73R8=; b=R/Nx7fUFkCEc4EgNfP5H5r/AAfJiMSNIuq2WxHo3Nwi+rPb88zgjnJWt3W/J9N+GqL vfGh+DyR2RB7bIeBcQGiY3leUxHJr1B227ijjzJBlCPb49/hLU/XeWENZCNuqWtuSxZq I4HhtUMKTtc4gU+EkblYn15R0mKYXIK/2t9PqAX9BTnyKRcypr6zi3FMQ453gVijZ6/a c/2DKnpsf5IQ2jouX3zxWhFChLpEVJ+5H51Qr+UKgDfKjw2E7TTvZv+JW/rMAqIlOHeY aa7sMkIvga7ykhcD88LTCT162pBXqx6+VaZ+0JtMcyj8DG3E8cS8b8HopTW1F1CSrLAY E23w== X-Forwarded-Encrypted: i=1; AL+hErE776kHAA6Stxc+WdDO6CRkXhvFNfZ67BjCZccODagByC59pq/hrs4p+641DYSfSxK/Pq57sG8Zg4Kq2Og5@lists.infradead.org X-Gm-Message-State: APuU4Z831Qwj/sSL9zOETx5W6jtvLutHbRBTtsHkmc5WPiVxkhwYAtAn X3aqhgqeIi0vbI4+vEKdDqcGjVVlVPl46QwUcGSDfTDP4PS9nhHMaJIX X-Gm-Gg: AZFdTZe135LLZZpaqTjvFm355Sp4/+Gwu2/fRkxoGVU4FJer0/MfBKCAV1jN+jGbLWW lDxVcuSNs/nwdrYPAKL4cHSJQdADhhqCh7FRN7+9/o0I9Nx4ukIbpV0L25hi/xjG4qZlHeFxUyh NXzomUv0ps6EDbyCRPHKTMv6KkVFKyDhCpiAMTnu40cbUiVYUr8yOqWtzrrfHYqkPWuXQJVJOe0 UG9TQI//onGIsLMY3eEIhWMBbjUxVPdiXjQlupYNqUGnJ3VMf380hkPiZARW7t0vVdvblEJqHG9 xaQkT5TyyTCI7ocvxYgNOhuS7qubq7gWr61QOGMGXSasyfN3EfJS9A8/zvtTQdk/xLtpDRN8n+U MIxPpN0TACJ3zXbOCLRf1z8b0TqKwmK7Nu4DoimUDY9mR0q1jPODg3AxMTORl2JjlaAwmDoJeit tZnrXNYzX8xTIbgc4/JZJfVvQ+H/f9m8Nc8BJz+ZM/8RkYaM1WQ70PZjeIPaQqcDqbNhtDlTky5 KljeIrIYN8fxK4YqcKa9Gik/vZ2BRJ5/mRmqn+Qm2FQOqDNf1axI6eJMdzmd4PLW1e5ykmQBnYJ sbE2GQSV1UrGYpe7cVg/h2UyslatheTdUoGyaUjwGyN/IwTuoHSVGvpkBC8T+ZqFRD/vSB/2wtT tiDl0dD9Bdp26/XCwVoL5EPgf X-Received: by 2002:a5d:5f53:0:b0:4b7:6ea2:54be with SMTP id ffacd0b85a97d-4b76ec0df5fmr38943938f8f.14.1795944497700; Sun, 29 Nov 2026 01:28:17 -0800 (PST) Received: from threads.localdomain ([84.68.176.78]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf61e8sm60210765f8f.11.2026.11.29.01.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 01:28:17 -0800 (PST) From: Lucas Tanure To: Neil Armstrong , Kevin Hilman , Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , Mathias Nyman Cc: Jerome Brunet , Martin Blumenstingl , Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] phy: amlogic: phy-meson-g12a-usb3-pcie: add T7 support Date: Sun, 29 Nov 2026 09:28:09 +0000 Message-ID: <20261129092810.146043-9-tanure@linux.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261129092810.146043-1-tanure@linux.com> References: <20261129092810.146043-1-tanure@linux.com> X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_012819_781559_6695D7E0 X-CRM114-Status: GOOD ( 19.21 ) X-Spam-Score: -0.8 (/) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 USB 3 devices on the Amlogic T7 only connect at high speed. The chip has the G12A USB3 + PCIe combo PHY, but nothing sets it up. The G12A sequence alone is not enough on the T7. The PHY must be held in reset and released, the way the vendor driver does. The USB 3 lane also needs its reference clock, spread spectrum and transmit levels set in the USB control registers, and two analog settings differ from the G12A. Signed-off-by: Lucas Tanure --- .../phy/amlogic/phy-meson-g12a-usb3-pcie.c | 108 +++++++++++++++++- 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c index f94c08b17267..de65c9b2d2b6 100644 --- a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c +++ b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -50,22 +51,50 @@ #define PHY_R5_PHY_CR_ACK BIT(16) #define PHY_R5_PHY_BS_OUT BIT(17) +#define PHY_R6 0x18 + #define PHY_R6_SEL GENMASK(18, 17) + +#define USB_R3 0x0c + #define USB_R3_P30_REF_SSP_EN BIT(13) + #define USB_R3_P31_PCS_TX_DEEMPH_3P5DB GENMASK(25, 20) + +#define USB_R7 0x1c + #define USB_R7_P31_SSC_EN BIT(0) + #define USB_R7_P31_SSC_RANGE GENMASK(3, 1) + #define USB_R7_P31_PCS_TX_DEEMPH_6DB GENMASK(21, 16) + #define USB_R7_P31_PCS_TX_SWING_FULL GENMASK(31, 25) + #define PCIE_RESET_DELAY 500 +enum phy_g12a_usb3_pcie_soc { + PHY_G12A_USB3_PCIE_G12A, + PHY_G12A_USB3_PCIE_T7, +}; + struct phy_g12a_usb3_pcie_priv { struct regmap *regmap; struct regmap *regmap_cr; + struct regmap *regmap_usb; struct clk *clk_ref; struct reset_control *reset; struct phy *phy; unsigned int mode; + enum phy_g12a_usb3_pcie_soc soc; }; static const struct regmap_config phy_g12a_usb3_pcie_regmap_conf = { .reg_bits = 8, .val_bits = 32, .reg_stride = 4, - .max_register = PHY_R5, + .max_register = PHY_R6, +}; + +static const struct regmap_config phy_t7_usb3_regmap_conf = { + .name = "usb", + .reg_bits = 8, + .val_bits = 32, + .reg_stride = 4, + .max_register = USB_R7, }; static int phy_g12a_usb3_pcie_cr_bus_addr(struct phy_g12a_usb3_pcie_priv *priv, @@ -193,12 +222,57 @@ static const struct regmap_config phy_g12a_usb3_pcie_cr_regmap_conf = { .disable_locking = true, }; +static int phy_t7_usb3_reset(struct phy_g12a_usb3_pcie_priv *priv) +{ + int ret; + + ret = reset_control_assert(priv->reset); + if (ret) + return ret; + + usleep_range(100, 200); + + ret = reset_control_deassert(priv->reset); + if (ret) + return ret; + + usleep_range(100, 200); + + return 0; +} + +static void phy_t7_usb3_setup(struct phy_g12a_usb3_pcie_priv *priv) +{ + regmap_update_bits(priv->regmap, PHY_R6, PHY_R6_SEL, + FIELD_PREP(PHY_R6_SEL, 2)); + + regmap_update_bits(priv->regmap_usb, USB_R3, USB_R3_P30_REF_SSP_EN, + USB_R3_P30_REF_SSP_EN); + + regmap_update_bits(priv->regmap_usb, USB_R7, + USB_R7_P31_SSC_EN | USB_R7_P31_SSC_RANGE | + USB_R7_P31_PCS_TX_DEEMPH_6DB | + USB_R7_P31_PCS_TX_SWING_FULL, + USB_R7_P31_SSC_EN | + FIELD_PREP(USB_R7_P31_SSC_RANGE, 2) | + FIELD_PREP(USB_R7_P31_PCS_TX_DEEMPH_6DB, 0x20) | + FIELD_PREP(USB_R7_P31_PCS_TX_SWING_FULL, 127)); + + regmap_update_bits(priv->regmap_usb, USB_R3, + USB_R3_P31_PCS_TX_DEEMPH_3P5DB, + FIELD_PREP(USB_R3_P31_PCS_TX_DEEMPH_3P5DB, 0x15)); +} + static int phy_g12a_usb3_init(struct phy *phy) { struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); + bool t7 = priv->soc == PHY_G12A_USB3_PCIE_T7; int data, ret; - ret = reset_control_reset(priv->reset); + if (t7) + ret = phy_t7_usb3_reset(priv); + else + ret = reset_control_reset(priv->reset); if (ret) return ret; @@ -208,6 +282,9 @@ static int phy_g12a_usb3_init(struct phy *phy) PHY_R0_PCIE_USB3_SWITCH, PHY_R0_PCIE_USB3_SWITCH); + if (t7) + phy_t7_usb3_setup(priv); + /* * WORKAROUND: There is SSPHY suspend bug due to * which USB enumerates @@ -219,7 +296,8 @@ static int phy_g12a_usb3_init(struct phy *phy) if (ret) return ret; - ret = regmap_update_bits(priv->regmap_cr, 0x1010, 0xff0, 20); + ret = regmap_update_bits(priv->regmap_cr, 0x1010, 0xff0, + t7 ? 0x20 : 20); if (ret) return ret; @@ -272,7 +350,7 @@ static int phy_g12a_usb3_init(struct phy *phy) regmap_update_bits(priv->regmap, PHY_R1, PHY_R1_PHY_LOS_BIAS | PHY_R1_PHY_LOS_LEVEL, - FIELD_PREP(PHY_R1_PHY_LOS_BIAS, 4) | + FIELD_PREP(PHY_R1_PHY_LOS_BIAS, t7 ? 5 : 4) | FIELD_PREP(PHY_R1_PHY_LOS_LEVEL, 9)); return 0; @@ -402,6 +480,19 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev) if (IS_ERR(priv->regmap)) return PTR_ERR(priv->regmap); + priv->soc = (uintptr_t)of_device_get_match_data(dev); + + if (priv->soc == PHY_G12A_USB3_PCIE_T7) { + base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(base)) + return PTR_ERR(base); + + priv->regmap_usb = devm_regmap_init_mmio(dev, base, + &phy_t7_usb3_regmap_conf); + if (IS_ERR(priv->regmap_usb)) + return PTR_ERR(priv->regmap_usb); + } + priv->regmap_cr = devm_regmap_init(dev, NULL, priv, &phy_g12a_usb3_pcie_cr_regmap_conf); if (IS_ERR(priv->regmap_cr)) @@ -428,7 +519,14 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev) } static const struct of_device_id phy_g12a_usb3_pcie_of_match[] = { - { .compatible = "amlogic,g12a-usb3-pcie-phy", }, + { + .compatible = "amlogic,g12a-usb3-pcie-phy", + .data = (void *)PHY_G12A_USB3_PCIE_G12A, + }, + { + .compatible = "amlogic,t7-usb3-pcie-phy", + .data = (void *)PHY_G12A_USB3_PCIE_T7, + }, { }, }; MODULE_DEVICE_TABLE(of, phy_g12a_usb3_pcie_of_match); -- 2.56.1 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic