[PATCH v9 2/7] PCI: Add assert_perst() operation to control PCIe PERST#

Krishna Chaitanya Chundru posted 7 patches 1 month, 2 weeks ago
[PATCH v9 2/7] PCI: Add assert_perst() operation to control PCIe PERST#
Posted by Krishna Chaitanya Chundru 1 month, 2 weeks ago
Controller driver probes firsts, enables link training and scans the
bus. When the PCI bridge is found, its child DT nodes will be scanned
and pwrctrl devices will be created if needed. By the time pwrctrl
driver probe gets called link training is already enabled by controller
driver.

Certain devices like TC9563 which uses PCI pwrctl framework needs to
configure the device before PCI link is up.

As the controller driver already enables link training as part of
its probe, the moment device is powered on, controller and device
participates in the link training and link can come up immediately
and may not have time to configure the device.

So we need to stop the link training by using assert_perst() by asserting
the PERST# and de-assert the PERST# after device is configured.

Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
 include/linux/pci.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index d1fdf81fbe1e427aecbc951fa3fdf65c20450b05..ed5dac663e96e3a6ad2edffffc9fa8b348d0a677 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -829,6 +829,7 @@ struct pci_ops {
 	void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where);
 	int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
 	int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
+	int (*assert_perst)(struct pci_bus *bus, bool assert);
 };
 
 /*

-- 
2.34.1
Re: [PATCH v9 2/7] PCI: Add assert_perst() operation to control PCIe PERST#
Posted by Manivannan Sadhasivam 1 month, 2 weeks ago
On Sat, Nov 01, 2025 at 09:29:33AM +0530, Krishna Chaitanya Chundru wrote:
> Controller driver probes firsts, enables link training and scans the
> bus. When the PCI bridge is found, its child DT nodes will be scanned
> and pwrctrl devices will be created if needed. By the time pwrctrl
> driver probe gets called link training is already enabled by controller
> driver.
> 
> Certain devices like TC9563 which uses PCI pwrctl framework needs to
> configure the device before PCI link is up.
> 
> As the controller driver already enables link training as part of
> its probe, the moment device is powered on, controller and device
> participates in the link training and link can come up immediately
> and may not have time to configure the device.
> 
> So we need to stop the link training by using assert_perst() by asserting
> the PERST# and de-assert the PERST# after device is configured.
> 
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>

Acked-by: Manivannan Sadhasivam <mani@kernel.org>

- Mani

> ---
>  include/linux/pci.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d1fdf81fbe1e427aecbc951fa3fdf65c20450b05..ed5dac663e96e3a6ad2edffffc9fa8b348d0a677 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -829,6 +829,7 @@ struct pci_ops {
>  	void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where);
>  	int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
>  	int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
> +	int (*assert_perst)(struct pci_bus *bus, bool assert);
>  };
>  
>  /*
> 
> -- 
> 2.34.1
> 

-- 
மணிவண்ணன் சதாசிவம்