From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020619; b=JtP2jrrwucULaeQthw2Y/pu2JBwH6nVRm0b1D1WLviuMLaMdcy7enVzKm46eeZvur95k gbQXoDcevlh8WzN0UH0rThGPu9Lto0ssKOUYIEK5tFOYMpgFmSATjPZLWGxl4q9Uz+AkF 04sMSccwdSGAv0sl+GYZGcfSD1w0JQcPyIkyoHBu5dWuk9CKXBw3jZAX0LBEutx6HHDqK KYg1vFHlr/uPlMAdpdlvxHbUQ5nURkeejNHfLR0urWs8gQdvReJ1OOXXrK8yBKLvpY6wQ vHqSvO4dqot/SB8Ey6CAnq4QFjs+3IhC+viXS+cJ6OG71R6Rfo1lFQxW3tTGFlPC9SA== 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=bn8GOGC6FWwsS6PqmRWxzSgrqRfaZEsEFXvlgL+SSBecdMma4n+s5yt7bRV5JXwR1228 wFlbazjolbKvMJAYer3waP17EjzMZGqvNPxR+0T4oRLl30CuJmazfkGCMeXopm+8i4aoo LHPdubEM5qy5lbzViiKS54a3+aiUh8pJDRIa1hhfJmA3JDEeIQ/hz5t7N6dydXOvl36FQ EK48UDdWrZQcsY4PfbMyD6FJDl77aWqbK96Nuxu+eROPET6c9YlqN30krZDBCpwYDk7H5 aI098JE1RaBOZI/0WxKd2eXNBZqMKLyJ3waKphOo2lrZzhfvWTOiso+Vw38EARJmYhg== 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.44 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 D45DA606A683 for ; Mon, 30 Nov 2026 06:36:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D45DA606A683 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-f44.google.com with SMTP id 98e67ed59e1d1-3b567ae3d54so484973a91.0 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=ToiKCX4jeVrOF4POv1sEM+g79ROH0mPwIK+sglLSs0NDxOwkOZ1TSpEW7fSJX2MTPj IfC6cmEYOTiAmqYLMa+QlJWD5nrNL5Q18Izqw60NAyaxAIqRXVaOKO8car9Nh7e86/e5 QZoxvtwtptoihzgkPtdLhRhlC9DpUybUxtQLWzlVSJDxUrsA/6PyayRXGmAHubjqqHus g34o+UeeeBFfNWEU6l5Jxb7gwPMlf/sDOQaFqatQL+c2DIXXUtCLfOCBf6HTzm+VxQJv 7oAFsiPAc7Aa1+PitCNpeRCD9fM82zCQtC+keBtvr/oO7qDA03+fX9ETGKdoPBWZ31DY czdg== X-Forwarded-Encrypted: i=1; AL+hErGoPrpRL7nldUpzGhfyUCTTyWz8HaYLt7xml6sY90hk+4T3zPbzEILWcrPAAUIhs3tmUzj35vMAo+0KyDo=@vger.kernel.org X-Gm-Message-State: APuU4Z/TCPNiN1WX1QyCnFZCJbTgotKV9wstkzw+iXwcUCvbpZI9yqnd GgCB8bLmp9tUDGEWCJ4+ZDHAe7dLyuCZGA4OxSSwlE+2+sj3ePL5qoQc X-Gm-Gg: AZFdTZfrgL8sKdpGX8QBMB7x5BkwgTZ8Z9IKldRiHtHj4HaQEANjFRkWh9r/RN4gR31 ktb6JzDARMRfWErFoaHPc2nVrDas7kA+St8rKRiXjndb761HTSVr1o2RtZFm/ZwBU60XsBiDJkj VHhoIph6313bnfPHbLoakKf8DpAIDpKiAsynZh2vw6g4usKIJfDVB6nE+HU+i4X2deHurXzo65X 0dKC1aSE/yo0ZZ6+kjIGlYKHXhMFFOg/zFOubvC7o6rtUYKmhJUPlr23hJkDRn34lYxNjiHGTwG EyhhIrKT+0tRm56Z9ng3+prjycGF1euhQ8pxDYsJkq9AdO8w+BZtkSM8QFaDLjr3jaRW+4t9OR1 HbdR6Jf6DXl95IvpDbYRDN53PYjRs29X3QWrpgqBqt3u3hkztATnDzOWF44Yf46dJsX8lT/Htv9 RAswLV7ppNQNyU8CDg+L+zm5IL2j75Mxzk3hMAovO3D1puuqmdMR9bgrVWOiT+K7cYX+d7tnsCK 2LPzqXAN9jXgswAPy+5EOzXEBIinzdkOe9Mdl8PbaZ7AsFXhZLVV/o7BEnA6GByulkG6EM/ccEo dcHEnnXkqWHJ7U2s4dA6FeLvIL8= 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-kernel@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