Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020619; b=ZsG2hgDD6M2F3ZaASL4iN956rX+gLwAGf6Moiv7NViTt7Q6kS2hsR+NXR5WNsHHj9wKg MM9jVQJLyVd6yVpEjSrzQkhCDvQlOCJiqVuE2fF9j8t3/bld8t2uF/coOevrhwpduVhyJ R6ZWpxMd5vGEcdppqDvbeOZzo+BzoBbRfAWErwllUT3bLppWwIdZKacaa28/ymR3lBnbu CxVzHz/MuLmvlI0n9+LbmktFlW97DgCRjKt6iJFlYJmbm3eASMI1Rkc855pnL2oKRYPje KJlLESZF5HwjDDi8NeDMp665il7bLJp7M7zpIMj+rr7PqS2f7ghuIJ+lp6SdhL4IcIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020619; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=hTiPLnuhm9c+sQTiXQOQx7ZKb4J6MdJg30zjhBmPJWM=; b=o7t/mpriT+BvClgERv3XXNgT7Bc6/5lbwxd8VTxSAyIAxUnyXOXIApoaqDbHD9uk7wBu SepQcHUBibcV/g5HueJSSUAWQHTq4/azW+6zypM7r+UD9VG32zs/PZCqsIis0tQRhGM9M lX6jyqbEUq+pmf8OCrfVberhccxFru3AHFmqRguVQQpapshw/8hYb4ep31eOnrejXW68V YBGvMq2CU+X6f8Do58Yi5iXmij4QBu95YApVo/wDw8BgbEeH1zCB7TiOZNndsHsXlDFoE flk7xtNXfQP0NOgYiKDMR6wrSHGA0Sc7XzgU4WC4WxQ2zOSlblLixmaIBTL/YmoRn/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KzydDjpZ; arc=none smtp.remote-ip=209.85.216.54 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCCFD606A682 for ; Mon, 30 Nov 2026 06:36:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CCCFD606A682 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KzydDjpZ Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3ac78f4c10bso4416855a91.1 for ; Sun, 29 Nov 2026 22:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796020618; x=1796625418; darn=lists.linux.dev; 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:content-type; bh=hTiPLnuhm9c+sQTiXQOQx7ZKb4J6MdJg30zjhBmPJWM=; b=KzydDjpZmg4yMb4Z8kmGNTeXwgBZEzHGErLmnd/ciD/rZxb+XzOGkjGLvfieiX42pb CCGPj3JHsPDlhWreKGdToStkcICkyp1LUMCwAWyg181bm63t/87XDAmDmNB98qB8xXAy IO2bfOp00tbasvPnqepUdR+LLssCjNW56GmVCu6GooaX4P/MMLPeg1b9wL7kl8oAVYrK 1TsDKzqMD7DzVZh9tok8O8LFPlMes10IG+1h1llTapKYYQe7dNXSaNMSoBzeJBFZjU/z +huV/Rqr07m7r/no6s02ImXsodDFhVoXRvgZVCpPUGEXjwsjEB4bR3o7PQXVEa88O1XV C7EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796020618; x=1796625418; 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=hTiPLnuhm9c+sQTiXQOQx7ZKb4J6MdJg30zjhBmPJWM=; b=S1Zku7cwENaZOmwmUnhXnhV36B/nWE/TcJ8gR7OCohrS/8QMYPfV5+hwudmJcczxUo AIa9pKlYDJsatEphwNbzL/WQ+uuTLq82IVGsmwIgeGa+As6cc4Ak2QjxEOrMfUuSbepe Vkjkx6xTXafjcoMv2fwWLPMWRAOhE8W50Zngj4VFWw4N/TAGpNmMFkFME0j+E2DE9xOH JwYiRSQpkwXFZH40iIm0S0fBRllvk3YbyQN13cpjjdDzapl/b90Nj5M1Z737W8lCvjDv zau79eXdOw+0cfuvAp1+WGSdUqTwuh2lUDkjUHYUtJKrHUKxC0sCiH0CJP0QVFPvTqyN sB6w== X-Forwarded-Encrypted: i=1; AL+hErFPGdztb1/ki5FCgAxegj3oNnGiaUexskGjo167P91sBVRgw8/eRgSffm93d0+M/ENvU7c=@lists.linux.dev X-Gm-Message-State: APuU4Z8pgMP4N5DZtuq63fJ147Cm7CHag1g+JJtuIKORBrud2SOoG/GW 8mUhse8QDnHajndii0gEsCX3ni5SQXnBilQ7BSDGTM0kv1cVXmbRAGIk X-Gm-Gg: AZFdTZfXzpTAH2NjhMjRT6DWoNYHS9FhP+EDw0YwoIP8QmgP2+s1erZpb4Jq+AASQhI DGzWFiCIGS+dA6YlATjPnFKphfSw8+zkhIdPq5QiWg3h6q7wUYPV6fK1gO3F9w4n6ATjvtmWkdk ywsmlMadheCaxVVLDnFyxLmje2826+gwZpAfZzr9aX6w8z3IGuydW73Ckyuncvb6cVGimONG5kQ rq6hSUsrz6LWBdBV0NBbkt3hJftb/XkWeaiWiLQXXNQ45YYJzFIbdm7GaqEJ5HIf0wObJOFnZVs MZA4c9FB5Jrxv1OYn/DY08wuYWVQ3RF9rYQNTv7LA0nRC/I1Zm9DQGRaBiDMTkFz+gFmDsAL3l3 ID6dlgfnLanhpkFC/BSWa41thnG+kFBYwZ247ouO3XQNDdtcEUOypz6/7HbiAYF5200HC60eFTN xm2itr5WCh6EWn5/C6gTqv4Txk2iB24RBnJZFNxAOiTYSEx4FRP/IjW+caNX8UtztUYxC2MQgg1 mrZ41AufxuExWhR3GSjuQmZ/KsFPbLntI5tUp+iwFTYEQEtJgIkKadMtpSg4yTEHSL4UyAKb6Uw 60a2lM0sFz/rm7Is9BbO5cpFtfI= X-Received: by 2002:a17:90b:5109:b0:39e:6a7e:ee18 with SMTP id 98e67ed59e1d1-3b41c9157acmr31814233a91.36.1796020618200; Sun, 29 Nov 2026 22:36:58 -0800 (PST) Received: from localhost ([2001:19f0:8000:4ce8:5400:7ff:fe0e:e6b2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41ad48786sm50581729a91.9.2026.11.29.22.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 22:36:57 -0800 (PST) From: Inochi Amaoto To: Andy Shevchenko , Jonathan Corbet , Shuah Khan , Randy Dunlap , Damien Le Moal , Niklas Cassel , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Aksh Garg , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Vinod Koul , Neil Armstrong , Vladimir Oltean , Rhys Tumelty , Inochi Amaoto , Qiang Yu , Manikandan K Pillai , "vladimir.oltean@nxp.com" , Hans Zhang <18255117159@163.com>, Yao Zi Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH v6 8/8] ata: ahci_imx: Use bulk PHY APIs for calibration PHYs Date: Mon, 30 Nov 2026 14:36:07 +0800 Message-ID: <20261130063607.294823-9-inochiama@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130063607.294823-1-inochiama@gmail.com> References: <20261130063607.294823-1-inochiama@gmail.com> X-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently the i.MX8QM SATA PHY relies on the first two HSIO lanes for shared impedance calibration. Store these calibration PHYs in a bulk array and acquire them by name with devm_phy_bulk_get(). Then process it in the lane id order in the imx8_sata_enable(). The document of this controller shows that the PHY will enter calibration mode only after it is deasserted. And this deassert is performed in the PHYs' power_on() callback. As the init() callback only enabled the clocks of the calibration PHY. It should be safe to use bulk api to init all the calibration PHYs before powering on them, as the bulk api can preserve the power on order. Signed-off-by: Inochi Amaoto Reviewed-by: Vladimir Oltean --- drivers/ata/ahci_imx.c | 54 +++++++++++++----------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index 6aaa18e29abc..3f7856eb4f08 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c @@ -25,6 +25,8 @@ #define DRV_NAME "ahci-imx" +#define NUM_CALIPHY 2 + enum { /* Timer 1-ms Register */ IMX_TIMER1MS = 0x00e0, @@ -66,8 +68,7 @@ struct imx_ahci_priv { struct clk *ahb_clk; struct regmap *gpr; struct phy *sata_phy; - struct phy *cali_phy0; - struct phy *cali_phy1; + struct phy_bulk_data cali_phys[NUM_CALIPHY]; bool no_device; bool first_time; u32 phy_params; @@ -428,30 +429,20 @@ static int imx8_sata_enable(struct ahci_host_priv *hpriv) * Initialize the first two lane PHYs here, although only the * third lane PHY is used by SATA. */ - ret = phy_init(imxpriv->cali_phy0); + ret = phy_bulk_init(NUM_CALIPHY, imxpriv->cali_phys); if (ret) { dev_err(dev, "cali PHY init failed\n"); return ret; } - ret = phy_power_on(imxpriv->cali_phy0); + ret = phy_bulk_power_on(NUM_CALIPHY, imxpriv->cali_phys); if (ret) { dev_err(dev, "cali PHY power on failed\n"); - goto err_cali_phy0_exit; - } - ret = phy_init(imxpriv->cali_phy1); - if (ret) { - dev_err(dev, "cali PHY1 init failed\n"); - goto err_cali_phy0_off; - } - ret = phy_power_on(imxpriv->cali_phy1); - if (ret) { - dev_err(dev, "cali PHY1 power on failed\n"); - goto err_cali_phy1_exit; + goto err_cali_phy_exit; } ret = phy_init(imxpriv->sata_phy); if (ret) { dev_err(dev, "sata PHY init failed\n"); - goto err_cali_phy1_off; + goto err_cali_phy_off; } ret = phy_set_mode(imxpriv->sata_phy, PHY_MODE_SATA); if (ret) { @@ -465,10 +456,8 @@ static int imx8_sata_enable(struct ahci_host_priv *hpriv) } /* The cali_phy# can be turned off after SATA PHY is initialized. */ - phy_power_off(imxpriv->cali_phy1); - phy_exit(imxpriv->cali_phy1); - phy_power_off(imxpriv->cali_phy0); - phy_exit(imxpriv->cali_phy0); + phy_bulk_power_off(NUM_CALIPHY, imxpriv->cali_phys); + phy_bulk_exit(NUM_CALIPHY, imxpriv->cali_phys); /* RxWaterMark setting */ val = readl(hpriv->mmio + IMX8QM_SATA_AHCI_PTC); @@ -480,14 +469,10 @@ static int imx8_sata_enable(struct ahci_host_priv *hpriv) err_sata_phy_exit: phy_exit(imxpriv->sata_phy); -err_cali_phy1_off: - phy_power_off(imxpriv->cali_phy1); -err_cali_phy1_exit: - phy_exit(imxpriv->cali_phy1); -err_cali_phy0_off: - phy_power_off(imxpriv->cali_phy0); -err_cali_phy0_exit: - phy_exit(imxpriv->cali_phy0); +err_cali_phy_off: + phy_bulk_power_off(NUM_CALIPHY, imxpriv->cali_phys); +err_cali_phy_exit: + phy_bulk_exit(NUM_CALIPHY, imxpriv->cali_phys); return ret; } @@ -844,15 +829,10 @@ static int imx8_sata_probe(struct device *dev, struct imx_ahci_priv *imxpriv) return dev_err_probe(dev, PTR_ERR(imxpriv->sata_phy), "Failed to get sata_phy\n"); - imxpriv->cali_phy0 = devm_phy_get(dev, "cali-phy0"); - if (IS_ERR(imxpriv->cali_phy0)) - return dev_err_probe(dev, PTR_ERR(imxpriv->cali_phy0), - "Failed to get cali_phy0\n"); - imxpriv->cali_phy1 = devm_phy_get(dev, "cali-phy1"); - if (IS_ERR(imxpriv->cali_phy1)) - return dev_err_probe(dev, PTR_ERR(imxpriv->cali_phy1), - "Failed to get cali_phy1\n"); - return 0; + imxpriv->cali_phys[0].id = "cali-phy0"; + imxpriv->cali_phys[1].id = "cali-phy1"; + + return devm_phy_bulk_get(dev, NUM_CALIPHY, imxpriv->cali_phys); } static int imx_ahci_probe(struct platform_device *pdev) -- 2.56.1