From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020619; b=Iq0W/JGfkZPLOKa8hAX3OTMDEUgRvtXOrEBkh+p4+FhyooLCXlJ65XsAttJsmi4alpX0 XEc+fK9NPYm7O35m6u+2dmcryXkLecSHBEsTMmzVAtwccnIfxbh6IHqD06Lelmvlrd3qo etnSOGDoNh1hRXabxF2vnr1Gf6TMym8GB0HswtlXn+fcv2hOV+fLTZW4+Hbl1CuBHVa8v 8VK34rdMVvZKeycP/PtSGv2TUzNeOtmmksFJ9jxg/Z8Pd2XdU8AtPgU5PGhxEca0BAGfe UVmsGUqc8LdN1v0ch26rUxhx4On/q0zjD/3UwXsRpZOTCwhbuZJx35eHJDStSx9LBTw== 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-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=ZIzIyZlj+68kmGSbdqsLyQq/tgseJM+9nfJeE1qDy4215Dj8sNQUnkkn3n0moLSjGbJy dYIu0DqQHEDEjOa4067jc8k5stZfut+KZlJxxwZiIF/X35mZweTrem1Av48JT2zAhCy+N EblknELesX/uOK4wvnszKdLy7rVyJj3ZHP5ccqK3wAzsWOIRYf3l/lEXE2xz0uqsT0R6L QY2YyQo5mSmyZ2kXfLMDxoRydSmg59/0ZQNPjmTWoIY44/I6pm/LGP0hYeT7F7Rn076j2 ISKIc8S0JIdv12RsnPrh5i62WrimwExr8rxrcKEs7vp3cwd49KWfglXzJ2C/Qfgq+Qw== 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=DsweYfxV; arc=none smtp.remote-ip=209.85.216.42 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 C953A606A33F for ; Mon, 30 Nov 2026 06:36:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C953A606A33F 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=DsweYfxV Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3b520f1604fso1447325a91.2 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=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:content-type; bh=hTiPLnuhm9c+sQTiXQOQx7ZKb4J6MdJg30zjhBmPJWM=; b=DsweYfxVaFhTBlT1DHTpWPt+GXWdRKjga71NzS2MFeLdxHPvxZNnL99HiqcLLLVgNp MgPHkFTM2eNZHxbYw+/bYWjTVhYtB/YYtAmRd3LWuTL0mWqdsNdARCdvjVvppJCQzLUq dmiUYu/BLhEpuOa+XVl0vRMi6nwbPlTeOkPxAeY/tBMXG2OdOtxDlO2MLtU+6PkpqhcY OBA7pbDjcWxNs5jO0mGyXPrlW4+CxSGRufX6r49KYYRQx4ZGsc22hhmvGl2CCrqe4lFa 91Gs/YcSO5A6htjCfS9nYJEzAxueV1VGuxXI09lYap2MonJ2L979k2ZcVNtrunRRVwAN yqIg== 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=P5TMh3UFUchN38qmLsIeXVkvsdYs35gSOoTFBMk+/Is6d0rEQGWEoYzXAeXbQIhrIe kG+Rf77pfe0qY/huyZp5SzG+AS9Xqy1oKrJWxSeu0a4Prw8hcNstfBuO6ele23FRbvVV qVKG/98fin78byOVsbD6cd6yOkf+oCUKxKXkoKO4wiXxAoTGqB+Y0ravitsaM00p+JlB ZEEHSYEfkNf4T0+I234ryY2rh5aKYDinH4527sT8UEvO3Yx04pXFzqWUuCwwfzixNE22 HgS6SeNxUUMKFgKx/zXBxkX+sFuxhqeguNOXeWzRtLe/G1+X9MG5SVKkrn89ji19zZWE vFWw== X-Gm-Message-State: APuU4Z8+TtMARuFh+Eq9m2jTr/qliowZYSyE2ulKxRmckdYE8Be2hotD tBvvrhuJFBizizMXtp5Y6PEhgPuz5jZx2hnvt2i534Y3mZE89PVxIy57 X-Gm-Gg: AZFdTZdQnhV2VXIMmUt7NXUGNWhvuM6VmgPJXVfu1BHMSuawRCZNHNJF+lxc+kakV3r 3x2P4sICf5CEApOSInpGzOA9486oNQrFpfFQ2F7Pb0S5cV1oE0ej+YoK9t1uG9Nuc995fMGch3i O7b9SYM4cHC1FD3T/Y1cck4vfrcxrPj+kruqKUFAEj/dbtW/o31ipH+ZjZe/H9RtM3KbR+hBvPy L9Vzt0Ng8iLmbUPL2qH5/hx3VgESKcAXPKxRzJJCVBcjeXB8gVbWe89ONjZhYFXvfs9lTMohXr+ 0Shzs+W2Fdzm60ZhmhXCqMNWcUWkJNu4quiaqIYz42xJndIqDc5771pSdFlbYqGelR/5CdjebaK ZUs1qtP+UOYuUHJaTnlRXFQp3qQGgwDVfUYsnL+d4BasoK121b2q3wOzptZvoXYEb/n5oJHei9T LQcpKxAovDm4bqbB1L2xt2hELXLIGeQJYxYmKKROr7Jxxtj0drlnQXql/3Ic+nJMfvtr6c7EoY9 G0YQEmJYa+GF/VVHOHgH3mSRcLOP3YQJtYq76dA8RWCQH2G0zmSkE3Mv+yfO7yqmwZ3KwHmNO3F Vb2cSfaDbmQK9hz856P7lf57jX0= 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: linux-doc@vger.kernel.org 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