From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020619; b=pUo1gvFJRNzuu0907ZGupOozUdYB1oAH5YYX5hrfSfD7oBuHeXiyLMOq2wQDzTL6E2FS febo4OVjaWkqi7ZwX2ODHC8neGkNa/MTSnFVVGmIV3bJKedlksZGF6tziCwbiZM00tWwO dz93/EYo72f5Hi8oDjNxiPahRKDqADwo/2IbT0Shsl/9qbGO+4DPOt/vX7zyljRcpCFEJ hHC7DhkRurfhKo1YcxGElgdyRHGn8I4f46zBeUlCmtQ0Xg3dywuep5uHWSS+1bkh/+JmK BkEaSUhXQkg2FcAa+A62O6ej0ebBrWcyFX9UkJdw14Obq0sSZxFiJLwZ1ikIBU2QmGw== 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=dMErKd+8Z0dZVSCjsex4dwQv+dq3Mr0nERwqoNfgpolxlL9Npz4vDcIu75ON1KPRtNso 9HzAsoY7V/dbFiw0e+ygxA79YLD2Uhv00xVp5RhgRXWIh1K3EERBto76eImRJF0rHoBIV ANbzCXYVm2ebg1UYPvYWcG/LiIWoliEl9ixN7lLiBolUv/jrugWXY+bkByZCBqkw8LywR E7CEhLYCGF1PsAUrmeY6tKlwqptgvLsuIzqOHn/pGUG0G7njR4vTvYQv/12p3NtrUnTab 0BoNPOZiUGFwuFJatYQvPMsvuS7Rrr3tkL4toMZk0ziOUC51dbjGHq8HvUIqgFO/qHQ== 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.215.180 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 C59FC606A333 for ; Mon, 30 Nov 2026 06:36:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C59FC606A333 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-pg1-f180.google.com with SMTP id 41be03b00d2f7-cded697ba49so998434a12.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=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=1rA8J3gZCXTE7+8QJQ1911CXmyHnBPdIbngpNnhU3l4UAKPhHv7uT8HhYDae0HElNM qb7poZ2ipv76nplI12G7JV5Gf4w1ExnBMN9/XRp6mkYVjFu/zQ01UNKHulkxCKPigx3I VtKL4Dw43vAURZaWOxnDR/GNXeawr0BLJmEHRL5ydRpFiidjSUeUC3zB+qzqSUzpe4Y3 WOu9EQP7i/DGIVXI2H4tBXmqaK4qQjCIrxvpz8/grTrDK/Uj/PMydO56/fiOzGpbtKj0 Uzop92SC6MCzdHysGn7d44E9HZYlnq1DwSTMCwaVR+jxgTuHGHLgRThIsl6TeO7H/Vzr Qx+A== X-Forwarded-Encrypted: i=1; AL+hErHxblOs42ZchwwhCgi2w2lg/lEsafcupxptXh3NpJNnV8VyubZNHuLW8eUGI4lEGoQ2+tegn28temI=@vger.kernel.org X-Gm-Message-State: APuU4Z8W/qoizrb3ApYZGZSuf3Sb2msxT0HH+sL8DRESZIyz0urEn/Kt FluN95Po8yaWY/lJL9F/7+P8UVeQ0YrijV2JRxXUtX/2aToi2YyFluj5 X-Gm-Gg: AZFdTZemX6zyRD9xMK/LYgHici7EYWAz4Kka5sXjCt8kJZeIomvZCU9hBcZetNUitb7 7qouG9amiWpCVLRirtere3ZCrPM8Drdk6PfwTsEFW6tvBdkzs794AND5xZWUV4XWluxTVQ3v+VY IW77MY2apSrddrDeKsv87OAR5kLojJveawJGFg6038Q3NTX0rx9lJKIfb+oViOn7R1/n24hiUkc BP4Hk2lN71to11KziMweQ1a8CTGuStAClU6m0Yh/teH0GhCQrlH03F83WmgkJnR+f/iZhVwcaSj sLbrZq3dJEJ6JuGwNO04bPMG1+3Rgdc6FGMM9hocjFPkm3lY1gKCKW57zZzkG78Z6rxssJ0S3v2 tJIkEj+lAGgZyf5mmngUW+WNEZbvGU6ZBNFbUaWhPDlyxjhk/TK/HVAzNRx24hBpBs23ZPcninJ Vs+LfNdKIHkU8Sg8aT2fTCEnd6NroghM9zi8jhOzPICJMGUnXWLJn3oovNBPrtASXZteRXUs5Pp e5IH6kJglmyuVG0PNqUuUjpG3aNw3roeE2gMvuMMTtxKyCApGTm7TxZVsr9CuuZkKlwHJBe6V8H G2G2gkcDwAYgJM6cJ0+SPzNxS4s= 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-ide@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