From: Inochi Amaoto <inochiama@gmail.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Niklas Cassel" <cassel@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Aksh Garg" <a-garg7@ti.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Inochi Amaoto" <inochiama@gmail.com>,
"Rhys Tumelty" <rhys@tumelty.co.uk>,
"Manikandan K Pillai" <mpillai@cadence.com>,
"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
"Qiang Yu" <qiang.yu@oss.qualcomm.com>,
"Hans Zhang" <18255117159@163.com>, "Yao Zi" <me@ziyao.cc>
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 <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: [PATCH v5 7/8] PCI: cadence: Use phy bulk data api to simplifiy the logic
Date: Wed, 25 Nov 2026 12:36:38 +0800 [thread overview]
Message-ID: <20261125043639.249525-8-inochiama@gmail.com> (raw)
In-Reply-To: <20261125043639.249525-1-inochiama@gmail.com>
According the document of cadence PCI controller, it use multiple
phys for multi-lane setup, so replace the loop of phy operation
with phy bulk apis.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/pci/controller/cadence/pcie-cadence.c | 62 +++++--------------
drivers/pci/controller/cadence/pcie-cadence.h | 2 +-
2 files changed, 16 insertions(+), 48 deletions(-)
diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/controller/cadence/pcie-cadence.c
index 0ac980249941..8ed2a679625d 100644
--- a/drivers/pci/controller/cadence/pcie-cadence.c
+++ b/drivers/pci/controller/cadence/pcie-cadence.c
@@ -179,39 +179,22 @@ EXPORT_SYMBOL_GPL(cdns_pcie_reset_outbound_region);
void cdns_pcie_disable_phy(struct cdns_pcie *pcie)
{
- int i = pcie->phy_count;
-
- while (i--) {
- phy_power_off(pcie->phy[i]);
- phy_exit(pcie->phy[i]);
- }
+ phy_bulk_power_off(pcie->phy_count, pcie->phy);
+ phy_bulk_exit(pcie->phy_count, pcie->phy);
}
EXPORT_SYMBOL_GPL(cdns_pcie_disable_phy);
int cdns_pcie_enable_phy(struct cdns_pcie *pcie)
{
int ret;
- int i;
- for (i = 0; i < pcie->phy_count; i++) {
- ret = phy_init(pcie->phy[i]);
- if (ret < 0)
- goto err_phy;
+ ret = phy_bulk_init(pcie->phy_count, pcie->phy);
+ if (ret)
+ return ret;
- ret = phy_power_on(pcie->phy[i]);
- if (ret < 0) {
- phy_exit(pcie->phy[i]);
- goto err_phy;
- }
- }
-
- return 0;
-
-err_phy:
- while (--i >= 0) {
- phy_power_off(pcie->phy[i]);
- phy_exit(pcie->phy[i]);
- }
+ ret = phy_bulk_power_on(pcie->phy_count, pcie->phy);
+ if (ret)
+ phy_bulk_exit(pcie->phy_count, pcie->phy);
return ret;
}
@@ -221,10 +204,8 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
{
struct device_node *np = dev->of_node;
int phy_count;
- struct phy **phy;
- int i;
+ struct phy_bulk_data *phy;
int ret;
- const char *name;
phy_count = of_property_count_strings(np, "phy-names");
if (phy_count < 1) {
@@ -233,31 +214,18 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
return 0;
}
- phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
- if (!phy)
- return -ENOMEM;
-
- for (i = 0; i < phy_count; i++) {
- of_property_read_string_index(np, "phy-names", i, &name);
- phy[i] = devm_phy_get(dev, name);
- if (IS_ERR(phy[i])) {
- ret = PTR_ERR(phy[i]);
- goto err_phy;
- }
- }
+ phy_count = devm_phy_bulk_get_all(dev, &phy);
+ if (phy_count < 0)
+ return phy_count;
+ else if (phy_count == 0)
+ return -ENODEV;
pcie->phy_count = phy_count;
pcie->phy = phy;
ret = cdns_pcie_enable_phy(pcie);
if (ret)
- goto err_phy;
-
- return 0;
-
-err_phy:
- while (--i >= 0)
- devm_phy_put(dev, phy[i]);
+ devm_phy_bulk_put_all(dev, phy);
return ret;
}
diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
index 4a96e1869e53..3cde29592331 100644
--- a/drivers/pci/controller/cadence/pcie-cadence.h
+++ b/drivers/pci/controller/cadence/pcie-cadence.h
@@ -274,7 +274,7 @@ struct cdns_pcie {
bool is_rc;
bool is_hpa;
int phy_count;
- struct phy **phy;
+ struct phy_bulk_data *phy;
const struct cdns_pcie_ops *ops;
const struct cdns_plat_pcie_of_data *cdns_pcie_reg_offsets;
int max_link_speed;
--
2.56.1
WARNING: multiple messages have this Message-ID (diff)
From: Inochi Amaoto <inochiama@gmail.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Niklas Cassel" <cassel@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Aksh Garg" <a-garg7@ti.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Inochi Amaoto" <inochiama@gmail.com>,
"Rhys Tumelty" <rhys@tumelty.co.uk>,
"Manikandan K Pillai" <mpillai@cadence.com>,
"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
"Qiang Yu" <qiang.yu@oss.qualcomm.com>,
"Hans Zhang" <18255117159@163.com>, "Yao Zi" <me@ziyao.cc>
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 <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: [PATCH v5 7/8] PCI: cadence: Use phy bulk data api to simplifiy the logic
Date: Wed, 25 Nov 2026 12:36:38 +0800 [thread overview]
Message-ID: <20261125043639.249525-8-inochiama@gmail.com> (raw)
In-Reply-To: <20261125043639.249525-1-inochiama@gmail.com>
According the document of cadence PCI controller, it use multiple
phys for multi-lane setup, so replace the loop of phy operation
with phy bulk apis.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
drivers/pci/controller/cadence/pcie-cadence.c | 62 +++++--------------
drivers/pci/controller/cadence/pcie-cadence.h | 2 +-
2 files changed, 16 insertions(+), 48 deletions(-)
diff --git a/drivers/pci/controller/cadence/pcie-cadence.c b/drivers/pci/controller/cadence/pcie-cadence.c
index 0ac980249941..8ed2a679625d 100644
--- a/drivers/pci/controller/cadence/pcie-cadence.c
+++ b/drivers/pci/controller/cadence/pcie-cadence.c
@@ -179,39 +179,22 @@ EXPORT_SYMBOL_GPL(cdns_pcie_reset_outbound_region);
void cdns_pcie_disable_phy(struct cdns_pcie *pcie)
{
- int i = pcie->phy_count;
-
- while (i--) {
- phy_power_off(pcie->phy[i]);
- phy_exit(pcie->phy[i]);
- }
+ phy_bulk_power_off(pcie->phy_count, pcie->phy);
+ phy_bulk_exit(pcie->phy_count, pcie->phy);
}
EXPORT_SYMBOL_GPL(cdns_pcie_disable_phy);
int cdns_pcie_enable_phy(struct cdns_pcie *pcie)
{
int ret;
- int i;
- for (i = 0; i < pcie->phy_count; i++) {
- ret = phy_init(pcie->phy[i]);
- if (ret < 0)
- goto err_phy;
+ ret = phy_bulk_init(pcie->phy_count, pcie->phy);
+ if (ret)
+ return ret;
- ret = phy_power_on(pcie->phy[i]);
- if (ret < 0) {
- phy_exit(pcie->phy[i]);
- goto err_phy;
- }
- }
-
- return 0;
-
-err_phy:
- while (--i >= 0) {
- phy_power_off(pcie->phy[i]);
- phy_exit(pcie->phy[i]);
- }
+ ret = phy_bulk_power_on(pcie->phy_count, pcie->phy);
+ if (ret)
+ phy_bulk_exit(pcie->phy_count, pcie->phy);
return ret;
}
@@ -221,10 +204,8 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
{
struct device_node *np = dev->of_node;
int phy_count;
- struct phy **phy;
- int i;
+ struct phy_bulk_data *phy;
int ret;
- const char *name;
phy_count = of_property_count_strings(np, "phy-names");
if (phy_count < 1) {
@@ -233,31 +214,18 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
return 0;
}
- phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
- if (!phy)
- return -ENOMEM;
-
- for (i = 0; i < phy_count; i++) {
- of_property_read_string_index(np, "phy-names", i, &name);
- phy[i] = devm_phy_get(dev, name);
- if (IS_ERR(phy[i])) {
- ret = PTR_ERR(phy[i]);
- goto err_phy;
- }
- }
+ phy_count = devm_phy_bulk_get_all(dev, &phy);
+ if (phy_count < 0)
+ return phy_count;
+ else if (phy_count == 0)
+ return -ENODEV;
pcie->phy_count = phy_count;
pcie->phy = phy;
ret = cdns_pcie_enable_phy(pcie);
if (ret)
- goto err_phy;
-
- return 0;
-
-err_phy:
- while (--i >= 0)
- devm_phy_put(dev, phy[i]);
+ devm_phy_bulk_put_all(dev, phy);
return ret;
}
diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
index 4a96e1869e53..3cde29592331 100644
--- a/drivers/pci/controller/cadence/pcie-cadence.h
+++ b/drivers/pci/controller/cadence/pcie-cadence.h
@@ -274,7 +274,7 @@ struct cdns_pcie {
bool is_rc;
bool is_hpa;
int phy_count;
- struct phy **phy;
+ struct phy_bulk_data *phy;
const struct cdns_pcie_ops *ops;
const struct cdns_plat_pcie_of_data *cdns_pcie_reg_offsets;
int max_link_speed;
--
2.56.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-25 4:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 4:36 [PATCH v5 0/8] phy: core: Add phy bulk helpers support Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 1/8] phy: core: Add common helper to add phy phandle device link Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 2/8] phy: core: Add common helper for get phy phandle by index Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 3/8] phy: core: Make phy_put() ignore NULL and error pointers Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 4/8] phy: core: Add phy bulk data helper functions Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:20 ` Vladimir Oltean
2026-11-25 15:20 ` Vladimir Oltean
2026-11-25 4:36 ` [PATCH v5 5/8] phy: core: Add managed " Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 6/8] doc: phy: Document some bulk " Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:28 ` Vladimir Oltean
2026-11-25 15:28 ` Vladimir Oltean
2026-11-25 4:36 ` Inochi Amaoto [this message]
2026-11-25 4:36 ` [PATCH v5 7/8] PCI: cadence: Use phy bulk data api to simplifiy the logic Inochi Amaoto
2026-11-25 15:23 ` Vladimir Oltean
2026-11-25 15:23 ` Vladimir Oltean
2026-11-25 4:36 ` [PATCH v5 8/8] ata: ahci_imx: Use bulk PHY APIs for calibration PHYs Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:39 ` Vladimir Oltean
2026-11-25 15:39 ` Vladimir Oltean
2026-11-25 15:56 ` Niklas Cassel
2026-11-25 15:56 ` Niklas Cassel
2026-11-25 22:48 ` Inochi Amaoto
2026-11-25 22:48 ` Inochi Amaoto
2026-11-25 4:50 ` [PATCH v5 0/8] phy: core: Add phy bulk helpers support sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125043639.249525-8-inochiama@gmail.com \
--to=inochiama@gmail.com \
--cc=18255117159@163.com \
--cc=Frank.Li@nxp.com \
--cc=a-garg7@ti.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=corbet@lwn.net \
--cc=dlan@gentoo.org \
--cc=dlemoal@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=looong.bin@gmail.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=me@ziyao.cc \
--cc=mpillai@cadence.com \
--cc=neil.armstrong@linaro.org \
--cc=qiang.yu@oss.qualcomm.com \
--cc=rdunlap@infradead.org \
--cc=rhys@tumelty.co.uk \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=skhan@linuxfoundation.org \
--cc=vkoul@kernel.org \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.