On Sat, Apr 12, 2025 at 07:19:57AM +0530, Krishna Chaitanya Chundru wrote: > TC9563 is a PCIe switch which has one upstream and three downstream > ports. To one of the downstream ports ethernet MAC is connected as endpoint > device. Other two downstream ports are supposed to connect to external > device. One Host can connect to TC9563 by upstream port. TC9563 switch > needs to be configured after powering on and before PCIe link was up. > > The PCIe controller driver already enables link training at the host side > even before this driver probe happens, due to this when driver enables > power to the switch it participates in the link training and PCIe link > may come up before configuring the switch through i2c. Once the link is > up the configuration done through i2c will not have any affect.To prevent > the host from participating in link training, disable link training on the > host side to ensure the link does not come up before the switch is > configured via I2C. > > Based up on dt property and type of the port, tc9563 is configured > through i2c. > > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@xxxxxxxxxxxxxxxx> > Reviewed-by: Bjorn Andersson <andersson@xxxxxxxxxx> > Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > --- > drivers/pci/pwrctrl/Kconfig | 10 + > drivers/pci/pwrctrl/Makefile | 2 + > drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 628 +++++++++++++++++++++++++++++++ > 3 files changed, 640 insertions(+) > > diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig > index 990cab67d41332a8508d4150825c621eb86322c5..d14ef2b0ffd84f9a8c4266fdd57a27f7f3611ca4 100644 > --- a/drivers/pci/pwrctrl/Kconfig > +++ b/drivers/pci/pwrctrl/Kconfig > @@ -21,3 +21,13 @@ config PCI_PWRCTL_SLOT > This is a generic driver that controls the power state of different > PCI slots. The voltage regulators powering the rails of the PCI slots > are expected to be defined in the devicetree node of the PCI bridge. > + > +config PCI_PWRCTRL_TC9563 > + tristate "PCI Power Control driver for TC9563 PCIe switch" > + select PCI_PWRCTL > + help > + Say Y here to enable the PCI Power Control driver of TC9563 PCIe > + switch. > + > + This driver enables power and configures the TC9563 PCIe switch > + through i2c. > diff --git a/drivers/pci/pwrctrl/Makefile b/drivers/pci/pwrctrl/Makefile > index ddfb12c5aadf684cf675585b1078ecb7c24649cc..5d0163c75878d5bf702bc6c892fa31bfea5a95e3 100644 > --- a/drivers/pci/pwrctrl/Makefile > +++ b/drivers/pci/pwrctrl/Makefile > @@ -7,3 +7,5 @@ obj-$(CONFIG_PCI_PWRCTL_PWRSEQ) += pci-pwrctrl-pwrseq.o > > obj-$(CONFIG_PCI_PWRCTL_SLOT) += pci-pwrctl-slot.o > pci-pwrctl-slot-y := slot.o > + > +obj-$(CONFIG_PCI_PWRCTRL_TC9563) += pci-pwrctrl-tc9563.o > diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c > new file mode 100644 > index 0000000000000000000000000000000000000000..547c764a6f405a676216309ef6ebcaffbbc3f1d6 > --- /dev/null > +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c > @@ -0,0 +1,628 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#include <linux/delay.h> > +#include <linux/device.h> > +#include <linux/i2c.h> Missing #include <linux/gpiod/consumer.h> You are using gpiod_*() calls, but don't include a corresponding header, which breaks your driver on arm platform. > +#include <linux/mod_devicetable.h> > +#include <linux/module.h> > +#include <linux/of.h> > +#include <linux/of_platform.h> > +#include <linux/pci.h> > +#include <linux/pci-pwrctrl.h> > +#include <linux/platform_device.h> > +#include <linux/regulator/consumer.h> > +#include <linux/string.h> > +#include <linux/types.h> > +#include <linux/unaligned.h> > + -- With best wishes Dmitry